Linux Terminal Command: rm
The rm command is an essential tool in File Manipulation & Viewing. In this tutorial, we will explore what rm does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.
Concept & Explanation
The rm command deletes file system objects. Unlike moving files to a graphical Trash bin, rm deletes files permanently and unlinks them from the filesystem inode database.
Common Options & Syntax
rm [options] [arguments]
Here are the most common flags used with rm:
- Simple Usage: Basic default commands.
- Detailed View: Shows diagnostic information.
- Advanced Actions: Can chain parameters for scripting.
1. Interactive Example (Simple)
Here is how most people run the command:
# Example
rm report.txt
What it does: Deletes the file ‘report.txt’ in the current directory.
2. Power-User Example (Advanced)
For scripting and advanced diagnostics, use this configuration:
# Advanced
rm -rf --interactive=once sensitive_data/
What it does: Recursively (-r) and forcefully (-f) removes the folder and its contents, prompting the user once before executing if it matches a large file range.
⚙️ Warning & Common Pitfalls
[!WARNING] Running
rm -rf *orrm -rf /(if permitted) can delete crucial system files. Always double-check your current directory usingpwdbefore running recursive deletion commands.
🔗 Related Commands
Here are some related posts on cli_tty1 you might want to check out:
- pwd : Print name of current/working directory.