Introduction
The start-up Bash commands, variables, aliases and cutomizations are put in ~/.bashrc, ~/.bash_profile, ~/.profile files. So whenever you open a new terminal, one of these files is called first, but which one?
Prerequistis
It’s good to know about Shell terminal and its commands.
.bashrc vs .bash_profile vs .profile
The difference between them is that:
.bashrcis run by non-login shells. In other words, if you start a terminal without any authentication, the.bashrcis run. One example is, when you are already logged in your Ubuntu Desktop and you open a new terminal. Another example is, with VS code, you are connected to a remote server, any terminal you open there runs.bashrcfirst..bash_profileis called when we enter a login shell (Bash). For example, SSH to a remote server with username and password..profile, this is the originalshprofile file. If.bash_profilenot found,.profilewill be loaded.
So my advice is for a local Linux, add commands to ~/.bashrc, for remote servers do the same, but also add the below line to ~/.bash_profile:
source ~/.bashrc
This guide was for Bash terminals, but for other Shell terminals you probably need to set slightly different files, for example, zsh uses .zprofile and .zshrc.
