A user starts a new terminal window in a running graphical desktop session, which launches bash as an interactive shell that is NOT a login shell. Which file in the user's home directory does bash read in that case?

LPIC-1 Exam 101-500, objective 103. GNU and Unix commands medium

Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.

Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

The options

Correct ~/.bashrc

Correct. An interactive non-login bash reads ~/.bashrc. That is why aliases and prompt settings belong there rather than in the login files.

Not correct ~/.bash_profile

Wrong. ~/.bash_profile is read by interactive LOGIN shells (console login, ssh, su -). Many distributions have it source ~/.bashrc so the settings appear in both, but bash itself does not read it for a non-login shell.

Not correct ~/.bash_logout

Wrong. ~/.bash_logout is executed when a login shell exits, not when a shell starts.

Not correct ~/.profile

Wrong. ~/.profile is a login-shell file, read by bash only when ~/.bash_profile and ~/.bash_login are absent.

Why

Bash uses two different startup paths. Interactive login shells read /etc/profile and then the first of ~/.bash_profile, ~/.bash_login, ~/.profile. Interactive non-login shells read ~/.bashrc (and usually /etc/bash.bashrc or /etc/bashrc, depending on the distribution). A terminal opened inside an existing desktop session is the classic non-login case, so ~/.bashrc is the file that runs.

Where this comes from

Cited
LPI exam objective 103.1
What it says
Shell startup: which bash configuration files apply to login and non-login shells.

Practise this

Reading one question is not practice. The trainer will draw a short set from objective 103 and space the ones you get wrong.

Practise LPIC-1 Exam 101-500

More questions on this objective

All questions on GNU and Unix commands

Practise LPIC-1 Exam 101-500