1

I accidentally deleted a bunch of Unix Executable Files on my Mac when I was using some cleanup tool and now there's no way I could restore those files using that app.

But I have them all in my trash folder and I'm wondering if there's a way to locate where the files originally were so I can manually put them back

Some of them are really obvious, like Dictionary is in Contents » MacOs, but for some other files like AdjustmentsPlugin, or DUSupport I have no idea where they were.

Is there an app I can use to locate Unix fils? Since I have another Mac I can just look for the files there. Spotlight doesn't really look for Unix Executables.

3
  • 1
    Can you tell us which cleanup tool you used and give us a few more examples from your Trash? Can't you just go to the Trash, right click, and select Put back…?
    – slhck
    Jul 25, 2012 at 18:50
  • I was using Xslimmer and it deleted a bunch of executable files. I don't think mac has an option to restore files from trash though... but my problem is now fixed. I looked up the file locations on another computer and put them back manually.
    – pew007
    Jul 25, 2012 at 19:35
  • 1
    Oh, alright! In a few hours, you can answer your own question (using the button below) and tell us exactly how you did it — that'd help others with the same problem.
    – slhck
    Jul 25, 2012 at 19:41

3 Answers 3

1

Have you tried the locate command from a shell prompt? Assuming the locate database has not yet been rebuild that should show you the old location of the files.

5
  • is there a suffix for those unix executable files? when I use the locate command it just says unknown0021e9e64f1a:~ Home$ locate Dictionary WARNING: The locate database (/var/db/locate.database) does not exist. To create the database, run the following command: sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist Please be aware that the database can take some time to generate; once the database has been created, this message will no longer appear.
    – pew007
    Jul 25, 2012 at 17:12
  • 2
    @newbie: Unix executable files generally do not have a filename extension. On conventional Unix/Linux systems they are likely to be found in directories named bin (or sbin). Jul 25, 2012 at 17:22
  • That means you succesfuly found and ran the locate command. Unfortunately the database its gets its information from is empty. You can create suces a DB with the command you listed (sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist), but that would only generate a database with the current location of the files (e.g. int he recycle bin). I was hoping to use the location from an old database. (Most unix systems update such a DB weekly or even nightly. I guess the defaults on OS/X differ).
    – Hennes
    Jul 25, 2012 at 17:32
  • That link to locate is broken. Sep 17, 2017 at 22:30
  • That is the downside of external links. It used to work. I replaced it with a new (currently working) link.
    – Hennes
    Sep 18, 2017 at 12:06
1

One option would be to use Spotlight:

mdfind 'kMDItemContentType==public.unix-executable'

It seems to exclude files inside application bundles though. And it doesn't include files with an extension like .sh or .rb even if they were executable.

1

Executable files have the executable bit set ( think chmod +x )

This is easily detectable by the tools that come with the operating system:

mdls

GetFileInfo #if you have the Developer Tools installed

Extended attributes ls -l@e

Now you just need a way to recurse into the filesystem, to find files which are executable:

find 

works if you like bash

Fire up zsh and you can use this:

print -l ${^path}/*(-*N)

To print , one per line , everything in your $PATH, which is an executable file

Run this as root of course, to get into all the nooks and crannies of the system.

Spotlight won't search anywhere that is hidden from you ordinarily.

Now:

This is the hard way, because in the finder, there is an option to "put back" files in the trash, which means there is metadata about where the files came from.

Regardless, if all the files are in the trash, then you just need create your list of paths, and make your system fit.

Actually, this is a job for Radmind, which is a tool used to bring a system into correspondence with a reference system... but you could also just re-install the OS, in place.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .