drop-in replacement for rm with undo/restore built-in.
Project description
resrm
resrm is a safe, drop-in replacement for the Linux rm command with undo/restore support.
It moves files to a per-user trash instead of permanently deleting them, while still allowing full sudo support for root-owned files.
Features
-
Move files and directories to a Trash folder instead of permanent deletion
-
Restore deleted files by short ID or exact basename
-
Empty trash safely
-
Supports
-r,-f,-i,--skip-trashoptions -
Works with
sudofor root-owned files -
Automatically prunes Trash entries older than
$RESRM_TRASH_LIFEdays (default 7, minimum 1)Note: if you need immediate deletion, use the
--skip-trashflag.
Installation
From GuardUtils package repo
This is the preferred method of installation.
Debian/Ubuntu
1) Import the GPG key
sudo mkdir -p /usr/share/keyrings
curl -fsSL https://repo.sysmd.uk/guardutils/guardutils.gpg | sudo gpg --dearmor -o /usr/share/keyrings/guardutils.gpg
The GPG fingerprint is 0032C71FA6A11EF9567D4434C5C06BD4603C28B1.
2) Add the APT source
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/guardutils.gpg] https://repo.sysmd.uk/guardutils/debian stable main" | sudo tee /etc/apt/sources.list.d/guardutils.list
3) Update and install
sudo apt update
sudo apt install resrm
Fedora/RHEL
1) Import the GPG key
sudo rpm --import https://repo.sysmd.uk/guardutils/guardutils.gpg
2) Add the repository configuration
sudo tee /etc/yum.repos.d/guardutils.repo > /dev/null << 'EOF'
[guardutils]
name=GuardUtils Repository
baseurl=https://repo.sysmd.uk/guardutils/rpm/$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://repo.sysmd.uk/guardutils/guardutils.gpg
EOF
4) Update and install
sudo dnf upgrade --refresh
sudo dnf install resrm
From PyPI
NOTE: To use resrm with sudo, the path to resrm must be in the $PATH seen by root.
Either:
- install
resrmasroot, or - add the path to
resrmto thesecure_pathparameter in/etc/sudoers. For example, where/home/user/.local/binis whereresrmis:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user/.local/bin"
Install with:
pip install resrm
From this repository
git clone https://git.sysmd.uk/guardutils/resrm.git
cd resrm/
poetry install
Usage
# Move files to trash
resrm file1 file2
# Recursive remove of a directory
resrm -r mydir
# Force remove (ignore nonexistent)
resrm -f file
# Interactive remove
resrm -i file
# Permanent delete (bypass trash)
resrm --skip-trash file
# List trash entries
resrm -l
# Restore a file by ID or basename
resrm --restore <id|name>
# Show full details of trashed item
resrm --inspect <id|name>
# Empty the trash permanently
resrm --empty
Trash Location
Normal users: ~/.local/share/resrm/files
Root user: /root/.local/share/resrm/files
Configuration
To control how long trashed files are kept, add this line to your shell configuration (e.g. ~/.bashrc):
export RESRM_TRASH_LIFE=10
TAB completion
Add this to your .bashrc
eval "$(register-python-argcomplete resrm)"
And then
source ~/.bashrc
pre-commit
This project uses pre-commit to run automatic formatting and security checks before each commit (Black, Bandit, and various safety checks).
To enable it:
poetry install
poetry run pre-commit install
This ensures consistent formatting, catches common issues early, and keeps the codebase clean.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file resrm-0.4.1.tar.gz.
File metadata
- Download URL: resrm-0.4.1.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.11 Linux/6.18.5-100.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd2ec073fc9ae3490940231c78ff31de1599f8b501f0b279025e4431ff143867
|
|
| MD5 |
b157016e38f31a93c5700d1aaf932f9b
|
|
| BLAKE2b-256 |
a8fa2e6ec79c349e84240ded9aae9e55bcc8584663d4ed03bdbef92225422b9a
|
File details
Details for the file resrm-0.4.1-py3-none-any.whl.
File metadata
- Download URL: resrm-0.4.1-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.11 Linux/6.18.5-100.fc42.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03820dfa14541f55c7334739d5bcb2472a7b03bc217a791aa8d1972bb43ec3a7
|
|
| MD5 |
21e69a4e1ae3cc8b47b52d964b5682fc
|
|
| BLAKE2b-256 |
89399e92bd5d8ded8a75e1ad59995999bfd08a2de4f14d690bd17b72ed38766b
|