Linux大安全

CentOS系统环境配置加载顺序

2020-11-04  本文已影响0人  夏胖运维

1. 修改文件

我们修改相关的环境变量配置文件

echo "echo '----------------------/etc/profile" >>/etc/profile
echo "echo '----------------------/etc/profile.d/echo.sh" >>/etc/profile.d/echo.sh
echo "echo '----------------------.bash_profile" >>.bash_profile
echo "echo '----------------------.bashrc" >>.bashrc
echo "echo '----------------------/etc/bashrc" >>/etc/bashrc

2. 开始测试

2.1. 重新登录

我们退出SSH登录,重新连接,查看输出内容

Welcome to the Xuan Wei Education iso image
----------------------/etc/profile
----------------------/etc/profile.d/echo.sh
----------------------.bash_profile
----------------------.bashrc
----------------------/etc/bashrc

2.2. 远程执行命令

我们使用ssh命令远程执行命令,查看输出内容

# ssh 127.0.0.1 'echo $PATH'   
root@127.0.0.1's password: 
----------------------.bashrc
----------------------/etc/bashrc
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

3. 总结

3.1. 登陆式shell

执行/etc/profile
执行/etc/profile.d/.sh
执行~/.bash_porfile
执行~/.bashrc
执行/etc/bashrc

3.2. 非登陆式shell:远程执行命令

执行~/.bashrc
执行/etc/bashrc

如果编译安装的软件需要远程也要能执行可以修改/etc/bashrc,或者将命令拷贝到/usr/local/sbin /usr/local/bin /sbin /bin /usr/sbin /usr/bin这个几个目录中

上一篇 下一篇

猜你喜欢

热点阅读