Linux command
safe-rm 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Delete a file
safe-rm [path/to/file]
Recursively delete a directory
safe-rm -r [path/to/directory]
Force delete files
safe-rm -rf [path/to/directory]
Delete multiple files
safe-rm -v [file1] [file2] [file3]
说明
safe-rm is a wrapper around the rm command that prevents accidental deletion of important system files and directories. It checks arguments against a configurable blacklist before passing them to the real rm. When a user attempts to delete a protected path, safe-rm refuses the operation and displays a warning instead. This provides a safety net against catastrophic mistakes like rm -rf /. Protected paths are configured in /etc/safe-rm.conf for system-wide protection and ~/.safe-rm for per-user settings. Each file contains one path per line. If both are empty, a default list of critical system paths is used. To use safe-rm as the default rm, create a symlink in a directory that precedes /bin in your PATH: ```ln -s /usr/bin/safe-rm /usr/local/bin/rm```
参数
- -r, -R, --recursive
- Remove directories and their contents recursively
- -f, --force
- Ignore nonexistent files and arguments, never prompt
- -i
- Prompt before every removal
- -v, --verbose
- Explain what is being done
FAQ
What is the safe-rm command used for?
safe-rm is a wrapper around the rm command that prevents accidental deletion of important system files and directories. It checks arguments against a configurable blacklist before passing them to the real rm. When a user attempts to delete a protected path, safe-rm refuses the operation and displays a warning instead. This provides a safety net against catastrophic mistakes like rm -rf /. Protected paths are configured in /etc/safe-rm.conf for system-wide protection and ~/.safe-rm for per-user settings. Each file contains one path per line. If both are empty, a default list of critical system paths is used. To use safe-rm as the default rm, create a symlink in a directory that precedes /bin in your PATH: ```ln -s /usr/bin/safe-rm /usr/local/bin/rm```
How do I run a basic safe-rm example?
Run `safe-rm [path/to/file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -r, -R, --recursive do in safe-rm?
Remove directories and their contents recursively