Basic Command Line Uses
Navigation and file operation basics
- Move around in the file-system (FS) with
- Delete files using
- Delete folders (directories) using
Command Prompt and PowerShell are interchangeable for most basic tasks in Windows. For the purpose of this guide either can be used and any differences will be noted.
When you open Command Prompt as a standard user (not as admin) you are by default located in
C:\Users\<username> (your user folder) this can be seen in the prompt as well.
When opening Command Prompt as admin you will be put into
C:\Windows\System32 by default.
We do not often want to work in the root of our user profile or in System32 so we will need to change what folder we are in. Folders can also called "Directories", if we want to Change Directory we will use
Say we want want to remove a file that is in
C:\Users\FooRoo\Downloads, we will
cd to that directory by running
cd C:\Users\FooRoo\Downloads. The prompt in your Command Prompt or PowerShell will change to this new path letting us know where we are now working out of.
del is simple, we call the command and a file name that we want to delete. We are in our Downlods folder and want to delete a file called "ChromeInstaller.exe".
If we did not want to
cdfirst we could have called
delagainst a fully qualified path instead:
In addition to the
ChromeInstaller.exe file in our Downloads we also want to remove a folder there called
temp and all of its contents.
Assuming we are still in the proper directory we will remove
temp and everything inside of it with:
rmdir /s temp
/s on this command specifies that we want the folder and everything in it gone. If we tried to only
rmdir temp we would get an error about it having children items.