1

I've accidentally overwritten /usr/etc with a random config file using sudo cp ~/.nzbget /usr/etc.

Yes I know I should have backed it up etc, etc, etc... Now the important stuff, I've seen extundelete, is it possible to recover the previous 'version', ie: the real /usr/etc. /usr/etc is not on a specific partition, so is part of / which I can't really unmount.

What is the best way for me to proceed?

  • 1
    This should have copied .nzbget into /usr/etc, not overwrite the whole thing. Besides, copying entire directories would trigger "cp: ommiting directory". – John WH Smith Dec 22 '14 at 20:17
  • Well /usr/etc is currently a file, so looks like it did. Does Debian utilise /usr/etc by default? – aSystemOverload Dec 22 '14 at 20:24
  • 2
    @aSystemOverloaded And who told you it should exist? Unless you explicitly installed software to /usr (which involved configuration files into /usr/etc), this directory shouldn't be. Remove that file. – John WH Smith Dec 22 '14 at 20:26
  • It was in the config file for NZBGet, saying it looked in these four locations for the config file, one of which was /usr/etc/nzbget.conf, an 'ASSumption' on my part, thanks for your assistance. – aSystemOverload Dec 22 '14 at 21:24
4

/usr/etc is usually unused on most systems. Configurations for programs from package managers and so on are expected to go to /etc, while configurations for custom (manually compiled) programs should go to /usr/local/etc.

The only time when you need /usr/etc is when you manually compile a program with --prefix=/usr, in which case it will install its configuration files under /usr/etc. If you never installed anything under this condition, then this directory never existed.

If it had existed, your command wouldn't have overwritten it: it would have sent ~/.nzbget in it instead. You would therefore have /usr/etc/.nzbget. If .nzbget is a directory, then your cp command should have failed with...

cp: ommiting directory '~/.nzbget'.

... since it cannot copy directories unless you use the recursive switch (-R). Here again, it would have copied this directory inside /usr/etc, not overwritten it. Under no circumstances could a file replace a directory, since this would probably corrupt the file system with dummy nodes (the files which used to be under that directory would have broken paths). The kernel itself won't allow it.

If you now have a /usr/etc file, then you just created it (with the contents of ~/.nzbget). Feel free to remove it (this will require root privileges if you copied your file using them) ;)

  • My natural paranoia is scared to kill it, but it's gotta be done one way or another. I did search for references to /usr/etc but there is conflicting information and nothing specific I could rely on. Thank you. – aSystemOverload Dec 22 '14 at 20:41
  • Do you know a good resource for recommended backup locations, as in which folders/files need to be backed up. Also, what would you recommend as the solution, would be great to have something that can backup daily and will keep x copies over specific periods. – aSystemOverload Dec 22 '14 at 20:49
  • @aSystemOverload This is a completely different question, to which Google would gladly answer. If you want to ask a more specific question about these tools, feel free to open one here, as long as it remains Unix & Linux specific, and isn't primarily opinion-based. :) – John WH Smith Dec 22 '14 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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