←
Command Line
/
Guided Lab Remove Files with rm
60:00
Click the virtual machine below to start practicing
>_ Tekhnikum | Lab
- Setting up virtual machine…
- Preparing lab files…
- Starting terminal services…
This lab machine has stopped
Your progress through the guide is saved. Start a fresh machine to keep practicing.
Introduction
rm deletes files immediately. There is no recycle bin on the command line, so this lab practises the habits that keep you safe.
This lab is the hands-on companion to the rm (Remove) lesson from Linux Journey (CC BY-SA 4.0).
Remove a File
rm file1
ls
Preview a Wildcard First
Before deleting with a wildcard, run ls with the same pattern to see exactly what would go:
ls *.tmp
rm *.tmp
keep.txt must survive.
Ask Before Deleting
-i asks for confirmation for every file. Answer n to keep it:
rm -i important.txt
rm: remove regular file 'important.txt'? n
Remove Directories
rmdir removes only empty directories. rm -r removes a directory and everything in it, so check what's inside first:
rmdir emptydir
ls -R oldproject
rm -r oldproject
Summary
rm file deletes immediately; there is no undo.
- Preview wildcards with
ls before rm.
rm -i asks before each deletion.
rmdir removes empty directories; rm -r removes a directory tree.