linux bash & profile &bash_profile 小结

本文详细介绍了 Linux 下 Bash 和 Profile 文件的区别及作用,包括它们的读取顺序和应用场景,特别关注了登录方式的不同对文件读取顺序的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

login 方式:: su - oracle
依次 /etc/bash.bashrc———— /home/$user/.bashrc ———— /ect/profile ———— /home/$user/.bash_profile(找不到~/.bash_profile, 则寻找~/.bash_login,若前两者不存在,读取~/.profile) -- 可见.profile的作用其实很次要的
正常

bash.bashrc
oracle .bashrc
etc profie
oracle .bash_profile


/home/oracle # mv .bashrc .bashrc2
bash.bashrc
etc profie!!
oracle .bash_profile


linux:/home/oracle # mv .bash_profile .bash_profile2
linux:/home/oracle # ..
linux:/home # su - oracle
bash.bashrc
etc profie!!
oracle . proflie


非login方式:————————图形界面? 等等。。 依次 /etc/bash.bashrc———— /home/$user/.bashrc
linux:/home/oracle # su oracle
bash.bashrc
oracle .bashrc

 

1. 图形模式登录时,顺序读取:/etc/profile和~/.profile ----(3)~/.profile ---- 图形模式登录时,此文件将被读取,即使存在~/.bash_profile和~/.bash_login

2. 图形模式登录后,打开终端时,顺序读取:/etc/bash.bashrc和~/.bashrc

3. 文本模式登录时,顺序读取:/etc/bash.bashrc,/etc/profile和~/.bash_profile ---- 貌似这里第二步少了个~/.bashrc


(5)和(6) 有些矛盾。。

后面的内容就太啰嗦了! 而且有些不对。不应该看。


Xshell:\> open 218
Connecting to 10.67.164.218:22...
Connection established.
Escape character is '^@]'.

Last login: Fri Apr 25 17:31:32 2014 from 10.74.169.50

etc bash.bashrc
.bash rc
etc profie!!
root . bash_profile (root 的根目录下没有.bash_profile 则新建一个)

可见这个顺序和su - root的顺序一样的

 

 

 


/etc/bash.bashrc 有的系统没有此文件,而对应的是 bashrc
/etc/profile


/export/home/$user ??
/home/$user/

.bashrc
.proflie
.bash_history ?

.inputrc ?

http://www.cnblogs.com/yangwindsor/articles/3380322.html
bashrc用于交互式non-loginshell,而profile用于交互式login shell

 

 

关于 bash & profile

其实明白了一点就很容易理解、记忆了,否则下次可能还是忘记::

bash  是shell 脚本, 执行shell 是不一定要登录的, 所以,他隐隐约约表示non-login

profile 是概括文件, 包含一些环境变量等等预处理变量、脚本、函数,  所以每次login 的时候都要执行一下

 

 

posted on 2014-04-25 18:41 CanntBelieve 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/FlyAway2013/p/3689397.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值