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 have accidentally removed my apache2 startup file /etc/init.d/apache2 using rm /etc/init.d/apache2 command.

How can I get that back?

share|improve this question

migrated from stackoverflow.com Jul 2 '10 at 14:28

This question came from our site for professional and enthusiast programmers.

6  
By restoring from your backup. –  Amardeep Jul 2 '10 at 13:34
2  
ed can be used (if you have a really good memory). –  msw Jul 2 '10 at 13:37
2  
Remount read-only. Right now. mount -oremount,ro /. Then continue looking for recovery programs, probably on a different machine because a read-only root is not appreciated by many programs. –  Thomas Jul 2 '10 at 13:39
2  
It's crazy how the Linux terminal doesn't have a garbage bin. –  Hermann Ingjaldsson Jul 2 '10 at 14:16
2  
@Hermann: if you are in a FreeDesktop (Gnome, KDE, XFCE) environment trash /etc/init.d/apache2 works as does restore-trash. I've never used them as source control and backups have always been sufficient and protect against more than a bad rm. ramendik.ru/docs/trashspec.html –  msw Jul 2 '10 at 15:52

5 Answers 5

In this case the file is part of a package in the distribution. Just reinstall it.

In apt-based systems like Debian or Ubuntu, i believe it's just sudo apt-get --reinstall install apache2.2-common

share|improve this answer
1  
+1 easiest way to go here. –  David Z Jul 2 '10 at 19:01

Depending on your package manager, you can just reinstall the apache package. It will add that file back. Make sure you back up your configurations before you try though.

share|improve this answer

This won't help you after the event, but I highly recommend etckeeper. It maintains your /etc in a git/mercurial/darcs/bzr repository more or less automatically. It works best on Debian/Ubuntu where it's tied in with apt to make automatic commits before and after package installs, but it's usable on any Unix system. I'm using it on Mac OS X, for example. I can see the entire history of my /etc directory, and pull out previous versions of files when I need to.

share|improve this answer

http://e2undel.sourceforge.net/recovery-howto.html

Never tried it.

share|improve this answer

Your Answer

 
discard

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