Challenge - 5 Problems
Master of rm command
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this command?
You run the command
rm -i file1.txt in a directory where file1.txt exists. What will happen?Linux CLI
rm -i file1.txt
Attempts:
2 left
💡 Hint
The -i option in rm stands for interactive mode.
✗ Incorrect
The -i option makes rm ask for confirmation before deleting each file.
💻 Command Output
intermediate2:00remaining
What happens when you run this command?
You run
rm -r myfolder where myfolder contains files and subfolders. What is the result?Linux CLI
rm -r myfolder
Attempts:
2 left
💡 Hint
The -r option means recursive deletion.
✗ Incorrect
The -r option tells rm to delete directories and their contents recursively.
🔧 Debug
advanced2:00remaining
Why does this command fail?
You run
rm -f file1.txt file2.txt but get an error saying rm: cannot remove 'file2.txt': Permission denied. What is the cause?Linux CLI
rm -f file1.txt file2.txt
Attempts:
2 left
💡 Hint
The -f option forces removal and suppresses errors for missing files.
✗ Incorrect
If the user lacks permission to access the directory or file, rm can show errors even with -f.
📝 Syntax
advanced2:00remaining
Which command correctly deletes all .log files in the current directory?
Choose the correct rm command to delete all files ending with .log in the current folder.
Attempts:
2 left
💡 Hint
Use -f to force deletion without prompts.
✗ Incorrect
rm -f *.log deletes all .log files forcibly without asking for confirmation. -r is unnecessary for files.
🚀 Application
expert3:00remaining
How many files remain after running this script?
You have a folder with files: a.txt, b.txt, c.log, d.log, e.txt. You run this script:
After confirming deletion of only c.log, how many files remain?
rm -f *.txt rm -i *.log
After confirming deletion of only c.log, how many files remain?
Attempts:
2 left
💡 Hint
First command deletes all .txt files without prompt. Second asks for confirmation on .log files.
✗ Incorrect
rm -f *.txt deletes a.txt, b.txt, e.txt. rm -i *.log prompts for c.log and d.log. Only c.log is confirmed deleted, so d.log remains.