First, the preliminaries. In order to understand the Linux command prompt, it’s necessary to recognize the significance of the pieces it’s comprised of. Certain things are necessary in order to have a terminal session at all.


It’s not possible to use the command line without logging in first. In order to log in, one needs a user account.

It’s also necessary to have something to log in to. Every terminal session is predicated on being logged in to a particular computer.

So far, this sounds similar to using a modern operating system like Windows or OSX. But here’s where that metaphor breaks down. The command line isn’t like Windows or OSX (Linux is the operating system). It’s closer to Windows Explorer or Finder on OSX. It’s always tied to a folder or directory the user is working in. If there’s no working directory, there’s no terminal session.

Every user has a default working directory, called their ‘home directory.’ On most Linux-like operating systems, this directory is /home/username, but on OSX1, it’s /Users/username.

Finally, there’s more than piece of software that works as a command prompt. These are called shells. Most of the time, the Bourne Again shell, colloquially referred to as “bash” is the default.

The Default Linux Command Prompt


Decoding the Prompt

Usually, it indicates who’s logged in, and the name of the machine they’re logged into. A common default name for a computer is localhost.localdomain.

Next, it tells you what directory you’re currently in. Sometimes it’s spelled out completely, such as /usr/local/bin/, or sometimes it’s shortened to just the name of the folder, e.g. bin. The tilde – ‘~’ – character is shorthand for the logged-in user’s home directory.

One user, called the superuser, has special privileges on a system. The username for the superuser is usually root. It’s generally not a good idea to log in as the superuser unless you’re doing work that absolutely requires those privileges, such as installing software system-wide.

A hash – ‘#’ – character at the end of a prompt is used to remind you that you’re logged in as root and to be careful. The $ at the end of a prompt means you’re using bash or similar. A % means you’re using csh, tcsh, zsh, or similar.

Continuation Prompt

When typing a long command, it’s possible to split the command onto multiple lines. Pressing enter will attempt to run the command unless the last character on the line is a backslash – ‘\’ – which tells the prompt you want to type a new line on the screen instead. Not unlike “Shift+Enter” on many messaging apps.

user@host:~$ echo \
> "hello"

The continuation prompt, by default, is a greater than sign – ‘>’ – that indicates that more input is expected. In addition to after a backslash-enter combination, it also appears when parentheses or quotes are left open (unmatched).

  1. OSX is not Linux, but uses the bash prompt and ships with a similar suite of tools. Certain commands may have slight syntax differences, however.