nerdexam
LPI

102-500 · Question #84

Which of the following files is not read directly by a Bash login shell?

The correct answer is A. ~/.bashrc. ~/.bashrc is skipped by Bash login shells - it is sourced only by interactive non-login shells (e.g., a new terminal tab that inherits an existing session). The distractor choices are all legitimately read by a login shell: /etc/profile (E) is read first as the system-wide…

Shells and Shell Scripting

Question

Which of the following files is not read directly by a Bash login shell?

Options

  • A~/.bashrc
  • B~/.bash_profile
  • C~/.bash_login
  • D~/.profile
  • E/etc/profile

How the community answered

(68 responses)
  • A
    78% (53)
  • B
    1% (1)
  • C
    4% (3)
  • D
    13% (9)
  • E
    3% (2)

Explanation

~/.bashrc is skipped by Bash login shells - it is sourced only by interactive non-login shells (e.g., a new terminal tab that inherits an existing session). The distractor choices are all legitimately read by a login shell: /etc/profile (E) is read first as the system-wide config, then Bash looks for and reads the first of ~/.bash_profile (B), ~/.bash_login (C), or ~/.profile (D) that it finds - so all four distractors are genuine login-shell startup files. Note that many distributions work around this by having ~/.bash_profile explicitly source ~/.bashrc, which is why it feels like login shells read it - but that's indirect, not direct.

Memory tip: Think of the "rc" suffix as "run commands for interactive shells" - ~/.bashrc is the interactive shell's file, while ~/.bash_profile owns the login shell. Login = profile; interactive = rc.

Topics

#login shells#shell configuration#bash startup#.bashrc vs .bash_profile

Community Discussion

No community discussion yet for this question.

Full 102-500 Practice