Basic Command Line Uses

Navigation and file operation basics

Preface

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.

cd

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 cd.

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

Using 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".

del ChromeInstaller.exe

If we did not want to cd first we could have called del against a fully qualified path instead: del C:\Users\FooRoo\Downloads\ChromeInstaller.exe

rmdir

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

The /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.


Revision #2
Created 24 May 2022 21:40:18 by PipeItToDevNull
Updated 25 May 2022 00:38:03 by PipeItToDevNull