nerdexam
LPI

010-160 · Question #19

The current directory contains the following file: -rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh Which of the following commands can delete this file? (Choose two correct answers.)

The correct answer is B. rm test.sh D. sudo rm test.sh. Deleting a root-owned file requires either write permission on the containing directory or elevated privileges via sudo. rm is the standard deletion command.

The Power of the Command Line

Question

The current directory contains the following file: -rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh Which of the following commands can delete this file? (Choose two correct answers.)

Options

  • Adefaultuser tux
  • Brm test.sh
  • Cmv test.sh /tmp/test.sh
  • Dsudo rm test.sh
  • Eshred test.sh

How the community answered

(28 responses)
  • A
    7% (2)
  • B
    86% (24)
  • C
    4% (1)
  • E
    4% (1)

Why each option

Deleting a root-owned file requires either write permission on the containing directory or elevated privileges via sudo. rm is the standard deletion command.

Adefaultuser tux

'defaultuser tux' is not a valid Linux command and has no file deletion functionality.

Brm test.shCorrect

rm test.sh works when the current user has write permission on the directory containing the file, because file deletion is governed by directory permissions, not file permissions. If the user is root or owns the directory with write access, this command succeeds.

Cmv test.sh /tmp/test.sh

mv moves the file to /tmp rather than deleting it; the file still exists at the new path and is not removed from the filesystem.

Dsudo rm test.shCorrect

sudo rm test.sh escalates privileges to root, bypassing permission restrictions on the root-owned file and allowing deletion regardless of the current user's permissions.

Eshred test.sh

shred without the -u flag only overwrites the file's data for secure deletion but does not remove the directory entry; the file remains on disk.

Concept tested: File deletion with rm and sudo privilege escalation

Source: https://www.gnu.org/software/coreutils/manual/html_node/rm-invocation.html

Topics

#rm command#sudo#file deletion

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice