Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using OS X Lion, and trying to delete some files I did accidentally (from home directoy):

rm -fr Library

I realized about this some 15 seconds later and did

killall rm

Some folders have been deleted, of course, inside "Library". Now the system seems to be ok, but I fear what will happen in case of reboot.

I have a Time Machine backup from 5 days ago. I wonder if it would be a good solution, just to copy whole "Library" folder from my home directory from backup and replace this one.

Or, what do you think would be the best approach?

PS: In order to restore just deleted directories inside "Library", in which order does "rm" start to delete directories, alphabetically?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I wouldn't risk anything and just restore your complete ~/Library. There are so many possibilities for items going missing that you relied upon – only very few files here are restored automatically by the system, e.g. those in ~/Library/Preferences or ~/Library/Application Support.

Both directories contain the most important user data, namely your application settings and additional data (e.g. chat logs, browser profiles, et cetera). So, when restoring, you might lose data saved in those five days.

Also check ~/Library/Mail for any Mail.app content. Last but not least, the ~/Library/Keychains folder will contain your saved passwords.

The order of a recursive rm is depth-first, by the way. So, it goes into the first folder – as deeply as possible – and starts deleting from there. Only when this folder is completely removed, the next one is traversed*:

In the case of commands such as rm and du, a postorder depth-first search is, in fact, the method of choice. This is because the descendants of a directory must be processed before the directory itself can be processed.

* Glenn S. Fowler, David G. Korn, K.-Phong Vo, An Efficient File Hierarchy Walker.

share|improve this answer
    
thanks! reading this I just replaced the first three folders and now everything seems to work –  flow Jun 19 '12 at 8:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.