Difficulty: Easy
Correct Answer: /etc/profile
Explanation:
Introduction / Context:
Understanding Bash startup files is essential for Linux system administration. Different files are sourced depending on whether a shell is a login or non-login shell and whether the configuration is system-wide or per-user. This question targets the system-wide file that establishes default environment settings for all users at login.
Given Data / Assumptions:
Concept / Approach:
Bash distinguishes between system-wide and per-user initialization files. For login shells, Bash reads /etc/profile first (system-wide) and then looks for per-user files like ~/.bash_profile, ~/.bash_login, or ~/.profile. For interactive non-login shells, many distributions use /etc/bash.bashrc or /etc/bashrc plus the user's ~/.bashrc. Only one of the options given is the canonical system-wide login file.
Step-by-Step Solution:
Verification / Alternative check:
On a typical Linux system, run man bash and review the INVOCATION section, which explains that login shells read /etc/profile. Distribution documentation (Debian/Ubuntu, RHEL/Fedora) confirms this behavior.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing system-wide files with per-user dotfiles (for example, ~/.bashrc). Also, mixing up login and non-login shell behavior leads to incorrect assumptions about which file executes. Always consider shell type and distribution conventions.
Final Answer:
/etc/profile
Discussion & Comments