1. Linux登陆过程当中加载配置文件顺序:linux
/etc/profile → /etc/profile.d/*.sh → ~/.bash_profile → ~/.bashrc → [/etc/bashrc]
可查看默认的~/.bashrc文件以下:vim
1 [root@localhost ~]$ cat ~/.bashrc 2 # .bashrc 3 4 # User specific aliases and functions 5 6 # Source global definitions 7 if [ -f /etc/bashrc ]; then 8 . /etc/bashrc 9 fi
2. Shell命令提示符及颜色是由PS1来配置:bash
1 [root@localhost ~]$ echo $PS1 2 \[\e[32;40m\][\u@\h \W]$\e[m
其中PS1经常使用的参数含义以下:字体
\d :#表明日期,格式为weekday month date,例如:"Mon Aug 1"
\H :#完整的主机名称
\h :#仅取主机的第一个名字
\t :#显示时间为24小时格式,如:HH:MM:SS
\T :#显示时间为12小时格式
\A :#显示时间为24小时格式:HH:MM
\u :#当前用户的帐号名称
\v :#BASH的版本信息
\w :#完整的工做目录名称
\W :#利用basename取得工做目录名称,因此只会列出最后一个目录
\# :#下达的第几个命令
\$ :#提示字符,若是是root时,提示符为:# ,普通用户则为:$spa
3. 颜色值设置命令行
F B
30 40 黑色
31 41 红色
32 42 绿色
33 43 黄色
34 44 蓝色
35 45 紫红色
36 46 青蓝色
37 47 白色 code
# PS1='[\[\e[32;40m\]\u@\h \w \t]\$'
1 [root@localhost ~]$ cat ~/.bashrc 2 # .bashrc 3 4 # User specific aliases and functions 5 6 alias rm='rm -i' 7 alias cp='cp -i' 8 alias mv='mv -i' 9 10 PS1="\[\e[32;40m\][\u@\h \W]\$\e[m " 11 12 # Source global definitions 13 if [ -f /etc/bashrc ]; then 14 . /etc/bashrc 15 fi
5.vim或者nano下修改blog
从新加载下~/.bashrc便可生效:ci
[root@localhost ~]$ source ~/.bashrc