0
0
Linux CLIscripting~20 mins

rm (remove files) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of rm command
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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
AThe file file1.txt is deleted immediately without any prompt.
BThe system asks for confirmation before deleting file1.txt.
CThe command shows an error because -i is not a valid option.
DThe command deletes all files in the directory.
Attempts:
2 left
💡 Hint
The -i option in rm stands for interactive mode.
💻 Command Output
intermediate
2: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
AThe command deletes only files inside myfolder but not subfolders.
BOnly the empty folder myfolder is deleted; files inside remain.
CThe folder myfolder and all its contents are deleted recursively.
DThe command fails with an error because -r is not valid.
Attempts:
2 left
💡 Hint
The -r option means recursive deletion.
🔧 Debug
advanced
2: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
Afile2.txt exists, but the error appears because the command was run without sufficient permissions.
Bfile2.txt does not exist, but -f suppresses errors so no message should appear.
Cfile2.txt does not exist, but the error appears because the shell expanded a variable incorrectly.
Dfile2.txt does not exist, but the error appears because -f was not recognized.
Attempts:
2 left
💡 Hint
The -f option forces removal and suppresses errors for missing files.
📝 Syntax
advanced
2: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.
Arm *.log
Brm -r *.log
Crm -rf *.log
Drm -f *.log
Attempts:
2 left
💡 Hint
Use -f to force deletion without prompts.
🚀 Application
expert
3: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:
rm -f *.txt
rm -i *.log

After confirming deletion of only c.log, how many files remain?
A1
B2
C3
D0
Attempts:
2 left
💡 Hint
First command deletes all .txt files without prompt. Second asks for confirmation on .log files.