How to change or hide the current hostname of centos
Many times, the company uses a cloud host that is bought or a virtual machine made from a template, and the other party tells the host name cannot be changed,
The host name is too long It’s so ugly. Today, it’s relatively simple to post with the tested method, mainly to hide the actual host name without changing
Edit the .bashrc file in the current user’s home directory to add
PS1='[ ${debian_chroot:+($debian_chroot)}\[emailprotected] \w]\$’
The source .bashrc file takes effect after saving
[[emailprotected] ~]#
You can also do this
PS1=’${debian_chroot:+($debian_chroot)}:\w\$’
Don’t leave one at all: ~#
Plus Color
PS1=”\033[33;1m]\u\033[31;1m]@service \033[37;1m\t\033[0m[\033[34;1m] \w[\033 [0m][\e[33;1m] # [\e[0m]”
Simple explanation
[email protected] 12:07:37 ~ #
PS1=”\033[33;1m]\u\033 [31;1m]@service \033[37;1m\t\033[0m[\033[34;1m] \w[\033[0m][\e[33;1m] # [\e[0m] “
\033[33;1m]\ubr/>\033[31;1m\]@service
\033[37;1m\t
\033[0m[\033 [34;1m] \w
[\033[0m][\e[33;1m] #
[\e[0m]”
The above is the color of each segment , It’s not difficult to see that the color value comes first, and what parameter is assigned color after the value. ..
Part of the parameter explanation:
\u show user
\t show time
\w show symbol~
\h show host name (short)
\ H Display the host name (long)
\n Line feed
Part of the color prompt:
\e is the color setting part “[32;40m]” , 32 is the foreground color, and 40 is the background color. “M\” is essential:
30 40 black 31 41 red 32 42 green 33 43 ×××34 44 blue 35 45 magenta 36 46 blue blue 37 47 white
p>