A dash in front of the shell name means that the shell was invoked as a login shell (which means it is run as part of the user login to the system). Among its responsibilities, the login shell makes sure that the environment variables are set so that all the default parameters that are needed at start-up are available to the user. To do that, at start-up, the login shell consults two types of files:
- User and system-wide login shell initialization files (also known as the "profile" files);
- User and system-wide non-login shell initialization files (commonly referred to as "shell rc" files).
The system-wide profile and shell rc files reside in the
/etc directory, and are owned by the
root user. For example, in bash these would be the following files:
The user profile and shell rc files are owned by the specific user, and they reside in the user's home directories (and are hidden). For example, in bash these would be the following files:
Please note that the main difference between system-wide profile file and the user profile file is the ownership; system-wide profile files are owned by the
root user and can only be changed by the
root user, while the user profile files are owned by the specific user and can be changed by that user to setup their environment.
A login shell processes commands in the system-wide profile file and the first file it finds among user profile files. However, each time you start a new shell in the same login session (i.e. without logging out of the system) the shell has no need to run the "profile" files again. Instead each time a new shell is started, it executes the system-wide shell rc file and the user shell rc file (unless the new shell is started as a login shell by explicitly using the
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.