On a Debian server you must set a prompt and a couple of aliases for every user, and they must apply to the terminal windows users open inside their desktop session, not only to console logins. Which system-wide file is the right place for those settings?
LPIC-1 Exam 102-500, objective 105. Shells and shell scripting 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
Not correct /etc/profile
Wrong for this case. /etc/profile is read only by login shells. A terminal window opened inside an already established session starts an interactive non-login shell, which never reads it.
Correct /etc/bash.bashrc
Correct. On Debian-family systems bash is built to read /etc/bash.bashrc for interactive shells that are not login shells, which is exactly what a terminal emulator starts.
Not correct /etc/environment
Wrong. /etc/environment is read by PAM, not by bash, and it is not a script: it accepts only plain NAME=value lines. Aliases and prompt logic cannot live there.
Not correct /etc/skel/.bashrc
Wrong. The skeleton copy is only used when a new account's home directory is created. Accounts that already exist keep the copy they were given, so changes here reach nobody who is already on the system.
Why
Bash splits its startup files along the login/non-login axis: login shells read /etc/profile and one per-user profile, interactive non-login shells read the system bashrc and ~/.bashrc. The system bashrc is a compile-time path, so it is /etc/bash.bashrc on Debian and Ubuntu and /etc/bashrc on Red Hat family systems, where it is pulled in by the default ~/.bashrc rather than by bash itself. Aliases and prompts belong on the bashrc side because they are per-shell settings that are not inherited through the environment.
Where this comes from
- Cited
- manual page bash(1)
Practise this
Reading one question is not practice. The trainer will draw a short set from objective 105 and space the ones you get wrong.
More questions on this objective
- A user logs in at a text console, and bash starts as an interactive login shell. Which file in that user's home directory is read by bash itself as part of login startup? machine-checked
- You are already logged in to a graphical desktop and open a new terminal window, so bash starts as an interactive shell that is not a login shell. Which per-user file does bash read in that case? machine-checked
- An executable script contains only the line `export EDITOR=vim`. After running it as `./setenv.sh`, `echo $EDITOR` in the calling shell prints nothing. What explains this? machine-checked
- In bash, what is the effect of `export MYVAR`? machine-checked
- At a bash prompt you run `alias ll='ls -l'` and it works for the rest of that session, but a terminal window opened afterwards does not recognise `ll`. Which statement explains this and gives the standard remedy? machine-checked
- A command finishes and the shell reports an exit status of 0. What does that mean, and which parameter reports it? machine-checked