0
0
Linux CLIscripting~5 mins

rm (remove files) in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the rm command do in Linux?
The rm command deletes files or directories from the file system permanently.
Click to reveal answer
beginner
How do you remove a directory and all its contents using rm?
Use rm -r directory_name. The -r option means recursive, so it deletes the directory and everything inside it.
Click to reveal answer
beginner
What does the -i option do with the rm command?
The -i option asks for confirmation before deleting each file. It helps prevent accidental deletion.
Click to reveal answer
intermediate
Why should you be careful when using rm -rf /?
Because rm -rf / deletes all files and directories starting from the root, which can erase your entire system and cause it to stop working.
Click to reveal answer
beginner
How can you remove multiple files at once with rm?
You can list multiple files separated by spaces, like rm file1.txt file2.txt file3.txt, and all will be deleted.
Click to reveal answer
What does the command rm -r myfolder do?
ACreates a new folder named 'myfolder'
BRenames the folder 'myfolder'
CMoves 'myfolder' to another location
DDeletes the folder 'myfolder' and all its contents
Which option makes rm ask before deleting each file?
A-r
B-f
C-i
D-v
What happens if you run rm file.txt?
AThe file 'file.txt' is deleted
BThe file 'file.txt' is copied
CThe file 'file.txt' is renamed
DThe file 'file.txt' is opened
What does the -f option do with rm?
AForces deletion without asking
BFinds files to delete
CFormats the disk
DFixes file permissions
Which command deletes multiple files at once?
Arm -r file1 file2 file3
Brm file1 file2 file3
Crm -i file1 file2 file3
Drm -v file1 file2 file3
Explain how to safely delete a directory and its contents using the rm command.
Think about recursive deletion and asking before deleting.
You got /3 concepts.
    Describe the risks of using rm -rf / and why it should be avoided.
    Consider what happens when you delete everything on your computer.
    You got /3 concepts.