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.
Question
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)- A7% (2)
- B86% (24)
- C4% (1)
- E4% (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.
'defaultuser tux' is not a valid Linux command and has no file deletion functionality.
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.
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.
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.
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
Community Discussion
No community discussion yet for this question.