Source : Internet
The $ rm -rf command in Linux is a powerful file and directory removal command that deletes files and directories recursively and forcefully, without prompting for confirmation.
Example:
This will permanently delete the project folder along with all subfolders and files inside it.
Breakdown of Options:
rm – The base command to remove files.
-r / --recursive – Removes directories and their contents recursively.
-f / --force – Ignores nonexistent files and never prompts for confirmation.
Usage Examples:
Delete a single directory recursively and forcefully
Deletes the directory and everything inside it without asking.
Delete multiple directories/files
Removes all listed items in one go.
Delete hidden files/folders
Removes hidden files/directories inside a folder.
Important Considerations:
Irreversible Deletion: Unlike GUI trash bins, rm -rf does not move files to a recycle bin — data is gone permanently.
Root Directory Protection: By default, GNU rm prevents removing /. Using --no-preserve-root overrides this, but it is extremely dangerous.
Safe Practices: Double-check paths before executing. Use ls first to verify contents. Consider using -i for interactive deletion if unsure.
⚠️ Warning: Running rm -rf / or similar on critical paths can wipe your entire system. Always ensure you are targeting the correct directory or file before execution.
No comments:
Post a Comment