bash读取启动文件问题-bash_profile

本文详细解释了Linux环境中.bash_profile与.bashrc的区别及用途。.bash_profile用于登录控制台时配置bash行为,而.bashrc则针对交互式终端进行设置。文中还介绍了如何创建这些文件,并指出了.bash_profile的兼容性和默认文件.profile的相关信息。

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

估计阅读完老外的这段解释,应该都明白了吧……

if you open Nautilus, the file browser, go to your HOME directory and press CTRL+H you will see then all the hidden files (Since hidden files start with the DOT . character). Since you are talking about the .bash_profile am guessing you want to start via console instead of an interactive desktop.

The difference between .bash_profile and .bashrc is the following:

.bashrc is the one that you edit when you want to change the way xterm or gnome-terminal open the console. how the bash works in this interactive places.

.bash_profile is the one you edit when you want to change how bash works when you login via console (Like the same way you login to a ubuntu server or when you press CTRL+ALT+F1 to start a terminal)

Since .bash_profile does not come by default there you can just create it. But as i understand the default .bash_profile now is called .profile which can be seen in the HOME directory. Both, .bashrc and .profile can be edited to change how bash works in both, interactive and console modes.

NOTE: If by some way you create .bash_profile, then ubuntu wont read .profile but instead go directly to .bash_profile since both of them are the same but .bash_profile has more compatibility because of old ways. So basically you do not need .bash_profile if you have .profile. so just remember:

.bashrc - Interactive Console/Terminal (Gnome, KDE, Xfce...)

.profile - TTY Console/Terminal


thx you are right i continude to read a little bit and found out that bash has a certain sequence it boots into first it tries to find .bash_profile if not found it tries to find .bash_login and if not found it tries to find .profile, and another thing i read is if you do create .bash_profile you can insert "source .profile"command at the end of .bash_profile and it should execute .profile afterwards, but it's all from reading a book, so not sure how much it will work –  david25 Dec 10 '10 at 22:57



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值