Is there any way to recover files in /usr/local directory on Ubuntu?

We are running Ubuntu server on VPS. Some files were removed accidentally by placing unnecessary space this command:

rm -r /usr/local <directory to be deleted>

I know, that in most cases this directory is used by packages to place some part of their content.

Is there any where to recover deleted files and directories?

I suppose, that theoretically it should be possible. Some software can look through the list of installed packages, check presence of files in file system and recover or reinstall corrupted packages if their files are missing in /usr/local.


Solution 1:

Per Debian (and therefore Ubuntu) policy packages should never use /usr/local/ for anything.

If a package did use it you could find out by using debsums -s to find missing files.

If you don't want to install debsums you could simply do:

grep '/usr/local/' /var/lib/dpkg/info/*.list

On my Debian laptop (with plenty of stuff installed) this shows no results, exactly as you'd expect.

/usr/local is used for locally installed binaries and scripts, and for those you should have backups.

Solution 2:

Check out ext3grep. It's not as easy as MS-DOS undelete used to be in the old days, but it has helped me out once.