The Command Line#

The command line (also called command-line interface, command prompt, shell), is a text-based application for viewing, handling, and manipulating files on your computer.

How do I open the command line?#

This depends on your operating system:

  • Windows: Click the “Start” button, search for “cmd” and open it.

  • Mac OS: Open the “Finder”, go to “Applications” > “Utilities” and open the “Terminal” application.

  • Linux: This depends on your distribution. Usually you can find the terminal application in the applications menu.

    If you have a Linux operating system installed, you probably know how to open the terminal already. ;)

How do I use the command line?#

The general syntax of any command in any operating system in the command line is: command + [optional parameters] + [optional flags]

  • Command: Name of the command, e.g. cd, ls, dir

  • Parameter: Specifies the command, e.g. cd Desktop Desktop specifies in which directory to move to

  • Flag: Optional boolean parameter, e.g. -l or /b

Note: The commands, parameters and flags are always separated by whitespaces.

More important note: Avoid file names containing whitespaces, because that might lead to problems when executing commands, e.g.

$ cd ./my folder would be interpreted as a command with two parameters ./my and folder.

Setting quotation marks would solve the problem as well, but it’s better to generally avoid whitespaces in file paths.

What Commands exist?#

This again depends a little bit on your operating system. The commands on Windows and Unix (Max OS, Linux) systems are a bit different.

If you want to use the Unix commands on Windows, use the PowerShell or the GitBash instead of .

Windows command

Mac OS / Linux command

Description

Example

cd

cd

change directory, When changing hard drives (C:\ to M:) execute M:\ afterwards

cd M:\Documents

cd

pwd

print working directory

cd

dir

ls

list directories/files

dir

copy

cp

copy file

copy c:\test\test.txt c:\windows\test.txt

move

mv

move file

move c:\test\test.txt c:\windows\test.txt

mkdir

mkdir

Make (new) directory

mkdir testdirectory

rmdir (or del)

rm

Remove directory

del c:\test\test.txt

rmdir /S

rm -r

Remove directory recursivly

rm -r testdirectory

exit

exit

close the window

exit

Tip

You can also use the unix commands on Windows, if you use the GitBash application which came with the Git For Windows installation

Tutorial videos#

Windows#

Mac / Linux#