What is the rm command?
When you run the rm command in your terminal, it permanently removes files or directories from the OS, which means they are removed and cannot be recovered or undone.
Syntax:
rm [options] [file or directory]
Explanation:
- [options] → -r (for removing directories)
- [file or directory] → You should type here the file or folder name that you want to remove.
Example 1: Remove a single file
Command:
rm file1.txt
Explanation:
- It removes
file1.txtfrom the current directory. - The file has been permanently removed, along with its contents and name.
Example 2: Remove multiple files at once
Command:
rm file1.txt file2.txt
Explanation:
When you run this command with more than one file, it permanently removes all the specified files.
Example 3: Remove a folder and everything inside it
Command:
rm -r myfolder
Explanation:
When you use the -r option, it permanently removes the folder (for example, myfolder) along with all files and subfolders inside it.
Notes:
- When you use this command, verify the file or folder name carefully before running the
rmcommand. - When you use the
-roption, it removes the file or folder and everything inside it recursively. You must be very careful before running it.












