nerdexam
GIAC

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.

Linux and Cryptography

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)
  • A
    4% (1)
  • B
    13% (3)
  • C
    8% (2)
  • D
    75% (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.

Arm -rf /garbage*

'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.

Bdel /garbage/*.*

'del' is a Windows command-prompt command and does not exist in Linux, making this option completely invalid on a Linux-based network.

Crm -rf /garbage* /SU

'/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.

Dsu -c "RM -rf /garbage*"Correct

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

#su command#privilege escalation#Linux commands#root access

Community Discussion

No community discussion yet for this question.

Full GSEC Practice