LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 04-23-2020, 02:05 AM   #1
techuser23
LQ Newbie
 
Registered: Apr 2020
Posts: 4

Rep: Reputation: Disabled
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
 
Old 04-23-2020, 02:41 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by techuser23 View Post
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

Last edited by shruggy; 04-23-2020 at 04:02 AM.
 
2 members found this post helpful.
Old 04-23-2020, 03:18 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,740

Rep: Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922
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.
 
Old 04-23-2020, 06:24 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ 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!
 
1 members found this post helpful.
Old 04-23-2020, 06:52 AM   #5
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
Originally Posted by techuser23 View Post
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.
 
Old 04-23-2020, 10:24 AM   #6
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
@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.
 
1 members found this post helpful.
Old 04-24-2020, 12:03 AM   #7
techuser23
LQ Newbie
 
Registered: Apr 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
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!!!
 
Old 04-24-2020, 02:00 AM   #8
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by techuser23 View Post
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.

Last edited by shruggy; 04-24-2020 at 02:18 AM.
 
Old 04-24-2020, 03:58 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,740

Rep: Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922Reputation: 5922
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?
 
Old 04-24-2020, 07:14 AM   #10
techuser23
LQ Newbie
 
Registered: Apr 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
@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.
 
Old 04-24-2020, 07:29 AM   #11
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
I guess they are cloud servers, am I right?
 
Old 04-24-2020, 11:44 AM   #12
techuser23
LQ Newbie
 
Registered: Apr 2020
Posts: 4

Original Poster
Rep: Reputation: Disabled
Yes @Shruggy, They are accessible through citrix only.
 
Old 04-25-2020, 02:57 AM   #13
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
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.
Attached Thumbnails
Click image for larger version

Name:	citrix-snapshots.png
Views:	25
Size:	9.9 KB
ID:	33080  

Last edited by shruggy; 04-25-2020 at 04:06 AM.
 
Old 04-25-2020, 04:05 AM   #14
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by techuser23 View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Oops, I accidentally deleted my NTFS partition!!! How to recover? WindowBreaker Linux - Newbie 1 07-03-2009 07:28 PM
I have deleted a folder accidentally? How do I recover it? srikanth_dhondi Linux - Software 2 02-19-2008 06:38 PM
How to recover libc.so.6 file if it's deleted accidentally? tebet11@yahoo.com Linux - Distributions 4 12-25-2006 08:13 PM
LXer: Open Source Impact on Software Innovation Outweighs Impact on ... LXer Syndicated Linux News 0 08-15-2006 01:54 PM
accidentally deleted some files and I don't know what I need to do to get them back Michele Linux - Newbie 2 06-26-2004 05:42 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 10:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration