2 Answers
2

Don't ever try to recover system files

Oh please, don't ever recommend file recovery for system files!
File recovery can be attempted on more unique files like a text you've written yourself.

Recovering system files is begging for troubles.

1st Solution

For your system, just reinstall it. You don't need to wipe/format anything during the installation: everything missing will just be replaced. You will just have to upgrade as usual.

But this shouldn't be necessary as /usr/local is most certainly empty on your system.

2nd Solution

Usually, there is almost nothing in that folder. If you know that you have installed something there, just reinstall it.

Finally, some packages might have put some files in there. Just open a terminal and check that the following commands outputs nothing:

dpkg --get-selections | cut -f 1 | xargs dpkg -L | grep /usr/local

Explanations

What it does is pretty simple:

dpkg --get-selections

will output the list of the packages installed on your system in the format:

package_name installed

But we only want package_name for each line:

| cut -f 1

| tells bash (the program that runs in the terminal) that the output of the previous command should not be displayed but "piped" inside the next program (here cut).

cut, as its name implies will cut each line into words an keep only the first field (-f 1) that it will display.

To sum up,

dpkg --get-selections | cut -f 1

should return the list of the packages installed on your system.

Now we can pipe that list to xargs which acts like "for each element in the list do ...".

Here,

xargs dpkg -L

will execute:

dpkg -L package1
dpkg -L package2
dpkg -L package3
...

for each package name that you give it through the pipe.

dpkg -L mypackage lists the files contained in the package named "mypackage".

And now, we just have to take that file list and check whether some package did put a file in /usr/local. We do it with grep which will filter out any output not containing /usr/local.

So, if we put it in order, first we get the list of installed packages, then we format this list to keep only the package names, then we list the installation folders used by the package, then we filter it to keep only what's inside of /usr/local.