OS Lab
CMD commands for the Windows OS
Contents
1. How does a command line work?
2. How do you open the command prompt?
3. How do you enter commands in the command prompt?
4. Windows CMD commands: an overview
How does a command line work?
The command line (also called the console or terminal) is a text-based interface within the
operating system, that forwards commands from the user to the operating system. This makes it
possible, for example, to organize files, start programs, or run other commands linked to the
operating system, computer, or network.
In older operating systems (like MS-DOS), you had to work without a graphical user interface, and
oftentimes even navigate without a mouse. Instead, you had to type in all commands – the
directory structures were then displayed as plain text on the screen. But even after the switch to
graphical operating systems, the command line remained text-based.
In general, the connection between operating system – regardless of whether graphical (GUI =
graphical user interface) or text-based (CLI = command line interpreter) was condensed under the
term “Shell.” The default command line interpreter for Windows is called [Link]. In addition,
however, there’s also the “PowerShell”: This offers more options than [Link]. For example,
automations can be created better with PowerShell. In this way, users can create script programs
with the PowerShell scripting language.
How do you open the command prompt?
There are various options for accessing the command line in Windows. Technically speaking, the
command line is the [Link] program. This executable file should be found in the system
directory of your Windows folder. (If you right-click on the file, Windows also gives you the option
to start the program as an administrator – in case you have the access data for this.) To reach the
program more quickly, you can use the search bar or the run menu. The latter is opened under
Windows 7, 8, and 10 with the key combination Win + R. Then all you have to do is type “cmd”
into the search field and press the OK button.
The command prompt has long had a fixed spot in the Windows start menu as well. Under
Windows 7 and Windows 10, the program is found in the “System Tools” folder. With Windows 8,
Microsoft replaced the start menu with a start screen. But the command prompt is also found via the
apps here. Alternatively, Windows 8 as well as Windows 10 both offer the “Power User Tasks
Menu.” You can open this with the key combination Win + X. In this way, you can find the
command prompt in the normal execution as well as the administrator version.
How do you enter commands in the command prompt?
CMD functions via defined commands. These have to be entered correctly, otherwise the command
prompt can’t run the task. The same goes for parameters that you link to the commands. Individual
1
OS Lab
commands can be extended using options (such as arguments). These are generally given as a letter
with a minus sign (-), plus sign (+), or slash (/). CMD also allows placeholders. For so-called wild
cards, use an asterisk (*) or question mark (?). While the latter replaces a single character (i.e. letter,
digit, or other character), the asterisk stands for any number of characters.
Note: In the command prompt and commands, you also frequently have to work with path specifications. You
need these to navigate through your directories or specify exact positions in commands. For the input of a
path, use the backslash (\).
Individual CMD commands can be combined with one another. Through a pipe, the output of the
first command is interpreted as input for the following command. In the command prompt,
commands are linked to one another with a vertical line (|). This line itself is called a pipe, but
officially is known as a vertical bar. Vertical bars pass data from one command to the next:
• CommandA | CommandB
There’s also the possibility of redirection: where the output of a command is directly forwarded to
a file (>) or the content of a text file is understood as input for the command (<).
• Command > File (output in file)
• Command < File (input from file)
Finally, Windows command line commands can also be connected in such a way that they run
directly after one other. This can be controlled via a relatively simple form (&), but also via two
more complex variations. It’s also possible to only run the second command if the first was
successful. Or, you can set up the exact opposite as well: The second command is only run if the
first doesn’t work (||). Both options can even be combined so that there’s an either-or string of
commands:
• CommandA & CommandB (the second command is run directly after the first)
• CommandA && CommandB (the second command is only run if the first was successful)
• Command A || CommandB (the second command is only run if the first was not successful)
• CommandA && CommandB || CommandC (the second command is only run if the first was
successful, otherwise the third command is run)
Tip: Each command has its own syntax and individual options. So that you don’t have to memorize all of
these, CMD offers a help command: Using help command or command /? you can obtain information about
how to handle the command.
It’s also extremely helpful that the command prompt remembers your last entered CMD commands.
Using the up and down arrow keys on the keyboard, you can recall your earlier entries. This also
means, though, that you can’t use these keys to scroll through the CMD window. This is usually
done with the mouse instead. But if you prefer to scroll using keys and are ready to give up the
recall command function, you can alter the corresponding setting: right-click on the command
prompt and enable the “Scrolling” option.
Command, file names or path specifications, as well as arguments, are separated from one another
using spaces. It also usually doesn’t matter if you use upper- or lower-case letters. It’s only
important in a few cases whether you write the parameter in upper- or lower-case (generally only
when two different parameters are abbreviated with the same letter, and are only differentiated from
one another through the case).
2
OS Lab
Windows CMD commands: an overview
There are almost 300 commands for Windows and its predecessor, MS-DOS. Over the decades,
some commands have been kept around, some have only recently been added with newer versions
of Windows, and others have been removed or replaced. In our comprehensive list, we explain what
the different commands mean and on which Windows versions they run. This way, you can quickly
look up whether the CMD commands that you know still function with Windows 10.
Basic Commands
CMD Windows
Sr. Description
command version
1 cls Clears the content of the screen. All Win/DOS
2 ver Displays the current version number of Windows or MS-DOS. All Win/DOS
Displays the current date and allows you to change it. With the parameter /T
3 date the date is shown without the option to change.
All Win/DOS
Displays the current time and allows it to be changed. If the parameter /T is
4 time entered, the command prompt only shows the time and offers no option to All Win/DOS
directly change it.
5 echo Displays a message and is mainly used within scripts and batch files. All Win/DOS
Displays all folders and files within the current directory. You can restrict the
6 dir output by attributes (/A), simplify the list (/B), or display all subdirectories All Win/DOS
and their files (/S).
Displays the current directory and lets you switch to other directories. With
the parameter /D plus drive and path specification, you can also switch
7 cd drives. Use cd.. to switch to a higher directory (has the same function as the
All Win/DOS
chdir command).
Displays the current directory and lets you switch to other directories. With
the parameter /D plus drive and path specification, you can also switch
8 chdir drives. Use chdir.. to switch to a higher directory (has the same function as
All Win/DOS
the cd command).
Creates a new directory on the specified path. If directories don’t already
9 md exist on the path, md creates them automatically (you can also use the mkdir).
All Win/DOS
Creates a new directory on the specified path. If directories don’t already
10 mkdir exist on the path, mkdir creates them automatically (you can also use the md).
All Win/DOS
Deletes a directory. This must not contain any files, even hidden ones. You
11 rd can delete an entire directory tree with the /S parameter (you can also use All Win/DOS
rmdir).
Deletes a directory. This must not contain any files, even hidden ones. You
12 rmdir can delete an entire directory tree with the /S parameter (you can also use the All Win/DOS
rd command).
Graphically displays the directory structure of a drive or path. With the /F
parameter, all files in the folders are also listed out. /A also ensures that only
ASCII characters are used for the graphical representation. The command
13 tree takes into account all subdirectories starting from the given path. If you don’t
All Win/DOS
enter a path, the current folder is used as the output.
Changes the title of the command prompt. Spaces are allowed, but not all
14 title special characters such as a slash, for example, because they may be All Win/DOS
interpreted as instructions for a parameter.
3
OS Lab
Changes the background (first value) and text color (second value) of the 10/8/7/Vista/
15 color command prompt. The color lies between 0 (black) and F (white). XP
16 prompt Changes the display of the command prompt. All Win/DOS
Opens a new command prompt window in which you can run a specific
17 start program or command.
All Win
18 edit Starts the MS-DOS editor, with which you can create text files. 32-bit/DOS
19 type Displays the content of a text file. All Win/DOS
Searches through a file or multiple files for a particular character sequence. If
you only want to know how frequently the word or phrase occurs, use the /C
20 find parameter. With the extension /I the command ignores upper- and lower-case
All Win/DOS
in the search.
Finds character sequences in one or multiple files. It gives you more options
10/8/7/Vista/
21 findstr when compared to the find command: you can search for files that contain
XP
various terms or with /C search for an exact word order.
22 help Displays help text for a specific command (you can also use the /? command) All Win/DOS
Lists out data (from a file or command) and outputs it again sorted – directly
23 sort in the command prompt, in a new file, or in another output.
All Win/DOS
24 path Creates and displays the path for searching executable files. All Win/DOS
25 set Displays environmental variables of [Link] and lets you configure them. All Win/DOS
Outputs the content of a file (for example, a text file) by the page. You can
26 more also use the command to split the output of another command into pages.
All Win/DOS
27 subst Assigns a drive letter to a path to create a virtual drive. All Win/DOS
Sets the execution of specified programs and commands for a specified point 10/8/7/Vista/
28 schtasks in time. You can create, delete, change, and display all scheduled tasks. XP
Lists all running processes – also on remote computers, if desired. The
10/8/7/Vista/
29 tasklist process ID also has to be specified, which is required for the taskkill
XP
command.
Ends one or more running tasks. You either have to specify the process ID
30 taskkill (PID) or image name.
10/8/7/Vista
Stops a process for a specified time. The command is used in batch files and
31 timeout scripts. If you use the /NOBREAK parameter, the command ignores any 10/8/7/Vista
keyboard input.
32 exit Ends [Link] All Win/DOS
Shuts down the computer (/s), triggers a restart (/r), or logs the user out (/l). A
10/8/7/Vista/
33 shutdown graphical user interface is displayed if you enter the parameter /I as the first XP
option in the command.