Linux environment variables PS1 set linux environment variables PS1 in simple words is to set the command prompt to display the content, as follows: www.2cto.com 1root@10.1.1.200 :~ # The meaning of the prompt in the PS1 variable: \ d: represents the date in the format of weekday month date, for example, Wed Dec 12 \ H: complete host name. For example, the hostname is debian. linux \ h: only the first name of the host. For example, debian ,. linux is omitted \ t: The display time is in the 24-hour format, for example, HH: MM: SS \ T: The display time is in the 12-hour format \ A: The display time is in the 24-hour format: HH: MM \ u: the account name of the current user, for example, root \ v: BASH version information, for example, 3.2 \ w: The complete working directory name. In the home directory ~ In place of/etc/default/\ W: Use basename to get the working directory name. Therefore, only the last directory is listed. In the preceding example, only default \ # is displayed \#: the following command is issued: www.2cto.com \ $: the prompt character. If it is root, the prompt is: #, and the normal user is: $, but the command prompt is found to be in a color, you can set the PS1 variable to make the prompt color. In PS1, set the Character Sequence color format to \ [\ e [F; Bm \], where "F" is the font color, 30-30 ~ 37; "B" indicates the background color, numbered 40 ~ 47. Unset: \ [\ e [0m \] www.2cto.com code corresponding to each font color: reset = 0, black = 30, Red = 31, Green = 32, yellow = 33, blue = 34, Magenta = 35. cyan = 36, white = 37
\ E [1; 31 m set to red, \ e [0 m color reset. You only need to replace 31 with the desired color code to print the code corresponding to the color background: reset = 0, black = 40, Red = 41, Green = 42, yellow = 43, blue = 44, Magenta = 45. blue = 46, white = 47 B code meaning 0 OFF1 highlighted (commonly used) 4 underline 7 reverse white display 8 invisible below is the PS1 variable prompt into color www.2cto.com 1root@10.1.1.200: opt # PS1 = '$ {debian_chroot: + ($ debian_chroot)} \ [\ e [01; 32m \] \ u \ [\ e [00m \] @ \ [\ e [01; 31m \] $ ip \ [\ e [00m \]: \ [\ e [01; 34m \] \ W \ [\ e [00m \] \ $ '2root @ 10.1.1.200: opt # Remember to write in. in the bashrc file.