Which shell script is the first startup script run when a login shell is started in Linux?

Which shell script is the first startup script run when a login shell is started in Linux?

Which shell script is the first startup script run when a login shell is started in Linux?

A.
~/.bashrc

B.
/etc/profile.d

C.
/etc/profile

D.
/etc/bashrc

Explanation:

The /etc/profile shell script is the first startup script run when a login shell is started. It runs only for
the login shell.
What is a Login shell?
A login shell is a shell that is started by login into the system. The login shells’ responsibility is to
start the non-login shell
and to make sure that environment variables are set so as to ensure that a user can get all the
default parameters needed at start-up.
Login shell will set the PATH environment variable, TERM, the UID and GID of the terminal
amongst other things. These are the requirements in order to work proficiently. Additionally, the
login-shell will set default variable such as USERNAME,
HISTSIZE, HOSTNAME, HOME, etc.
Answer option A is incorrect. The ~/.bashrc shell script is the first startup script run when a nonlogin shell is started.
A non-login shell is a shell started by a user or a program issuing the bash command.
Some non-login shells are as follows:
su
graphical terminals
executed scripts
any other bash instances
Answer options D and B are incorrect. The non-login shells first call ~/.bashrc. The ~/.bashrc calls
/etc/bashrc, and then /etc/bashrc
calls /etc/profile.d.



Leave a Reply 0

Your email address will not be published. Required fields are marked *