Note: 'Please note that throughout this post, we use the terms 'directory' or 'folder' but they are the same thing.'
Let's get started!!
What is the command line?
The command-line or command-line interface is a text-based application for viewing and handling files on your computer through the use of commands. It's much like Windows Explorer or Finder on the Mac, but without the graphical interface. Other names for the command line are cmd, CLI, prompt, console, or terminal.
Open the command-line interface
To start, we need to open our command-line interface first.
Depending on your version of Windows and your keyboard, one of the following should open a command window (you may have to experiment a bit, but you don't have to try all of these suggestions
- Go to the Start menu or screen, and enter "Command Prompt" in the search field.
- Go to Start menu → Windows System → Command Prompt.
- Hold the Windows key and press the "R" key to get a "Run" window. Type "cmd" in the box, and click the OK key.
On Windows, you probably see a
>, like this:
Each command will be prepended by a
> and one space, but you should not type it. Your computer will do it for you.
The part up to and including the
> is called the command line prompt, or prompt for short. It prompts you to input something there.
Writing your first command
Let's start by typing this command:
Your first command: Windows
And then hit
The computer will print your username.
It'd be nice to know where are we now, right? Let's see. Type this command and hit
> cd We should see something similar to this: C:\Users\username
Note: 'cd' stands for 'change directory'.
Learn more about a command
Many commands you can type at the command prompt have built-in help that you can display and read! For example, to learn more about the current directory command:
List files and directories
So what's in it? It'd be cool to find out. Let's see:
List files and directories
> dir Directory of C:\Users\username 05/08/2020 07:28 PM <DIR> Applications 05/08/2020 07:28 PM <DIR> Desktop 05/08/2020 07:28 PM <DIR> Downloads 05/08/2020 07:28 PM <DIR> Music
Note: 'DIR' stands for 'Directory'.
We can also cd into a folder and see all the list of items in that folder:
> cd Desktop
And hit enter, you should see all the files inside of your desktop directory.
Change current directory
> cd Documents
Hit Enter after that!
Check if it's changed:
> mkdir Testing
To Create a folder or directory
> cd Testing
To open or navigate to the folder or directory
A small challenge for you: in your newly created
practice directory, create a directory called
test. (Use the
Now that you are in the Testing directory
Create another folder or directory inside it using the mkdir command like we did above and give it any name of your choice and navigate to that folder using the cd command
Having done that, Congrats!
We don't want to leave so many commands on our CLI, we can easily navigate back to our Desktop Directory using the following command:
> cd ..
cd command will change your current directory to the parent directory (that is, the directory that contains your current directory or the folder that contains your current folder).
Deleting the Testing directory
Note: Deleting files using
rmis irrecoverable, meaning the deleted files will be gone permanently! So be very careful with this command.
> rmdir /S Testing Testing, Are you sure <Y/N>? Y
Done! To be sure it's deleted, let's check it:
If you do not see the Testing Dir, Congrats!! You have successfully deleted it.
That's it for now! You can safely close the command line now. Let's do it the hacker way
Here is a summary of some useful commands:
|exit||close the window||exit|
|cd||change directory||cd testing|
|cd||show the current directory||cd|
|mkdir||create a new directory||mkdir testingdirectory|
|rmdir (or del)||delete a file||del c:\testing\testing.txt|
|rmdir /S||delete a directory||rm -r testdirectory|
|[CMD] /?||get help for a command||cd /?|
These are just a very few of the commands you can run in your command line.