Zhanhailiang Date: 2014-10-18
1. Load the configuration file sequence during the Linux login process:
/ETC/PROFILE→/ETC/PROFILE.D/*.SH→~/.BASH_PROFILE→~/.BASHRC→[/ETC/BASHRC]
You can view the default ~/.BASHRC file as follows:
[Root@~/Wade/Codereview/redis-2.8.17] Cat~/. BASHRC#. BASHRC# User specific aliases and functions# Source Global Definitionsif [ - F /etc/Bashrc]; Then./etc/Bashrcfi
2. shell command prompt and color is configured by PS1:
[Root@/etc/Init.d] Echo $PS 1[\[\e[ +; 40m\]\u@\W]
The parameters commonly used in PS1 are as follows:
\d: #代表日期, formatted as weekday month date, for example: "Mon 1" \h: #完整的主机名称 \h: #仅取主机的第一个名字 \ t: #显示时间为24小时格式, such as: hh:mm:ss\t: #显示时间为12小时格式 \a: #显示时间为24小时格式: hh:mm\u: #当前用户的账号名称 \v: #BASH的版本信息 \w: #完整的工作目录名称 \w: #利用basename取得工作目录名称, so only the last directory is listed \#: #下达的第几个命令 \$: # Prompt character, if root, the prompt is: #, the average user is: $
3. Color value setting: The format of character color in PS1 is: \[\e[f; Bm\], where "F" is the font color, number is 30-37, "B" is the background color, number 40-47. The color table is as follows:
F B30 black, red, green, yellow, blue, Purple 36 Green Blue Panax Notoginseng White
Depending on the color table, the color of the Linux Terminal command line can be personalized by applying the character color formatting. For example, to set the command line format for the green Word black, display the current user's account name, the first name of the host, the full current working directory name, 24-hour format time, you can use the following command:
#PS1 = ' [\[\e[32;40m\]\[email protected]\h \w \t]$ '
4. Take the author's ~/.BASHRC configuration as an example:
[Root@~]# cat ~/.BASHRC#. BASHRC# User specific aliases and functionsExport PS1=' [\[\e[32;40m\]\[email protected]\w]\$ '# Source Global Definitionsif [ - F /etc/Bashrc]; Then./etc/Bashrcfi
5. After the modification is completed, reload the next ~/.BASHRC to take effect:
Linux Modify shell command prompt and color