nerdexam
LPI

102-500 · Question #16

Which of the following configuration files should be modified to globally set shell variables for all users?

The correct answer is A. /etc/profile. /etc/profile is the correct choice because it is a system-wide initialization file that is sourced for all users during login shell startup, making it the standard location for globally setting environment variables and shell variables across any POSIX-compatible shell. Why the…

Shells and Shell Scripting

Question

Which of the following configuration files should be modified to globally set shell variables for all users?

Options

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

How the community answered

(21 responses)
  • A
    86% (18)
  • B
    5% (1)
  • D
    5% (1)
  • E
    5% (1)

Explanation

/etc/profile is the correct choice because it is a system-wide initialization file that is sourced for all users during login shell startup, making it the standard location for globally setting environment variables and shell variables across any POSIX-compatible shell.

Why the distractors are wrong:

  • B. /etc/bashrc - This file is sourced for interactive non-login shells (on some distros), but it's Bash-specific and not universally present; it's better suited for aliases and functions, not global variable declarations across all users.
  • C. ~/.bash_profile - The ~/ prefix means this is in a specific user's home directory, so it only affects that one user, not all users globally.
  • D. /etc/.bashrc - This path doesn't conventionally exist; the system-wide Bash configuration lives at /etc/bashrc (no dot prefix in the /etc/ directory).
  • E. /etc/shellenv - This is not a standard Linux configuration file and doesn't exist on typical systems.

Memory tip: Think of /etc/profile as the "everyone profile" - the /etc/ directory holds system-wide configs, and profile is the login script, so anything placed there runs for every user at every login.

Topics

#shell configuration#login shells#environment variables#system-wide settings

Community Discussion

No community discussion yet for this question.

Full 102-500 Practice