Basic File System Commands
Here's the basic file system commands you should know, most of these are actually CMD/Command Prompt commands but PowerShell
has aliases for them. In PowerShell I don't know anyone who types Get-ChildItem
, and while you may see the
short alias gci
occasionally (especially on Microsoft blogs), most people type dir
because it's
familiar muscle memory (or ls
if they are Linux/UNIX users as there are aliases for those as well).
Because they will work from both the CMD Command Prompt and PowerShell they're doubly useful to know - you'll be productive regardless of which shell you're using - and many of these will work in Linux/Bash as well! This isn't a complete list, but is enough to get you doing all basic Windows File Explorer functions via the CLI.
Navigating a system from the Command Prompt (CMD or PowerShell) will be much easier if you know these, and because of various switches and options it can be both quicker and possible to do things you just can't from Windows File Explorer.
Command | Description |
---|---|
cls |
Clears the Console window, short for "clear screen" |
c: or e: |
Switch the current drive/volume by just typing the drive letter and a colon :, you can use any valid letter. |
dir |
Shows the Directory listing (displaying all files / folders), you can specify somewhere else too, eg.
dir c:\temp But just dir will show the directory listing of the current folder. |
md or mkdir |
Make Directory ie. create a Folder such as: mkdir c:\temp\new2 to create a new2 folder inside
c:\tempIf you just use mkdir new2 it will create new2 in whatever directory you are in. |
cd or chdir |
Change Directory, changes to the specified directory / folder, eg. cd c:\temp\new2 Or just cd new2 if you were already in the c:\temp folder. |
rd or rmdir |
Remove Directory (if it's not empty it will prompt you if you mean it) - rd c:\temp\new2 will remove
the new2 subfolder of c:\temp |
pwd |
In PowerShell (or Linux/Bash) it Prints the current Working Directory, which is also shown in your prompt, eg. PS C:\temp> In DOS/CMD you can just type cd with no folder to change to and it will display your Current Directory.
|
copy |
Copy a file, specify source and destination which is often a folder, eg.
copy file.txt c:\temp Which will copy file.txt in the current directory to c:\temp |
move |
Move a file, similar to copy by you don't end up with a second copy - the original is removed.move c:\temp\file.txt c:\windows\temp will move the file to c:\windows\temp regardless of what
folder you are in. |
ren |
Rename a file or folder, specify CurrentName and NewName, eg.
ren file.txt "Descriptive Name.txt" |
del |
Delete a file, just specify the file like del file.txt or del c:\temp\file.txt Note: does NOT move it to the Recycle Bin and there's no undelete! |
write or echo |
Prints something to the screen, if multiple words aren't in "quotes" they will appear on separate lines, like
write "Hello, world!" Note: write only works in PowerShell, but echo works in both (and in CMD you don't need
quotes if there's spaces) |
more |
Displays the contents of a text file to the screen, one page at a time if needed. Eg: more file.txt
(press q to quit)Also works with pipeline input (covered in the Boot Camps) such as: dir c:\windows | more |
help |
Get help for any PowerShell command/alias or a list of basic CMD Windows commands (shows the options and examples)
eg. help copy |
alias |
In PowerShell almost all of these are aliases, alias will show you all aliases, or you can specify one
to see the real command.Eg: alias copy shows it is really Copy-Item in PowerShell. Doesn't do anything in CMD/DOS.
|
SOME.EXE |
You can run any regular .EXE file, eg. ping 127.0.0.1 or notepad script.ps1 to edit a
script, the .EXE isn't needed. |
exit |
Quits your CLI Console session and closes the window, doesn't ask for confirmation! |
.\script.ps1 |
Runs the named script in the current directory. You can't just type the name, you need to specify the
path in PowerShell. For .BAT or .CMD scripts you can just type their name as if they were .EXE files, even in PowerShell. |
Seems overwhelming if you're new to using the CLI. There's also a sort of play-by-play CLI Task Test you can try: a list of very basic CLI tasks to try from a command prompt - along with an answer list showing what to type to complete them all (you can use PowerShell on your own PC).
You can keep this page open as a quick reference.
If you feel like you need extra practice then I strongly suggest Zed's CLI Crash Course which has exercises for most basic file system commands. You can also use this if you'd like to learn basic Linux/macOS/Bash commands, like ls, cp, rm, mv, etc.