Adding a trash can to Linux with trash-CLI
10 months ago
- #Linux
- #File Recovery
- #CLI
- Linux CLI lacks a trash can, but trash-cli provides a solution for safely removing and recovering files.
- Installation of trash-cli is possible via multiple methods, with instructions available on GitHub.
- Using aliases for trash-cli commands is recommended, but overwriting 'rm' can cause issues.
- Files can be moved to trash using 'trash' or 'trash-put', with suggested alias 'tm'.
- View trash contents with 'trash-list' (alias 'tmls') and search with 'trash-list | grep -i' (alias 'tmgr').
- Trashed items are stored in '~/.local/share/Trash/files' or '/root/.local/share/Trash/files' for sudo operations.
- Check trash disk usage with 'du -sh ~/.local/share/Trash/files' (alias 'tmdu').
- Recover trashed items using 'trash-restore' (alias 'tmre'), but cannot overwrite existing files.
- Empty the trash with 'trash-empty' (no confirmation) or 'trash-empty n' to remove items older than 'n' days.
- Remove specific items from trash with 'trash-rm', though path-based removal may not work.
- Automate trash cleanup with cron jobs, e.g., '20 4 * * * trash-rm 7' to run daily at 4:20 AM.
- The tool is highly recommended for its file recovery capabilities, despite minor inconveniences on unmanaged systems.