Unix shell configuration
I’ve struggled to find an authoritative source to explain the different uses of the files: ~/.profile
, ~/.bash_profile
and ~/.bashrc
. Finally, I found a good explanation here. Quoting directly:
- When you login graphically to your system it will read
~/.profile
so you put there settings like LANG which are important for graphical applications. - When you open a terminal (except Gnome-terminal & Screen) you open a login shell which sources
~/.bash_profile
- When you execute commands in non login shell like ssh server command or scp file server:~ or sudo(without -i) or su (without -l) it will execute
~/.bashrc
~/.bashrc
is meant for non login invocations, you should not print there any output - it makes tools like scp fail.- If the shell of the user is set to
/bin/sh
, you will need to edit/etc/passwd
and set it to/bin/bash