Command Line

You're interacting with your server using a Terminal application, which accepts text commands that you type into it. This is sometimes referred to as a command-line interface (CLI).

The Terminal application itself gives you access to a shell program that runs on the server. This program—bash most commonly, or zsh on recent Macs—allows you to give commands to the computer via that command-line interface.

Let's go over some of the commands that are available to you in the command line. The more you work in the terminal, the more you'll have occasion to use these. You'll know that your Terminal, running a shell, accepting input via the command line, is ready for input when it gives you a prompt:

Important concept: File paths

There are two ways of referring to the location of a file in the computer's file system: absolute path and relative path.

  • Absolute path
    The absolute path for a file is given relative to the root directory /. A "notes" file stored on my Desktop would be indicated by the absolute path /home/ubuntu/Desktop/notes.txt. That path is unique, and will always refer to that file, regardless of where it is used.
  • Relative path
    The relative path for a file is given relative to wherever I currently "am" in the filesystem, ie. my working directory. If I wanted to list the contents of the notes file, the command I give would depend on where I am in the filesystem.
    • If I'm on the Desktop I would say cat notes.txt
    • If I'm in the ubuntu home directory I would say cat Desktop/notes.txt
    • If I'm somewhere else in the file system I might say cat ~/Desktop/notes.txt

Either system of addressing will work for most purposes. It's usually just a question of what is most convenient.

Useful shell commands