rmw

From LinuxReviews
Jump to navigationJump to search
ReMove to Waste (rmw)
Developer(s)
  • Andy Alt, Project Manager
  • Parth Suresh, C
  • Bruce Hernandez, C
  • suve, C
  • Martijn de Boer, NL translation, testing
  • Ankur Jyoti Phukan, C
  • James Sherratt, C
  • Guillermo Franco, man page
  • João Rodrigues, PT translation
  • Svitlana Galianova, RU & UK translation
  • Mario Carrillo,Spanish (MX) translation
  • Subhashree Mishra, Hindi translation
Repositorygithub.com/theimpossibleastronaut/rmw/
Operating systemLinux
Type
  • Safe file removal tool
  • rm alternative
  • Shell tool
LicenseGNU GPL v3
Websiteremove-to-waste.info
Konsole.svg

rmw (ReMove to Waste) is an alternative to, but not a replacement for, the standard rm file removal utility for Linux/Unix shells. rmw saves removed files in a waste folders instead of removing them from the underlying file system so you can easily "undelete" files if you accidentally "delete" something important. Automated eradication of files moved to the waste folder after a set number of days is supported.

Configuring it so it works in all your folders can take some time if you have a complex disk setup with many partitions. You will, luckily, only have to do it once and perhaps occasionally add to the configuration file if you add partitions or get new removable devices.

Features And Usability[edit]

Rmw removing and restoring a file.jpg
rmw deleting a file, listing the last removed file (rmw -m and restoring that file (rmw -u.

rmw will configure itself with a simple strait-forward default configuration the first time you run it. It creates a configuration file in $HOME/.config/rmwrc and a default waste folder in $HOME/.local/share/Waste. The actual files you "delete" with rmw from the same partition as your $HOME are moved to the waste basked sub-folder $HOME/.local/share/Waste/files and all kinds of incriminating evidence about them is saved in $HOME/.local/share/Waste/info.

You'll very quickly notice that rmw is not as easy to setup and use at it may sound like if you have lots of partitions like /storage for large files, NFS network partitions and other more complex setups. rmw will simply do nothing but tell you that:

":warning: No suitable filesystem found for "foo.bar"
0 files were removed to the waste folder"

..if you cd into another partition, touch foo.bar and try to rmw foo.bar.

There is a simple yet slightly complex solution: You can create multiple waste folders and list them in $HOME/.config/rmwrc. You can even create waste folders on removable storage devices like external hard drives, USB sticks and network mounts by appending , removable after the desired path. rmw will create the needed /files and /info sub-folders on removable devices automatically if a folder marked removable exists when rmw is used to "delete" files on removable devices. You can't just specify /mnt/usbsticks/Waste and mount USB devices there and get /Waste created for you; you would have to create a /Waste folders on all your USB devices.

That's all good, except that you will have to do a lot of work if you want to use rmw on a machine with lots of partitions and/or you happen to use lots of different removable devices regularly.

All the tiresome work it takes to create Waste (you can call your trash folders anything as long as you point to them with WASTE= directives) folders for "deleted" files on all your partitions may be worth it if you really want to use rmw instead of good old rm. You'll only have to the majority of the configuration you will ever need to do once and occasionally create and add more WASTE= folders when you add system partitions or buy new removable devices.

rmw can mostly be used just like you would use rm once it is setup and configured. There are some minor differences between the two (apart from rmw moving, not deleting, files and folders). rmw will move folders to he waste basket even if you do not provide any -r or --recursive options. You can, rmw supports -r for compatibility, but you don't have to specify it.

rm Compatibility[edit]

rmw is not compatible with rm and it isn't meant to be. It does not support rm options like -i or --interactive and rmw's -f option relates to it's waste basked management, not forced eradication of files. rmw is therefore not something you can use as a drop-in replacement for rm.

You shouldn't place an alias in your $HOME/.bashrc that says alias rm=rmw and expect rmw to "just work" like rm does, that's not how it works or how rmw was intended to be used. You can make an alias that says

alias rm='echo Use rmw'

so you're reminded to use rmw if you try rm, or you could

alias rm='rm -i'

in which case you still get to use rm, but you're asked if you are sure you want to delete files if you accidentally type rm when you mean to type rmw.

Picking Files Out Of The Waste Basket(s)[edit]

rmw -m will show you the most recently removed files. The last file rmw removed can be restored with -u or --undo-last.

Files can be restored by filename, wildcard or patter with either -z or --restore (-z is a short-hand for --restore).

It is also possible to interactively interface with a list of eradicated files by running rmw -s. Restoring files using this tool is done by selecting a file or files with space and pressing ↵ Enter. You can not just highlight a file in the file list and press ↵ Enter, absolutely nothing happens unless you select it with space on a highlighted file before you press ↵ Enter. That's not very intuitive or what you'd expect, but it is a perfectly fine and usable way to restore files if you bother to look at the help text at the bottom of the screen.

rmw places the files you restore back in the folders they were removed from and it prints a message with the files full paths in case you forgot.

Clearing The Waste Basket(s)[edit]

rmw will, with the default configuration file it creates, refuse to let you empty the waste baskets. There is a -e or --empty option described in rmw --help as "completely empty (purge) all waste folders". It doesn't do that until you change the default purge_after value in $HOME/.config/rmwrc from 0 to any number of days you would like to keep files around before they are purged. rmw -e will work as advertised, it will clear all (re)moved files and empty all the waste baskets, as long as purge_after is set to a positive number.

You don't have to use -e to clear the waste basket if you set purge_after to a number of days, rmw will eradicate files that are older than the number of days you have set automatically - as long as you use rmw regularly, anyway. There is no systemd timer or cron job, rmw will only check if it's time to purge some files when you use it.

Verdict And Conclusion[edit]

rmw is a really handy tool that can be a life-saver if you have a bad habit of eradicating files you later regret eradicating with rm. Setting it up will take some time, and getting used to using it will take even longer. Reminding yourself by setting an alias like alias rm='rm -i' in $HOME/.bashrc will help you get used to it since you'll quickly be so annoyed by the "rm: remove regular empty file 'foo'?" prompt you get every time you remove a file when rm -i is set as an alias for rm that you'll learn to remember to use rmw instead in no-time.

rmw can't be used as a drop-in replacement for rm. That's just the way it is and it's fine as long as you don't expect it to be. It can be a really good addition to it, and it is something you should consider installing just in case you accidentally or intentionally remove some file you later wish you hadn't removed. You may be perfectly happy with your file deletions 99.9999% of the time, but you may end up quite unhappy the 0.0001% of the time you end up wishing you had used something with an easy undelete option instead of rm. rmw will save you that 0.0001% of the time if you install it and make a habit of using it.

Installation[edit]

None of the major GNU/Linux distributions seem to be aware rmw exists, so you will likely have to compile it from source. It's quick and easy, it is a tiny compile that won't take long even if you have old and/or weak hardware.

git clone https://github.com/theimpossibleastronaut/rmw.git
cd rmw
./configure
make
sudo make install

Contributing[edit]

The ReMove to Waste project has a "Contributor Covenant 1.4" Code of Conduct so you may want to think twice about contributing to this project or going anywhere near development with a 10 foot pole.

Links[edit]


Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.