TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Bash Configurations Demystified

106 pointsby dghubblealmost 12 years ago

8 comments

gue5talmost 12 years ago
See &lt;<a href="http://blog.flowblok.id.au/2013-02/shell-startup-scripts.html&gt;" rel="nofollow">http:&#x2F;&#x2F;blog.flowblok.id.au&#x2F;2013-02&#x2F;shell-startup-scripts.htm...</a>, the most comprehensive overview I&#x27;ve encountered to date.
评论 #6077970 未加载
deathanatosalmost 12 years ago
What&#x27;s the reason for all the files, and why do I care whether my shell is a login or non-login? To me, no matter where I get my shell from (whether VT, SSH, gnome-terminal), I want all my aliases, settings and nice terminal colors to be there.
评论 #6078073 未加载
评论 #6078133 未加载
评论 #6078022 未加载
eslaughtalmost 12 years ago
&gt; As the name implies, .bashrc is for bash configs. Environment variables or other configuration settings should typically be written to .profile on Ubuntu and .bash_profile on OS X.<p>I don&#x27;t understand this. If I set PATH in .profile or .bash_profile, then on Ubuntu I won&#x27;t see that setting when I log in via a non-login shell. This is common for non-interactive SSH sessions.<p>So consider the following example:<p><pre><code> * I install MPI to &#x2F;usr&#x2F;local&#x2F;openmpi-X.Y.Z * I add &#x2F;usr&#x2F;local&#x2F;openmpi-X.Y.Z&#x2F;bin to PATH, inside my .profile </code></pre> Now MPI is broken, because MPI executes out of a non-login shell when running on remote nodes via SSH.<p>I think I&#x27;ll keep my PATH settings in .bashrc, thank you very much.
评论 #6079372 未加载
johnbellonealmost 12 years ago
Excellent article.<p>I recently had the task of straightening out the default install of dotfiles we had at my job. Since we&#x27;re behind a corporate firewall and require various HTTP proxies to hit the outside world I devised pretty much the same setup as explained in the article.<p>All of the environment exports are placed in .profile as, at the very least, I expect this to be sourced on a login shell. If there is a non-login shell, for the most part, most people tend to source it pretty early on in the process. The .bash_profile is kept around for diagnostic information for interactive shells such as the Ruby, Go, Node and Java versions of the machine you are logging into.<p>Because everyone tends to have their own dotfiles I hijacked the .bash_login to keep machine specific information which can be optionally sourced. This leads me to tell people to basically keep .profile and .bash_login out of their revision control and to source both of them relatively early on in the login process.<p>All .profile is for environment variables that are machine&#x2F;network specific. If you have any overrides, e.g. aliases, all that goes into your .bash_login.<p>My .bash_profile: <a href="https://github.com/johnbellone/dotfiles/blob/master/home/.bash_profile" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;johnbellone&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;home&#x2F;.ba...</a><p>My .bashrc <a href="https://github.com/johnbellone/dotfiles/blob/master/home/.bashrc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;johnbellone&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;home&#x2F;.ba...</a>
m_ramalmost 12 years ago
<i>Programs like RVM add a .bash_profile file so you should be sure to append [[ -s ${HOME}&#x2F;.profile ]] &amp;&amp; source ${HOME}&#x2F;.profile to the added .bash_profile file.</i><p>You can also rename .profile to .bash_profile on Ubuntu and Debian. All other distros that I&#x27;ve encountered set up .bash_profile by default.
评论 #6078343 未加载
评论 #6078569 未加载
D9ualmost 12 years ago
<p><pre><code> &gt; the scary console login after you&#x27;ve messed up your GUI settings </code></pre> That&#x27;s where I stopped reading...<p>BASH isn&#x27;t <i>that</i> mysterious.<p><pre><code> man bash</code></pre>
评论 #6078578 未加载
评论 #6079786 未加载
dbboltonalmost 12 years ago
Is there a specific reason why you would want to source .profile from within .bash_profile instead of just making one a symlink to the other?
评论 #6078318 未加载
smewpyalmost 12 years ago
This is really helpful, thanks.