How to change the Linux command line prompt

What is the command line prompt

As shown in the figure below, these series of features, namely the command line prompt

Insert picture description here

How to modify the command line prompt

For example, we know that in the default Linux Shell command line prompt, the directory displays not an absolute path, but a relative path. If we want to modify it, we can look like the following

# cat   /etc/profile.d/motd.sh 
export PS1='[\u@\H \w]\$ '

Of course this special variable PS1can also be placed /etc/profileinside

Which command line prompt symbols can be used in total

We can man bashsee

Insert picture description here

Commonly used special symbols are explained as follows

symbol meaning
\ u Current user name
\H CPU name
\w Absolute path of current directory
\W Relative path of current directory
\$ User prompt, root #, non-root $

Reference

https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html

Guess you like

Origin blog.csdn.net/xys2015/article/details/114002063