The start-up Bash commands, variables, aliases and cutomizations are put in
~/.profile files. So whenever you open a new terminal, one of these files is called first, but which one?
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
.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 original
shprofile file. If
.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
This guide was for Bash terminals, but for other Shell terminals you probably need to set slightly different files, for example,
- Essential bash customizations: prompt, ls, aliases, and history date
- Script to copy a directory path in memory in Bash terminal
- What is the difference between .bashrc, .bash_profile, and .profile?
- A C++ MPI code for 2D arbitrary-thickness halo exchange with sparse blocks
- Create clone of a C++ class in polymorphic way