bashrc not work

王朝学院·作者佚名  2016-05-26  
宽屏版  字体: |||超大  

bashrc not work今天想 在 .bashrc 中配置一段自动启动 ssh-agent 的脚本,结果总是没有自动运行;才发现我的 bashrc 脚本没有自动 加载

后来才发现是这次装的深度系统(deepin)默认没有 ~.PRofile脚本, 去看看之前的Ubuntu系统里面都默认是有这个脚本的,而 ~.bashrc 脚本则是通过 .profile 来加载的

如果新建一个用户, 在其 $HOME 目录下会自动创建 .profile 脚本吗?

1. linux系统加载bash配置脚本的顺序.bashrc 文件本身在 *nix 系统下就不会自动加载,一般都是通过 .profile 间接加载的

一般,系统会按下面的顺序加载

/etc/profile~/.bash_profile~/.bash_login~/.profile

如果你的.bashrc 没有自动加载,就新建 ~/.profile

# ~/.profile: executed by Bourne-compatible login shells.if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fi fimesg n

当然如果, 已经有了 .bash_profile or .bash_login, 那么这个 .profile 文件也不会被加载。 总之,是把 此段代码写到 已经存在的 最先被加载到的那个配置中。

refer to :

http://askubuntu.com/questions/260682/bashrc-not-autosourced-in-12-04-ltshttp://apple.stackexchange.com/questions/12993/why-doesnt-bashrc-run-automatically

2. Difference Between .bashrc & .bash_profile.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

当你直接在机器login界面登陆、使用ssh登陆或者su切换用户登陆时,.bash_profile 会被调用来初始化shell环境Note:.bash_profile文件默认调用.bashrc文件

当你不登陆系统而使用ssh直接在远端执行命令,.bashrc 会被调用你已经登陆系统后,每打开一个新的Terminal时,.bashrc 都会被再次调用。

若要配置环境变量之类,最保险是写在 .bashrc 文件中。因为不管是登陆还是不登陆,该文件总会被调用

refer to :

http://upgirl.blog.51cto.com/3744514/1140176

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有