GSEC · Question #244
You work as an Administrator for McRoberts Inc. The company has a Linux-based network. You are logged in as a non-root user on your client computer. You want to delete all files from the /garbage…
The correct answer is D. su -c "RM -rf /garbage*". The 'su -c' command allows a non-root user to execute a specific command as the root user by prompting for the root password. This is the correct approach when you need to perform a privileged operation without permanently switching to the root account.
Question
You work as an Administrator for McRoberts Inc. The company has a Linux-based network. You are logged in as a non-root user on your client computer. You want to delete all files from the /garbage directory. You want that the command you will use should prompt for the root user password. Which of the following commands will you use to accomplish the task?
Options
- Arm -rf /garbage*
- Bdel /garbage/.
- Crm -rf /garbage* /SU
- Dsu -c "RM -rf /garbage*"
How the community answered
(24 responses)- A4% (1)
- B13% (3)
- C8% (2)
- D75% (18)
Why each option
The 'su -c' command allows a non-root user to execute a specific command as the root user by prompting for the root password. This is the correct approach when you need to perform a privileged operation without permanently switching to the root account.
'rm -rf /garbage*' runs entirely under the current non-root user's permissions and would fail with a permission denied error on a protected directory, and it does not prompt for a root password.
'del' is a Windows command-prompt command and does not exist in Linux, making this option completely invalid on a Linux-based network.
'/SU' is not a valid flag or option for the 'rm' command on Linux - this syntax would result in a parse error and does not trigger any password prompt or privilege escalation.
The 'su -c "command"' syntax executes the specified command string as the root user and, critically, prompts for the root user's password before proceeding - exactly the behavior requested. The '-c' flag passes the quoted command to the root user's shell, allowing a non-root user to perform privileged file deletion on /garbage without permanently switching user context.
Concept tested: su -c command for non-root privileged execution
Source: https://man7.org/linux/man-pages/man1/su.1.html
Topics
Community Discussion
No community discussion yet for this question.