This is kind of scary! I removed /etc/init.d directory! How can I recover this directory? I know that if I restart my computer now I won't see my linux again!
Please advice!
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityLook at the /etc/rc?.d directories. You will find symlinks in those that point to the scripts that were in /etc/init.d. You will know what startup scripts you will need to restore to /etc/init.d. So, something like:
$ ls -l /etc/rc?.d
and you will see something like:
/etc/rc2.d:
total 4
-rw-r--r-- 1 root root 556 2009-01-23 15:01 README
lrwxrwxrwx 1 root root 18 2009-10-27 00:05 S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx 1 root root 15 2009-10-27 00:05 S11klogd -> ../init.d/klogd
lrwxrwxrwx 1 root root 13 2009-10-27 00:05 S16ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 18 2010-06-07 22:04 S20bluepill -> ../init.d/bluepill
To get a copy of those scripts, do what Martin suggests, or, alternatively, spin up another machine (on a spare computer or in a virtual environment) using the same Linux distro, and copy the relevant /etc/init.d files from there; you may have to install additional packages. The latter might be easier.
After you copy the files, you should run the "ls -l /etc/rc?.d" again. The broken symlinks should now be there. If there are broken links, figure out what packages provide those, etc., install those on the VM, and keep doing this until things look correct.
After that, you're probably going to be OK, though you should be prepared to get console on the machine in case something goes wrong.
Install the same Linux distri in a VM, if you have extra services like Apache etc. install them too, and copy the /etc/init.d directory to your machine.
Maybe you could find developer infrastructure (issue trackers, repositories, ...) for your distribution and checkout the scripts out of there.
This would work for basic init scripts. For various program's init scripts you can either checkout the init scripts for each such program, or simply reinstall appropriate package.