如何寻找设置了PATH的配置文件?

当我们执行 echo $PATH的时候,想知道哪里设置了PATH变量。以下罗列了可能设置PATH的配置文件。

1. ~/.bashrc

这个配置文件在用户的家目录下,内容加载了/etc/bashrc配置文件的内容。例如:

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

2. ~/.bash_profile

这个配置文件也是在用户的家目录下,但一般修改~/.bashrc即可。


3. /etc/profile,/etc/bashrc

这两个文件最好不要改动,如果要添加内容,让所有的用户都使用到,则可以在/etc/profile.d/下建立一个custom.sh脚本文件。

注意:两者的区别在于:

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
我们看到,设置函数和alias是到/etc/bashrc里,系统环境和登陆后启动的程序,到/etc/profile。 这两个文件最好都不要改变,两个配置文件都提示,要到/etc/profile.d/下建立一个custom.sh文件。



综合以上表述,我们可以修改/添加登陆配置的地方有三个:

~/.bashrc 

~/.bash_profile 

/etc/profile.d/


转载于:https://my.oschina.net/jccpp/blog/127186

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值