The environment variable PS1 under Linux is simply to set the content displayed by the command prompt, as follows:
root@10.1.1.200:~#
The meanings of the prompts in the PS1 variable:
d: represents the date, the format is weekday month date, for example: "Mon Aug 1"
H: Full host name. For example: My machine name is: fc4.linux, then the name is fc4.linux
h: Only take the first name of the host, as in the above example, it is fc4, .linux is omitted
t: Display time in 24-hour format, such as: HH:MM:SS
T: Display time in 12-hour format
A: The display time is in 24-hour format: HH:MM
u: Current user’s account name
v: BASH version information
w: The complete working directory name. The home directory will be replaced by ~
W: Use basename to obtain the working directory name, so only the last directory will be listed
$: Prompt character. If you are root, the prompt is: #, for ordinary users: $
vi ~/.bashrc
export PS1="[\u@localhost \w]$"
#如果希望立即生效的话
source ~/.bashrc
The environment variable PS1 under Linux is simply to set the content displayed by the command prompt, as follows:
The meanings of the prompts in the PS1 variable:
d: represents the date, the format is weekday month date, for example: "Mon Aug 1"
H: Full host name. For example: My machine name is: fc4.linux, then the name is fc4.linux
h: Only take the first name of the host, as in the above example, it is fc4, .linux is omitted
t: Display time in 24-hour format, such as: HH:MM:SS
T: Display time in 12-hour format
A: The display time is in 24-hour format: HH:MM
u: Current user’s account name
v: BASH version information
w: The complete working directory name. The home directory will be replaced by ~
W: Use basename to obtain the working directory name, so only the last directory will be listed
$: Prompt character. If you are root, the prompt is: #, for ordinary users: $
Why do you all change the command prompt?
I usually change it directly
/etc/hosts
/etc/hostname
Change it insidePS1='[\u@localhost \W]\$'
Directly
or modify
/etc/hostname
Just log in again after making changes