Windows Command Line Cheat Sheets


Navigating the file system:

C:\ > cd : Changes the current directory.

C:\ > cd dirName

C:\ > dir : Lists the files and directories in the current directory.

C:\ > popd : Changes the current directory back to the previously stored directory.

C:\ > chdir or $ pushd : Changes the current directory and stores the previous directory.

C:\ > pushd [path]

C:\ > tree : Lists the files and directories in a hierarchical format.

Creating and managing files and directories:

C:\ > md or C:\ > mkdir : Creates a new directory

C:\ > mkdir new_folder

C:\ > copy : Copies a file or directory.

C:\ > copy file1.txt file2.txt : To copy file1.txt to file2.txt            

C:\ > copy foldername newfoldername /s : To copy the whole folder with its contents to a new folder     

C:\ > move or C:\ > ren : Moves or renames a file or directory.

C:\ > move file1.txt file2.txt or ren file1.txt file2.txt : To rename file1.txt to file2.txt 

C:\ > move foldername newfoldername

C:\> ren foldername newfoldername

C:\ > del or C:\ > erase : Deletes a file or directory.

C:\ > del file1.txt or C:\ >erase file1.txt :   To delete file1.txt

Viewing and editing files:

C:\ > type : Displays the contents of a file.

C:\ >  type filename

C:\ > more: Allows you to view the contents of a file one page at a time.

C:\ >  more fileName

C:\ > notepad : A simple text editor to edit the file in command line.

C:\ >  notepad fileName

C:\ > edit : A simple text editor in command line, that works only in command prompt.

C:\ >  edit filename

Searching and filtering:

C:\ > find or C:\ > findstr : Search for a specific string in a file or multiple files.

To search for “search_string” in file1.txt

                 C:\ >  find “search_string” file1.txt or findstr /s /c:”search_string” file1.txt

C:\ > forfiles : Select a file or a set of files and then execute a command on those files.

 C:\ >  forfiles /p “C:\Windows” /s /c “cmd /c echo @file” : To search for files in the directory “C:\Windows” and print their name.


Permissions and ownership:

C:\ > cacls : Displays or modifies access control lists (ACLs) of files.

                  C:\ >  cacls file1.txt : To view the permissions of file1.txt

                  C:\ >  cacls file1.txt /g user1:F :   To give permission


C:\ > cls : Clears the terminal screen.

C:\ > exit : exits the command line

Learn the complete Python programming language

Read more

Stay connected with news and updates!

Join our mailing list to receive the latest news and updates from our team.
Don't worry, your information will not be shared.

We hate SPAM. We will never sell your information, for any reason.