ubuntu bash环境设置

第一步 系统级设置

读取/etc/profile文件,再根据/etc/profile文件的内容去读取其他附件的设置文件,例如/etc/profile.d/*.sh等


第二步 个人设置

根据不同的用户,到家目录去读取~/.bash_profile或~/.bash_login或~/.profile设置文件
其中:
这三个文件通常只要一个即可,不过存在顺序上的差异:bash启动时,会先去读取~/.bash_profile,找不到时就去读取~/.bash_login,再找不到时则读取~/.profile

根据不同的用户,到家目录去读取~/.bashrc文件


所以登陆bash后,最终读取的设置文件是~/.bashrc,通常可以将个人的一些常用的alias或者PATH等环境变量或者自定义变量都写到这个文件。


ps: 可能需要注意区分login shell 与 non-login shell

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to the terminal , or one started with the -i option.

Login Shell: 登录的时候,你输入帐号和密码进入了,出现了shell提示符,这个过程就是登录外壳;
Interactive Shell:接下来你得到了一个像root@host />这样的提示符,你输入什么,它就解释出什么,这就是交互式外壳;
Non Interactive Shell:你可能需要学习写一个bash script,用外部shell执行:bash script.sh,它(bash)从第一条命令执行到最后一条然后退出,不与你进行任何交互,它就是非交互式外壳

详见:

man 1 bash 之 INVOCATION

" a non-login shell, which does not read /etc/profile or ~/.bash_profile files, but rather reads the ~/.bashrc instead."


[url]http://simplyzhao.is-programmer.com/posts/6701.html[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值