I have deleted /etc/rc.d/ dirs, how can I restore them?
I have accidentally deleted /etc/rc.d and /etc/rc0.d folders which resulted deletion of init.d and other related folders.
1.What is the use of /etc/rc.d, rc, rc.d, rc0.d, rc1.d, rc2.d.......rc6.d and other files inside /etc/rc.d?
2.If we accidentally delete them how to recover?
3.If we have the same files in other server can we copy and get the situation to normal?
4.Suggest any possible way to minimize the impact or totally resolve this situation.
PLEASE HELPP!!!
OS DETAILS here
Linux version 2.6.32-642.11.1.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) ) SMP Wed Oct 26 10:25:23 EDT 2016
Solution 1:
/etc/rcX.d
(where X is the runlevel) contains symbolic (a.k.a. soft) links to init scripts in/etc/init.d
that are to be executed by/sbin/init
(on boot). It is explained for Red Hat Enterprise Linux 6 with pretty much detail here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/installation_guide/s2-boot-init-shutdown-initThe best thing would be to recover them from a recent backup (as already mentioned by Gerard H. Pille in his comment above). Should you lack such a backup you could try to recover them using
/sbin/chkconfig
or/usr/sbin/ntsysv
which provides a ncurses user interface. I have no experience with it, but you can find a manual here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-services-ntsysvIf the other server has been set up in the exact same way (e.g. with ansible or some setup script) this might be a viable solution. In any case the structure of the other server could be helpful when using
/usr/sbin/ntsysv
Try not to reboot the server until you have restored the
/etc/rc.d
folders and symlinks. Good luck!
According to the comment by Gerard below you could also try to install the yum-verify plugin:
yum install yum-plugin-verify
and make sure that you have
plugins=1
in /etc/yum.conf
. Then execute
yum verify-all
and it should check all installed packages and report missing configuration files. Re-installing misconfigured packages should solve the problem, but again, I never had to do this myself.
Update You should re-create the symbolic links for each and any service that is runninf on the identical other server with
chkconfig service_name on
where service_name is the name of the init.d script you want to start on boot. Using this command should make sure that the links are created within the appropriate runlevel folder.
You can check your progress with
chkconfig --list
and compare the output with the output on the other server.
You can find a chkconfig manual here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-services-chkconfig