Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. It has following rc and profile files, the files begain with ~
is the user level files, the content inside only effective for the user.
When you run bash as interactive login shell or as a non-interactive shell with --login
option, it first reads and executes commands from the file /etc/profile
, after this it looks for ~/.bash_profile
, ~/.bash_login
and ~/.profile
, this is the order. An interactive login shell can be invoked by a ssh login.
But as my test on Ubuntu/CentOS, it will also looks for ~/.bashrc
if these three files do not exist, in most Linux distributions there are no .bash_profile
, .bash_login
and .profile
. If .bash_profile
exist, the .bashrc
file will be not read and executed. So my suggestion is do not create .bash_profile
in your $HOME directory.
When you run bash as interactive shell that is not a login shell, it reads and executes command from /etc/bash.bashrc
and ~/.bashrc
.
In most Linux distribution, /etc/profile
will invoke /etc/bash.bashrc
and /etc/profile.d/*.sh
or /etc/bash.bashrc
invokes /etc/profile.d/*.sh
, so mostly you will not feel different in interactive login shell and interactive no-login shell.
If you have questions about Bash, you can simply run man bash
and find the answers.
There is a package bash-completion, it used to auto complete your program subcommands and arguments. If you want to auto complete your program you can simply put a complete file under /etc/bash_completeion.d
. It will be invoked by /etc/profile.d/bash_completion.sh
indirectly.
If your program is installed in non-standard system directory like /opt/your_prog
, your program commands and libraries can’t be used without the prefix, so you need to add them to PATH
and LD_LIBRARY_PATH
. You can simply create a file /etc/profile.d/your_prog.sh
, the content is very like following:
#!/bin/bash
export PATH=$PATH:/opt/your_prog/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/your_prog/lib
export PYTHONPATH=/opt/your_prog/python2.7/site-packages
The rc
in Linux stands for run commands
.
http://superuser.com/questions/173165/what-does-the-rc-in-bashrc-etc-mean