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