Multiple choice unix

How do you delete a file?

  1. mv filename

  2. cp filename

  3. rm filename

  4. rm -rf *

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The 'rm filename' command removes (deletes) a single file. 'mv' moves/renames files, 'cp' copies files, and 'rm -rf *' recursively deletes ALL files and directories in the current location - a dangerous command unrelated to deleting a single file.

AI explanation

To delete a file, you can use the rm command in a terminal. Let's go through each option to understand why it is correct or incorrect:

Option A) mv filename - This option is incorrect because the mv command is used to move or rename files, not delete them.

Option B) cp filename - This option is incorrect because the cp command is used to copy files, not delete them.

Option C) rm filename - This option is correct because the rm command is used to remove/delete files. By providing the filename as an argument, you can delete the specific file.

Option D) rm -rf * - This option is incorrect because the rm -rf * command is used to forcefully delete all files and directories in the current directory. It is a dangerous command and should be used with caution.

The correct answer is Option C) rm filename. This option is correct because it uses the rm command to delete the specified file.