XK0-004 · Question #75
A junior Linux administrator is setting up system-wide configuration settings. The goal is to ensure the PATH environment variable includes the following locations for all users who log into a Linux…
The correct answer is B. Update the /etc/profile file using a text editor, navigate to the PATH element, add the missing locations. When a user logs in to the system and the user’s login shell is a BASH shell, the commands in the /etc/profile file are executed. The /etc/profile.d/ directory serves as a storage location for scripts administrators may use to set additional system-wide variables. It is…
Question
A junior Linux administrator is setting up system-wide configuration settings. The goal is to ensure the PATH environment variable includes the following locations for all users who log into a Linux system. The administrator issues the following commands at the terminal:
Respectively, the output of these commands is as follows:
Given this output, which of the following would be the BEST action for the administrator to perform to address this issue?
Options
- AUpdate the /etc/profile.d file using a text editor, navigate to the PATH element add the missing locations,
- BUpdate the /etc/profile file using a text editor, navigate to the PATH element, add the missing locations
- CUpdate the /etc/profile.d file using a text editor, navigate to the PATH element, add the missing
- DUpdate the /etc/profile file using a text editor navigate to the PATH element, add the missing locations,
How the community answered
(57 responses)- A14% (8)
- B75% (43)
- C4% (2)
- D7% (4)
Explanation
When a user logs in to the system and the user’s login shell is a BASH shell, the commands in the /etc/profile file are executed. The /etc/profile.d/ directory serves as a storage location for scripts administrators may use to set additional system-wide variables. It is recommended you set the environment variables via scripts contained in /etc/profile.d/ rather than editing the /etc/profile file directly. for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" >/dev/null This code means “if there is a file that ends in .sh in the /etc/profile directory and it is readable, source (run) the contents of this file in the current shell.”
Topics
Community Discussion
No community discussion yet for this question.