Exam SK0-005 All QuestionsBrowse all questions from this exam
Question 187

A user logs in to a Linux server and attempts to run the following command:

sudo emacs /root/file

However, the user gets the following message:

User userid is not allowed to execute ‘emacs’ on this server.

Which of the following would BEST allow the user to find out which commands can be used?

    Correct Answer: B

    The correct command to list the sudo privileges for a user is 'sudo -l -U userid'. This command will provide a detailed list of all commands that the specified user is allowed to run using sudo on that system. The 'sudo -l' option stands for 'list', and '-U userid' specifies the user whose sudo privileges you want to inspect. It is a direct and appropriate way to determine which commands a user can use with sudo.

Discussion
surfugandaOption: A

A. visudo | grep userid Explanation: The visudo command is used to edit the sudoers file, which contains the rules for granting sudo privileges. By piping the output of visudo to grep userid, the user can search for any rules or configurations related to the specified user (userid). This command would allow the user to identify any specific sudo rules that might be restricting their ability to execute the emacs command as sudo. Reviewing the sudoers file in this manner provides a direct insight into the permissions and commands available to the user.

gingasaurusrexOption: B

The BEST option to allow the user to find out which commands can be used is option B: sudo -1 -U userid. This command allows the user to run a shell with the privileges of the specified user (-U userid) while preserving their own environment (-i). This means that the user will be able to see the commands they are authorized to run, and also allows them to test running those commands as the authorized user. Option A (visudo | grep userid) runs the visudo command with the intention of displaying the sudoers file contents that have configuration options for the specified user, but it will not show the available commands. Option C (cat /etc/passwd) shows the contents of the /etc/passwd file, which contains user account information including usernames, user IDs, home directories, and login shells. However, it will not show the commands that the user can run. Option D (userlist | grep userid) does not seem to be a valid command and would not help the user find the available commands they can run.

tame_rabbitOption: B

The correct command to list sudo privileges for a user is sudo -l or sudo -ll (for a more detailed list). Therefore, the best answer is: B. sudo -1 -U userid Despite the typo (1 instead of l), this option is closest to the correct command. The proper command would be: sudo -l -U userid This command will list all commands that the specified user (userid) is allowed to run using sudo on that system. It's the most direct and appropriate way to find out which commands a user can use with sudo.

tame_rabbitOption: B

it should be sudo -l -U userid (not 1) The sudo -l -U userid command is used to list the sudo privileges of a specific user (userid). Here's what each part of the command does: sudo: This command allows users to execute commands with the security privileges of another user, typically the superuser (root). It is often used to perform administrative tasks while logged in as a regular user. -l: The -l option stands for "list" and is used to list the allowed (or forbidden) commands that the user can execute with sudo privileges. -U userid: The -U option specifies the user whose privileges you want to inspect. In this case, userid is the placeholder for the username whose sudo privileges you want to check.