Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Jul 2 '10 at 14:28

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

By restoring from your backup. – Amardeep Jul 2 '10 at 13:34
ed can be used (if you have a really good memory). – msw Jul 2 '10 at 13:37
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
It's crazy how the Linux terminal doesn't have a garbage bin. – Hermann Ingjaldsson Jul 2 '10 at 14:16
@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. – msw Jul 2 '10 at 15:52

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 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

Never tried it.

share|improve this answer

You must log in to answer this question.