Skip to content

Command-Line Interface

A command-line interface (CLI) is a text-based user interface (UI) used to run programs, manage computer files and interact with the computer1.

You can check out a more comprehensive guide made by the excellent Django Girls team. Skip to the summary for a quick refresher. Longer tutorials and even interactive ones are available.

The Windows tabs refer to PowerShell.

Tip

Press Tab at any point while typing to toggle the autocomplete: if there is only one option it will be filled, if there is more than one hit Tab again to show a list of all the possible options.

Learn more about a command

If for some reason Google does not work, open the local manual page for a command:

man [command]

Scroll down linewise by typing J or Down up with K or Up, and go to the next page with Space or Page Down. Quit the documentation by typing Q.

Remember, man like manual.

Get-Help [command]

Current directory

Print the path to the current directory

pwd
pwd

List all the files

List all the files and directories.

In the current directory:

ls

Remember, ls like list.

ls

Remember, ls like list.

In any directory:

ls path/to/dir
ls path/to/dir

Absolute vs relative paths

An absolute path is relative to the root directory of the file system (/ for Linux, C:\ for Windows)2. For example: /home/pmn/repos/dsdocs.

A relative path starts from some given working directory, avoiding the need to provide the full absolute path.

In our example, if the current directory is /home/pmn, to list all the files in dsdocs run

ls repos/dsdocs

Change current directory

To change the current directory:

cd path/to/dir

Remember, cd like change directory.

cd path/to/dir

Remember, cd like change directory.

Create a directory

To create a directory in the current directory:

mkdir dir_name

Remember, mkdir like make directory.

mkdir dir_name

Remember, mkdir like make directory.

Move a file

Rename or move a file

mv old_file_name new_file_name
mv old/file/path new/file/path

Remember, mv like move.

Move-Item Path c:\old_path -Destination c:\new_path

  1. TechTarget: CLI

  2. Wikipedia: Absolute and relative paths