This time, talk about the "command line prompt" related content.
Shell programs like bash are an essential part of working with Linux. The bash prompt also has a very important role to play.
"Command-line Prompt" in English is "command prompt", wherein "prompt" has prompted, push the meaning, according to this meaning, the shell "command line prompt" has prompted to push the user input meaning.
(The following is an example of bash, which is a shell program)
In the current Linux distribution, the prompts are generally as follows:
[Email protected]/etc]$
The above prompt contains information such as "Login username","host name" and "Current directory". In this way, prompts the user to enter the same time, also prompts some useful information to the user.
The content displayed in the prompt can be customized. In addition to "logged in User name","host name" and "Current directory", you can also display a variety of information such as time, date, console number, connection time, etc.
Conversely, for security reasons, you can also display no information, only "$" or "#".
Detailed setup of the prompt do not say here, want to modify the prompt, only need to modify the shell environment variable "ps1" (if a command needs to enter more than one line, you can set "ps2").
For example, the environment variable "ps1" in the shell has been set to:
ps1="
There is no redundant information, only the "$" tag (the root user is the "#" tag when logged in).
At this point, if you want to display the "ps1" as mentioned earlier ("[[email protected]/etc]$"), set "ps1" to:
$ ps1='
"ps1" can be set after the user login, but also before logging in, set the method is the current user's *home directory * [Fn:1] under the ".bashrc" file to append a line at the end of the set, set as follows:
Export ps1='
This way, the new command-line prompt will be used the next time you log in.