Linux Trivia Translation-prompt on command line

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.