What is the order in which the bash configuration files are read, assuming that all the files exist in their correct location and are readable?

Bash is invoked as an interactive login shell.

What is the order in which the bash configuration files are read, assuming that all the files exist in
their correct location and are readable?

Bash is invoked as an interactive login shell.

What is the order in which the bash configuration files are read, assuming that all the files exist in
their correct location and are readable?

A.
/etc/profile, ~/ .profile

B.
/etc/profile, ~/ .bash_profile

C.
/etc/profile, ~/ .bash_profile, ~/ .bash_login, ~/ .profile

D.
/etc/profile, ~/ .bash_profile, ~/ .profile, ~/ .bash_login

Explanation:
When Bash is invoked as an interactive login shell, or as a non-interactive shell with
the –login option, it first reads and executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and
reads and executes commands from the first one that exists and is readable. The –noprofile
option may be used when the shell is started to inhibit this behavior.
When a login shell exits, Bash reads and executes commands from the file ~/.bash_logout, if it
exists.



Leave a Reply 4

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


Djuro

Djuro

Correct is C.

Jef Adams

Jef Adams

from man page

When bash is invoked as an interactive login shell, or as a non-interactive shell with the –login
option, it first reads and executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that
order, and reads and executes commands from the first one that exists and is readable.
—> correct answer C