CompTIA Linux+ (XK0-005) — Question 228
Ann, a security administrator, is performing home directory audits on a Linux server. Ann issues the su Joe command and then issues the ls command. The output displays files that reside in Ann's home directory instead of Joe's. Which of the following represents the command Ann should have issued in order to list Joe's files?
Answer options
- A. su - Joe
- B. sudo Joe
- C. visudo Joe
- D. pkexec Joe
Correct answer: A
Explanation
The correct command is 'su - Joe' because the dash indicates a login shell, which switches to Joe's environment and home directory. The other options do not provide the necessary environment switch: 'sudo Joe' runs Joe's command without changing the directory, 'visudo Joe' is used for editing the sudoers file, and 'pkexec Joe' is for executing commands with elevated privileges but does not change the user context.