Flevo CFD

Bash Sartup Files

Shell is a tool through which we can execute a series of commands in a new operating system. There are several shells, such as sh, bash, zsh, and fish shell.

In this text, we want to see what files bash loads when we open the terminal. With this knowledge, we can place our custom variables or scripts in appropriate files so that they are identified or executed whenever bash starts.

We can have two modes of access to the shell, or specifically, to bash.

The first is when we enter our username and password, such as logging in with a Display Manager or SSH, which is called a Login Shell.

The second is when we open the terminal with a GUI, which is referred to as a Non-Login Shell.

Whenever bash is launched, it loads a series of files, and this varies depending on the type of access.

Login Shell

In this case, the first file loaded is /etc/profile/.

Then, in order, one of the following files is loaded if they exist:

  • /home/USERNAME/.bash_profile
  • /home/USERNAME/.bash_login
  • /home/USERNAME/.profile
  • /home/USERNAME/.bashrc

Non-Login Shell

In this case, first, the file /etc/bash.bashrc is loaded (although on some systems, the file /etc/bashrc might be loaded).

Afterwards, the file /home/USERNAME/.bashrc is loaded.