LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   How to recover accidentally deleted /etc/rc.d file or folder?? What is the impact of deleting them? (https://www.linuxquestions.org/questions/linux-enterprise-47/how-to-recover-accidentally-deleted-etc-rc-d-file-or-folder-what-is-the-impact-of-deleting-them-4175673770/)

techuser23 04-23-2020 02:05 AM

How to recover accidentally deleted /etc/rc.d file or folder?? What is the impact of deleting 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?

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 (mockbuild@x86-027.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) ) SMP Wed Oct 26 10:25:23 EDT 2016

shruggy 04-23-2020 02:41 AM

Quote:

Originally Posted by techuser23 (Post 6114779)
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?

They are used by an old init system, SysVinit.

Quote:

2.If we accidentally delete them how to recover?
If you made a backup copy, restore from backup. If not
Code:

yum reinstall chkconfig initscripts
That will restore the minimal usable configuration. You should check then what services you are running:
Code:

ps -eHocomm|sed -E '1,/^init$/d;/^[ ]{3,}/d'|uniq
or just
Code:

pstree
and what packages they belong to:
Code:

rpm -qf $(rpm -qal|grep ^/etc/rc.d/init.d/.)|sort -u
Then reinstall the packages like shown above and reconfigure the services as needed.

Quote:

If we have the same files in other server can we copy and get the situation to normal?
If you have another identically installed server running all the same services you may copy the files from there. This will show which services are configured to start on boot:
Code:

chkconfig --list

michaelk 04-23-2020 03:18 AM

Welcome to LQ.

These are some of the basic questions where one thinks it could be homework, if not homework someone trolling and if totally serious why would you be messing around as root if not totally knowing what you are doing?

If really serious the impact is the server will not boot if off or shutdown if running. Call the administrator of the system or some one that knows what they are doing. As posted there are several ways to recovery. If those fail contact Red Hat.

ondoho 04-23-2020 06:24 AM

^ Never thought about that, except that it's a royal f***up to let that happen in any case. But we have seen those on LQ, people do mess up royally! Being root where they don't have to, it happens all the easier.

Anyhow, shruggy's answer is excellent!

dc.901 04-23-2020 06:52 AM

Quote:

Originally Posted by techuser23 (Post 6114779)
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?

If you do not know answer to your own questions above, you do not need to login as root!
As admin of ANY machine Linux/Windows/Mac, one of the basic things for admin duty is backup AND restore procedure. Hopefully you have that documented and tested?

If not, as mentioned, reinstall initscripts and figure out which services you need to reinstall.

Good luck, and perhaps, stop logging in as root.

shruggy 04-23-2020 10:24 AM

@OP I have another piece of advice for you. The first thing I always do on a newly installed system is installing and configuring etckeeper. On a RedHat-based distro that usually means enabling the EPEL repo first.* Thus, I always have a quick and easy way out of a situation like yours.
____
* Back in August 2019, when the EPEL repo for CentOS 8 was still pretty empty, I was forced to install rpmdevtools first and rebuild etckeeper from Fedora source.

techuser23 04-24-2020 12:03 AM

Thanks @Shruggy, We have a identical server which runs almost same services.
am not sure about what is installing of scripts if they already existed(before deleting). --> yum reinstall chkconfig initscripts
I am just a dumb jerky moron couldn't understand all those.. We have same files/folders in the other server..
Can we just copy them to the damaged system? (tried this, but all the links were missing don't know softlinlks/hardlinks/any other links)

1. Can we copy the folders or files (/etc/rc.d and /etc/rc0.d from another server) to get the situation normal?
2. How about the links that were not created automatically after copying the folders/files, is there any way to do them?
3. I understand that there will be no impact unless we do a reboot/restart of the server, am i right?
4. Let's say i copied the folders and created the links with your suggestions, are there any further checks to go ahead for a reboot which doesn't affect anything?
5. Please help with simple/complex steps or commands with clear mentions

Please help me @Shruggy @dc.901 @ondoho @michaelk or anyone.. please help!!!

shruggy 04-24-2020 02:00 AM

Quote:

Originally Posted by techuser23 (Post 6115185)
am not sure about what is installing of scripts if they already existed(before deleting). --> yum reinstall chkconfig initscripts

Since you deleted them they don't exist anymore. If you don't reinstall initscripts your system won't boot.

Quote:

We have same files/folders in the other server..
Can we just copy them to the damaged system? (tried this, but all the links were missing don't know softlinlks/hardlinks/any other links)
If you don't know what hardlinks/symlinks are then no, you shouldn't attempt this. First learn how to use tools that can copy directory hierarchies preserving links and permissions (rsync, tar, cpio, whatever).

Quote:

2. How about the links that were not created automatically after copying the folders/files, is there any way to do them?
See chkconfig(8), ntsysv(8) and system-config-services(8).
Quote:

3. I understand that there will be no impact unless we do a reboot/restart of the server, am i right?
Yes, you are right. BTW, don't try restarting/reloading any currently running service until you cleaned up this mess.

Quote:

4. Let's say i copied the folders and created the links with your suggestions, are there any further checks to go ahead for a reboot which doesn't affect anything?
Look, I know nothing about your system. How could I say? Were there init scripts put in /etc/init.d by other means than installing RPM packages? Or were they tweaked in any way after install? Was there something put into rc.local? And so on.

michaelk 04-24-2020 03:58 AM

Basically, all the init scripts for each installed service are in the init.d directory. When configured to run a link is created in the associated rcx.d according to the default settings within the script itself but can be changed via chkconfig.

How are you copying the files/links? If via some flash drive it needs to be using a Linux filesystem using cp -P or a tar file that preserves links. They can be copied over the network using the tools as suggested too.

Anyone else have knowledge of how the systems were configured?

techuser23 04-24-2020 07:14 AM

@michelk please guide me on how to copy these files from another server to local, and local to damaged server using FTP/Filezilla because both linux servers don't have connectivity.

Please help me with commands for preserving or copying files/folders with exactly same properties, file ownership, especially softlinks or symlinks and any other properties.

shruggy 04-24-2020 07:29 AM

I guess they are cloud servers, am I right?

techuser23 04-24-2020 11:44 AM

Yes @Shruggy, They are accessible through citrix only.

shruggy 04-25-2020 02:57 AM

1 Attachment(s)
Could you revert to a previously taken VM snapshot (see attachment)? You could also take another snapshot now to be able to go back to the current state.

ondoho 04-25-2020 04:05 AM

Quote:

Originally Posted by techuser23 (Post 6115318)
because both linux servers don't have connectivity.

Then you need physical access.
Or ask your provider to reset the machines - meaning you lose everything.

It seems you did not follow shruggy's advice, and, to make it worse, rebooted???

Lessen learned: make backups.


All times are GMT -5. The time now is 09:23 AM.