The Windows Command Prompt (CMD) is a great tool for programmers and regular Windows users because it offers a ton of commands to control the entire Windows operating system. All those commands can boost your productivity as you don’t have to click through all the graphical user interfaces. Therefore, knowing some of the basic Command Prompt commands is never bad.
If you’re interested, keep on reading!
Most of the commands I am going to mention are also compatible with the Windows PowerShell unless there’s an asterisk (*) in front of the command. (e.g. *color)
Here’s an overview of the commands:
To get further information and a list of available parameters of these commands, you can always type
help <command> or <command> /? inside your CMD window.
#1: cd
The first command prompt command of this list is an absolutely basic one. However, you definitely need to know about it!
The cd command is used for changing the directory you are currently working in.
Usually, if you open cmd, the standard working directory is C:\Users\username\.
To navigate to a different directory, you simply need to type: cd [Path]
To navigate to a folder that exists in the current directory, you can just type the name of the folder, not the entire path. (e.g. cd Desktop)
To navigate to the previous folder use cd ..
#2: mkdir & rmdir
We use mkdir to create a folder and rmdir to remove one.
The desired command is followed by the path the folder should be in or by just the name of the folder.
For example:
- mkdir Folder1
- rmdir Folder1
- mkdir C:\Users\user1\Folder2
- rmdir C:\Users\user1\Folder2
#3: echo foo > bar.txt
This command is useful for creating a new file with some text in it. If you try to write something in a file that already exists, it’ll get overridden.
This is how you use the command:
echo This is some text > filename.txt
If you want to create an empty file, you can use echo. > filename.txt
Keep in mind that this syntax doesn’t work for PowerShell.
#4: dir
The dir command shows all files and folders of a directory as well as some additional information. You can either specify a path after the command to show the content of a directory you are not currently working in or only type the command to show the contents of the current directory.
#5: robocopy
The robocopy command copies one or multiple files of a specified path to another path.
The syntax for this command looks like this:
robocopy <source path> <destination path> [file(type)]
If you don’t specify a file or file type, robocopy will copy the whole content from the source path.
To copy multiple files or specific file types you can use an asterisk (*). It basically means “everything”.
For example: robocopy C:\Users\user1 C:\Users\user2 *.txt
There are a ton of additional options for this command. You can have a look at all of them here.
#6: move
Of course, there also is a command for moving files. The syntax for this command is similar to robocopy and very simple:
move <source file path> <destination path>
For example:
move C:\Users\user1\file1.txt C:\Users\user2\
If you don’t specify a filename for the destination, it uses the original filename. Otherwise, the file you want to copy will be renamed to the name you specified in the destination path.
#7: del
To delete a file using cmd, you just need the del command. It is used like this:
del <file path>
You can either specify a whole path to the file or just type the name of the file if it is inside the current working directory.
Be careful not to confuse this command with rmdir, as rmdir deletes entire folders, not files!
#8: clip
The clip command/attribute copies the output of any desired command. Compared to other commands from this list, the clip command isn’t really a command. In reality, it is an additional instruction that comes after a different command.
So, to copy a command’s output, simply put | clip after it.
For example:
echo this is a test | clip
This command copies “this is a test” to the clipboard, as it is the output of the echo command.
#9: cls
The cls command is a pretty simple one. Its only task is to clear the console (CMD/PowerShell) window.
This command doesn’t take any additional arguments.
#10: echo
Echo is used to display text inside the console window (CMD/PowerShell).
It’s rather simple. Just write the text you want to print out after the echo command.
For example:
Besides printing out text, the echo command is also used for other features like creating files, etc.
However, printing text to the console is one of its main use cases.
#11: *prompt
A very useful one this the prompt command. It changes the prompt text in cmd.
The standard prompt is just the current path. (e.g. C:\Users>)
The syntax for the prompt command looks like this:
prompt <new prompt text>
You can either select a basic text as your prompt or use different parameters to display symbols and information.
You can find information about the different parameters and symbols in the official documentation of Microsoft or by typing help prompt inside CMD.
#12: *color
With the color command, you can change the background color and text color of your console window.
For example, the command color a makes the text of your console green.
Here is a list of every available color:
Parameter | Color | Parameter | Color |
0 | Black | 8 | Gray |
1 | Blue | 9 | Light Green |
2 | Green | A | Light Blue |
3 | Aqua | B | Light Aqua |
4 | Red | C | Light Red |
5 | Purple | D | Light Purple |
6 | Yellow | E | Light Yellow |
7 | White | F | Bright White |
You are allowed to give two parameters to the command.
The first one is the background color, and the second one is the text color.
If you use only one parameter, only the text color will change, and the background color resets to black.
#13: help
The help command provides you with useful information about the most commonly used commands.
To use it, just type help into CMD or PowerShell.
If you want to get help to a specific command, you can simply write the commands keyword behind the help keyword.
For example:
#14: shutdown
The shutdown command can be used to shut down, restart, and hibernate the computer or to log off a user.
There are a lot of additional parameters to this command. Additionally, you can specify a reason for the shutdown. To get a detailed description of all the parameters, enter shutdown without any parameters.
Nevertheless, here’s a list of the most important parameters.
To shut down immediately, use:
shutdown -p
To shut down with a warning and delay, use:
shutdown -s
To restart, use:
shutdown -r
To abort the shutdown, use:
shutdown -a
To log the current user off, use:
shutdown -l
#15: tasklist
Tasklist lists all tasks that are currently running as well as some information about them.
Again, there are multiple arguments you can pass to this command. As always, you can display all possible parameters with help tasklist.
If you do not specify any parameters, the command will list all processes with their corresponding PID numbers, session names, and their memory usage.
#16: taskkill
With taskkill, you can terminate processes by their PID name or process name.
This command requires some parameters:
- To kill a task by its PID: taskkill /PID <PID>
- To kill a task by its process name: taskkill /IM <name>
Additionally, you can choose to terminate every child process a process started with the /T option.
#17: systeminfo
Systeminfo displays a ton of information about your computer.
For example, the hostname, the OS name & version, the system type, etc.
I suggest trying this command on your own to see what information it shows.
#18: ping
#19: ipconfig
The ipconfig command displays information about the network configuration of your network adapters.
For example, it shows your IP address, your MAC address, and your default gateway.
If you want even more detailed information, you can use ipconfig /all.
#20: netstat
Netstat shows you every active connection of your computer.
If you don’t pass any arguments to the command, it will show the protocol, the local address, the foreign address, and the connection state of each connection.
Thanks for reading!