Linuxlab

~/.bashrc in Linux: shell configuration

Updated July 3, 2026

~/.bashrc is a script that bash runs when it starts an interactive non-login shell.

Common cases

echo 'export EDITOR=vim' >> ~/.bashrc   # add a setting
echo "alias ll='ls -lh'" >> ~/.bashrc    # add an alias
source ~/.bashrc                          # reload without restarting
cat ~/.bashrc                             # see what is inside

How it works: which file is read when

~/.bashrc is read for an interactive non-login shell (a new terminal window or tab). ~/.bash_profile (or ~/.profile) is read once at login. So aliases and the prompt go in .bashrc, while one-time things like starting an ssh agent go in .bash_profile. Changes take effect in new shells; to apply them in the current one, run source ~/.bashrc.

Used in

You need this in the lesson The shell environment. The theory is the chapter The shell environment and configuration.

See also

Aliases, Environment variables, The PATH variable.

Try it

Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.