Command Prompt Definition

A command prompt, also referred to simply as a prompt, is a short text message at the start of the command line on a command line interface.

A command line interface (CLI) is an all-text display mode that is provided in a console or terminal window by a shell. A console is an all-text display mode that occupies the entire display monitor screen. A terminal window is a text-only window that emulates a console and which can be opened on a GUI (graphical user interface) screen. A shell is a program that not only provides the command line interface for Unix-like operating system but also executes (i.e., runs) commands that are typed into it.

The command line is the line on which commands are typed in a console or terminal window. A command is an instruction to tell a computer to do something, e.g., to execute a program.

The functions of a command prompt are (1) to inform the user that the system is ready for the next command, data element or other input and (2) to help the user plan and execute subsequent operations.

Prompts are found on the command line interface of any operating system that provides a CLI. This includes not only Unix-like operating systems but also MS-DOS and the various Microsoft Windows systems.

The contents of the command prompt change according to several factors, including the operating system, the specific shell or other text-mode program being used and individual user settings.

The default prompt on the bash shell, which is the default shell on Linux, contains the name of the user, the name of the computer and the name of the current directory (i.e., the directory in which the user is currently working). For example, for a user named sandra on a computer named localhost and who is working in a directory called work, the prompt would look like [sandra@localhost work]$.

If the user sandra is working in its home directory, the prompt for the bash shell would resemble [sandra@localhost sandra]$, assuming that the user's home directory has the same name as the user (which it does by default). Likewise, if the current directory is changed to the root directory, which is represented by a forward slash ( / ), the prompt would become [sandra@localhost /]$.

This generic prompt pattern is often temporarily replaced by other prompts that are requests for specific information from the user. One of the most common is a request for a password, which would change the prompt to Password:, for example when using the su (i.e., substitute user) command or any other program that requires root (i.e., administrative) permissions (i.e., authority to read, write or execute certain files or directories).

As is the case with virtually everything else in Unix-like operating systems, the contents of prompts can be changed by the user or the system administrator. A first step in changing prompts is usually to look at the pattern of the prompt currently being displayed, which can be seen by using the echo command with the PS1 variable, which represents the prompt pattern, as follows:

echo $PS1

echo tells the system to repeat what follows, and the dollar sign tells it to repeat its value instead of its name. The default pattern will usually resemble [\u@\h \W]\$ . A new prompt can be set for the current session by typing PS1= followed by the new pattern in quotes. The prompt can be changed permanently by editing the appropriate configuration file.

The prompts for MS-DOS are less informative. A typical prompt would look like:


This only tells the user that the current directory is the root directory on the C: hard disk drive (HDD) or the first partition (i.e., logically independent section) of that drive.

Created July 17, 2005.
Copyright © 2005 The Linux Information Project. All Rights Reserved.