/etc/profile 的修改技巧
来源:互联网 发布:vr技术与人工智能 编辑:程序博客网 时间:2024/05/18 02:52
在 Arch Linux 的配置过程中可能要修改 /etc/profile,修改多了以后,原来的 profile 就面目全非了。
仔细看看你的 Linux 系统,如果有 /etc/profile.d 目录的话,就可以把要修改的内容分文件存放。
使 ls 能带颜色显示目录
建立文件 /etc/profile.d/dircolor.sh,内容如下:
# Setup for /bin/ls to support color, the alias is in /etc/bashrc.
if [ -f "/etc/dircolors" ] ; then
eval $(dircolors -b /etc/dircolors)
if [ -f "$HOME/.dircolors" ] ; then
eval $(dircolors -b $HOME/.dircolors)
fi
fi
alias ls='ls --color=auto'
修改 dircolor.sh 为可执行模式
# cd /etc/profile.d
# chmod +x dircolor.sh
修改完毕后,重新登录,使修改内容生效。
在 path 中增加新的目录
建立文件 /etc/profile.d/addsbin.sh,内容如下:
# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [ "$DIR" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
仔细看看你的 Linux 系统,如果有 /etc/profile.d 目录的话,就可以把要修改的内容分文件存放。
使 ls 能带颜色显示目录
建立文件 /etc/profile.d/dircolor.sh,内容如下:
# Setup for /bin/ls to support color, the alias is in /etc/bashrc.
if [ -f "/etc/dircolors" ] ; then
fi
alias ls='ls --color=auto'
修改 dircolor.sh 为可执行模式
# cd /etc/profile.d
# chmod +x dircolor.sh
修改完毕后,重新登录,使修改内容生效。
在 path 中增加新的目录
建立文件 /etc/profile.d/addsbin.sh,内容如下:
# Functions to help us manage paths.
# path variable to be modified (default: PATH)
pathremove () {