220-1102 Question 248
Single answersuA Linux support technician is logged in as a standard user and needs to restart a service and edit a root-owned configuration file during a remote troubleshooting session. The company wants the technician to use the root account only when necessary and avoid staying logged in as root longer than needed. Which command is the BEST choice to switch to the root account for the current shell so the technician can complete several administrative commands and then exit back to the standard user account?
- A
su -
- B
sudo
- C
chmod 777 /etc/service.conf
- D
passwd root
Show answer and explanation
Correct answer: A
Explanation
This question tests practical Linux privilege escalation knowledge relevant to A+ Core 2. The 'su' command is used to substitute to another user account, commonly root. Using 'su -' is important because the hyphen starts a full login shell and loads the target user's environment, which helps avoid problems caused by retaining the standard user's PATH and shell settings. This is especially useful when a technician needs to run several root-level commands in sequence and then return to the original account with 'exit'. While 'sudo' is a best practice for running individual privileged commands and is widely recommended in modern Linux administration, the scenario specifically asks to switch to the root account for the current shell. This aligns with standard Linux documentation and common admin guidance on the difference between 'su', 'su -', and 'sudo'.
- A. Correct.
Correct. The command 'su -' switches the current shell to the root account and loads root's login environment, including its PATH and profile settings. This is appropriate when a technician needs to perform multiple administrative tasks in one session and then return to the original user by typing 'exit'. In Linux administration, 'su -' is preferred over plain 'su' when a full root login shell is needed.
- B. Incorrect.
Incorrect. 'sudo' is commonly used to run a single command with elevated privileges, and it is often the preferred security practice in many environments. However, the question specifically asks for the best choice to switch to the root account for the current shell so multiple commands can be run before exiting back to the standard user. By itself, 'sudo' does not switch the shell to root unless used with additional options such as launching a shell.
- C. Incorrect.
Incorrect. Changing permissions on a system configuration file to 777 would create a serious security problem by making the file readable and writable by all users. This does not switch to the root account and is not an appropriate method for performing administrative tasks.
- D. Incorrect.
Incorrect. 'passwd root' changes the root account password. It does not switch the current session to root and would be unrelated to the stated task. A candidate might choose this if they confuse authentication with account switching, but it does not solve the immediate administrative need.