Shell Prompt

Share

What is a "Shell Prompt" on Linux?

The shell prompt is the text that appears on the command line before the area where you can type terminal commands, for example John@Mint:~$ is the default shell prompt format on Linux Mint. It's also called "command prompt," however Windows' default terminal emulator is called "Command Prompt," which makes things a bit confusing.

A window titled virtual@cucriosities:~. Its main pane has a dark background and contains one line of text. It reads: in green text, virtual@curiosities, then a white colon (:), followed by a blue tilde (~), and a dollar white dollar sign ($). A space and then a flashing rectangle. The word "date" is typed. Afterwards the current date is appears under the first line. The multi-colored code that was in the first line appears again at the bottom with the flashing rectangle to its right.
The command date being executed in the GNOME Terminal on Linux Mint. The multi-colored text before the flashing rectangle is the shell prompt.

Shell prompts serve three purposes:

  1. When you type a command in the terminal, its output will appear on the terminal. The shell prompt indicates that the output of the command has finished and the user may start typing a new command.
  2. The shell prompt helps distinguish commands typed by the user from the output of a program when reading the text on the terminal.
  3. Short shell prompts tend to be only a single character long plus a space character, such as a dollar sign ($) or a greater than sign (>). Longer shell prompts can include contextual information for the user. It's common for the shell prompt to indicate the value of the pwd command, i.e. what is the "current directory," as this environment variable affects the behavior of programs. The shell prompt may also include the user's username. Although this may not sound very useful as most people know who they are, it's possible to use some terminal commands to switch from one user to another, including to switch to the root user, which has full power over the system and can do massive damage if you run the wrong command with it.
A teletypewriter device printing terminal messages on a piece of paper. The messages read in all caps: CONNECTION CLOSED BY FOREIGN HOST. CONNECTION TO TTY.LIVINGCOMPUTERMUSEUM.ORG CLOSED. % % % % TELNET 192.168.251.28 TRYING 192.168.251.28... CONNECTED To 192.168.251.28. ESCAPE CHARACTER IS '↑]'. UNIX (R) SYSTEM V RELEASE 4.0 (AMIX) LOGIN: GUEST PASSWORD: UNIX SYSTEM V RELEASE 4.0 AT&T AMIGA (UNLIMITED). AMIX COPYRIGHT (C) 1984, 1986, 1987, 1988 AT&T ALL RIGHTS RESERVED LAST LOGIN: TUE MAY 7 05:11:17 FROM LOCALHOST LAST LOGIN: TUE MAY 7 05:11:17 FROM LOCALHOST SYS (text ends here)
An amiga UNIX login performed via teletype. Observe how in the line % TELNET 192.168.251.80 the shell prompt is the percent sign (%) before the TELNET command. Photo: Andy Diller on Flickr. License: CC BY-SA 2.0.

The shell prompt isn't part of the command that will be interpreted by the shell. It can't be edited or removed from the terminal by pressing the Backspace key. However, it's normally possible to customize the shell prompt to display something else, and there are even programs you can install to display colorful information on your terminal instead of the default information.

Although the shell prompt is normally only part of the last line, it's possible for a custom shell prompt to span one entire line before the area where you type commands, or even to span multiple lines.

Observations

In scripting examples, often the author will write the input after a dollar sign ($) or greater sign (>) that represents the shell prompt and distinguish it from the output of the program. For example:

$ date
Thu Feb 20 11:28:20 PM -03 2025

In the code snippet above, date is meant to be a typed command, and we know this because there is a common shell prompt before it. Meanwhile, the line after it, without the shell prompt, is supposed to be the output of the command.

Quotes

A command prompt, also referred to as a prompt or a shell prompt, is a short, automatically generated text message at the beginning of the command line that serves to (1) inform a user that the system is ready for the next command, data element or other input and (2) help the user plan and execute subsequent operations.

https://www.linfo.org/command_line.html (accessed 2025-02-20)

A shell prompt is the main way to interact with a command line only interface. A typical shell prompt will look something like this:

[username@domain directory]$

It displays the user (username) you are logged in as, the server you are logged into (domain) followed by the current directory (or folder) you are in (directory). All this information is followed by a symbol that simply separates the hostname user and directory from the rest of the prompt. Most systems use a $ symbol, but %, # and > symbols are also used.

https://www.marquette.edu/high-performance-computing/linux-intro.php (accessed 2025-02-20)
Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments