User Tools

Site Tools


Command-Line Interface

Also: Wikipedia: Command-line interface

The Command-Line Interface (CLI), also called Terminal; Console; Command Prompt, is a way to interact with a computer. Unlike in a Graphical Interface, where you use your mouse and on-screen buttons, in a CLI all interaction is done with the keyboard, through a Text Interface.

Old-time Windows users might be familiar with MS-DOS, which features a Command-Line Interface. However, the Unix CLI is a much more powerful tool than MS-DOS.

Command Prompt

On Unix, a CLI starts out something like this:

johndoe@computer12 /home/johndoe $ █

It shows:

  • username (johndoe)
  • hostname (computer12)
  • current directory (/home/johndoe)
  • the text-cursor – indicates where you can type.

The above combined is called the command prompt. It tells you who you are, on which machine you are, and where you are within the machine.

Unlike on Windows where paths look like C:\Users\John Doe, on Unix paths look like /home/johndoe. Spaces are allowed but not common as they tend to cause problems.


After opening a terminal window, the user johndoe types ls, and hits Return. This is the command to show the contents of the current directory.

johndoe@computer12 /home/johndoe $ ls
documents     letter.txt
johndoe@computer12 /home/johndoe $ █

There are two files: documents (a directory) and letter.txt. Directories are typically shown in bold.

Next, John wants to see the contents of letter.txt. He enters the command cat, followed by the filename.

johndoe@computer12 /home/johndoe $ cat letter.txt
Dear Reader,

This is an example text file.

Yours truly, John Doe
johndoe@computer12 /home/johndoe $ █

To navigate to the documents directory, John types cd (change directory), followed by the name of the directory.

johndoe@computer12 /home/johndoe $ cd documents
johndoe@computer12 /home/johndoe/documents $ █

You can see that the command prompt has changed, and he is now inside the documents directory. John can then type ls again to see what's inside.

To go back to the parent directory, he types cd ...

johndoe@computer12 /home/johndoe/documents $ cd ..
johndoe@computer12 /home/johndoe $ █

For a list of basic commands, please refer to basics

wiki/unix/cli.txt · Last modified: 2019/04/25 15:23 (external edit)