Linux下Bash Shell的常用配置文件
2017-04-23 13:09
218 查看
1 /etc/profile
用于设置系统级的环境变量和启动程序,在这个文件下配置会对所有用户生效。当用户登入(login)时,文件会被执行,并从/etc/profile.d目录的配置文件中查找shell设置。一般不建议在/etc/profile文件中添加环境变量,因为在这个文件中添加的设置会对所有用户起作用。
2 ~/.bash_profile
该文件是一个用户级的设置,这个文件同样也可以用于配置环境变量和启动程序,但只针对单个用户有效。和/etc/profile文件类似,bash_profile也会在用户登录(login)时生效,也可以用于设置环境变量。但与profile不同,bash_profile只会对当前用户生效。
e.g:
[luminqi@localhost ~]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi //'#'表示注释,上面这三行代码表示若存在~/.bashrc,则读入~/.bashrc的设置
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH=$PATH:/usr/local/bin //在这里可以添加变量
export PATH=$PATH:/opt/buildroot-2012.08/arm920t/usr/bin
export PATH=$PATH:/usr/local/git/bin
##由于/etc/profile和~/.bash_profile都是在取得login shell的时候才会读取的配置文件,所以如果你将自己的偏好设置写入~/.bashrc文件后,通常要重启后/etc/profile和~/.bash_profile才能生效,若不想重启,则需要读入环境配置文件的命令source。
e.g source ~/.bashrc 表示将~/.bashrc的配置读入~/.bash_profile中
3 ~/.bashrc和/etc/bashrc
这个两个文件用于配置函数或别名,/etc/bashrc是系统级的、~/.bashrc是用户级的,两者分别会对所有用户和当前用户生效。
e.g
[luminqi@localhost ~]$ cat ~/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi //同上理这里表示若存在/etc/bashrc,则读入/etc/bashrc的配置
# User specific aliases and functions
alias vt100='export TERM=vt100' //在这里可以为常用命令定义别名
alias linux='export TERM=linux'
90a7
alias la='ls -a'
alias gitci='git commit'
alias gitpush='git push origin master'
主线如下:
开机——>读取/etc/profile(系统配置)——>读取~/.bash_profile(用户配置)——>开始操作bash
对于~/.bash_profile这条分支:
~/.bash_profile<——~/.bashrc<——/etc/bashrc
通常来说,作为一般用户我们只要修改~/.bashrc和~/.bash_profile,之后source.
用于设置系统级的环境变量和启动程序,在这个文件下配置会对所有用户生效。当用户登入(login)时,文件会被执行,并从/etc/profile.d目录的配置文件中查找shell设置。一般不建议在/etc/profile文件中添加环境变量,因为在这个文件中添加的设置会对所有用户起作用。
2 ~/.bash_profile
该文件是一个用户级的设置,这个文件同样也可以用于配置环境变量和启动程序,但只针对单个用户有效。和/etc/profile文件类似,bash_profile也会在用户登录(login)时生效,也可以用于设置环境变量。但与profile不同,bash_profile只会对当前用户生效。
e.g:
[luminqi@localhost ~]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi //'#'表示注释,上面这三行代码表示若存在~/.bashrc,则读入~/.bashrc的设置
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH=$PATH:/usr/local/bin //在这里可以添加变量
export PATH=$PATH:/opt/buildroot-2012.08/arm920t/usr/bin
export PATH=$PATH:/usr/local/git/bin
##由于/etc/profile和~/.bash_profile都是在取得login shell的时候才会读取的配置文件,所以如果你将自己的偏好设置写入~/.bashrc文件后,通常要重启后/etc/profile和~/.bash_profile才能生效,若不想重启,则需要读入环境配置文件的命令source。
e.g source ~/.bashrc 表示将~/.bashrc的配置读入~/.bash_profile中
3 ~/.bashrc和/etc/bashrc
这个两个文件用于配置函数或别名,/etc/bashrc是系统级的、~/.bashrc是用户级的,两者分别会对所有用户和当前用户生效。
e.g
[luminqi@localhost ~]$ cat ~/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi //同上理这里表示若存在/etc/bashrc,则读入/etc/bashrc的配置
# User specific aliases and functions
alias vt100='export TERM=vt100' //在这里可以为常用命令定义别名
alias linux='export TERM=linux'
90a7
alias la='ls -a'
alias gitci='git commit'
alias gitpush='git push origin master'
主线如下:
开机——>读取/etc/profile(系统配置)——>读取~/.bash_profile(用户配置)——>开始操作bash
对于~/.bash_profile这条分支:
~/.bash_profile<——~/.bashrc<——/etc/bashrc
通常来说,作为一般用户我们只要修改~/.bashrc和~/.bash_profile,之后source.
相关文章推荐
- Linux下常用配置文件及常用命令介绍
- Linux下常用配置文件及常用命令介绍
- linux 常用配置文件
- [32期] Linux系统中常用的配置文件汇总解析(上)
- linux常用配置文件以及说明
- Linux下常用配置文件及常用命令介绍(来自PConline)
- linux几个常用的环境变量配置文件
- Linux常用网络配置文件介绍
- Linux常用网络 配置文件
- linux-file-structure和常用配置文件位置
- Linux下常用配置文件及常用命令的介绍
- (备忘)Linux中常用的配置文件
- 【APP】Linux网络基础总结(常用配置文件&常用命令)
- LINUX常用网络配置文件的介绍
- Linux下常用配置文件及常用命令介绍
- Linux高性能集群常用服务简介与配置(二)——NFS(网络文件系统)
- Linux下常用配置文件
- linux 常用配置文件
- 转载:Linux网络基础总结(常用配置文件&常用命令)
- Linux 常用配置文件的目录