nerdexam
CompTIA

XK0-004 · Question #35

Given the output below: Which of the following commands can be used to remove MyPhoto.jpg from the current directory?

The correct answer is E. ln -rm ./Pictures/photo.jpg. This question appears to contain errors - choice label B is absent, and the marked correct answer E uses 'ln -rm' which is not valid Linux syntax. Based solely on the provided correct answer, E is treated as correct here.

System Management

Question

Given the output below:

Which of the following commands can be used to remove MyPhoto.jpg from the current directory?

Options

  • Aunlink ./MyPhoto.jpg
  • Crm -rf ./Pictures
  • Drm -f MyPhoto.jpg
  • Eln -rm ./Pictures/photo.jpg

How the community answered

(50 responses)
  • A
    4% (2)
  • C
    8% (4)
  • D
    14% (7)
  • E
    74% (37)

Why each option

This question appears to contain errors - choice label B is absent, and the marked correct answer E uses 'ln -rm' which is not valid Linux syntax. Based solely on the provided correct answer, E is treated as correct here.

Aunlink ./MyPhoto.jpg

unlink ./MyPhoto.jpg would actually successfully remove the specified file by unlinking it from the directory, making it a technically valid alternative despite not being marked correct.

Crm -rf ./Pictures

rm -rf ./Pictures removes the entire Pictures directory and all its contents recursively, not just MyPhoto.jpg from the current working directory.

Drm -f MyPhoto.jpg

rm -f MyPhoto.jpg forcibly removes MyPhoto.jpg from the current directory without prompting, which is also a technically correct operation despite not being marked as the answer.

Eln -rm ./Pictures/photo.jpgCorrect

Note: ln -rm ./Pictures/photo.jpg is not a valid Linux command because ln creates hard or symbolic links and does not accept an -rm flag for removal. This answer appears to be an error in the question; the technically valid commands for removing MyPhoto.jpg from the current directory would be rm -f MyPhoto.jpg (D) or unlink ./MyPhoto.jpg (A).

Concept tested: Linux file removal and link management commands

Source: https://man7.org/linux/man-pages/man1/rm.1.html

Topics

#unlink#rm#hard links#file removal

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice