Can files/directories deleted with rm be restored?

To this end I use trash-cli package and the following alias in my ~/.bashrc

alias rm=trash

And the trash-cli package can be installed by the followoing command: sudo apt-get install trash-cli.

The files you remove will be moved to trash, and you can see them in nautilus trashcan.

You can always access the real rm by using one of the following method:

command rm something
'rm' something
\rm something

There are also commands to access the trashcan from terminal, trash-list, restore-trash (or trash-restore), trash-empty installable from package trash-cli (then see their man pages).

Last note, it is not advisable to use such an alias for super-user, because it can interfere with system operations.


Deleting it from terminal deletes it permanently - recovery is very hard and sometimes impossible.

If your partition type is ext3 (check it by using the System->Administration->Disk Utility), then take a look at ext3undel.

If it is not (if you installed Ubuntu with default settings), try the extundelete program.

There is no guarantee you will recover anything though.