Avatar of Maxwellb
Maxwellb
 asked on

I just Chowned entire server

Instead of causing the ownership of the current folder and its subfolders to change, I changed ownership on every file on the server...

Command issued: chown -hR <username> /*

Now, everything belongs to that particular user. I known there is probably know way to reverse this... would issuing "chown -hR root /* solve this problem or would it just change everything to root and leave apache etc broken?

Any suggestions much appreciated!

Thanks,
-Max
LinuxLinux Distributions

Avatar of undefined
Last Comment
Kerem ERSOY

8/22/2022 - Mon
Maxwellb

ASKER
Would something like this work:

for p in $(rpm -qa); do rpm --setperms $p; done
for p in $(rpm -qa); do rpm --setugids $p; done

(http://www.cyberciti.biz/tips/reset-rhel-centos-fedora-package-file-permission.html)

ASKER CERTIFIED SOLUTION
omarfarid

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Maxwellb

ASKER
Is there any way I am going to be able to pull any files off this machine since last backup? Right now I can't even ping... ("Operation now allowed")

Thanks!
-Max
omarfarid

how backup was taken? Is it on a local tape drive?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Tintin

The answer to fix your problem depends on what Linux distribution you are running.
rionroc

Hello

Try to boot in console safe-mode.
Login to the user you have pointed for chown.
chown again to root.

:)
rionroc
Julian Parker

you may need to boot from rescue media, the last time I did this I managed to use rpm as you showed above to fix the problem but that was caught before I rebooted the system.

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rionroc

Yes,  Master jools is correct too, you have to boot the Linux Installer, then select rescue, when your in the console, chown all to root, and when booting back to Linux, chown again to different users you want too, the important thing is your back on the system.
SOLUTION
Duncan Roe

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Hugh Fraser

You could also look at booting a standalone system off a USB (something like Backtrack, for instance) to give you a running system with a writeable media (the USB stick). You'll be able to mount the volumes and change the ownerships, or copy files to the USB stick if you opt for a clean install.

A quick scan of one of my systems shows that the amount of work required to undo the chown command would be considerable, especially if you've added custom apps afterwards that are creating their own user/groups and have files in various directories.
Duncan Roe

Yes I did mention you would have a lot of work in front of you...
The bootable USB stick I have experience of had very little spare capacity, and I imagine this would be typical.
Trouble is, the stick is created by a dd copy of the boot image, which makes it look to only a few spare Mb, regardless of stick size. But USB is a good idea - you can plug in a second USB stick and copy files to that. Also the boot stick will likely get you a network back, which is a little effort with init=/bin/bash (but only a little)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SOLUTION
Kerem ERSOY

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
stephenhoekstra

Hi,

Only sure way is to reinstall or restore from backup (but who backs up their ENTIRE system anyway?).  Chown'ing everything to root is not a solution!  

Boot off a livecd and either mount a network share or external device and backup your data (/home, /var/www, /etc) and reinstall.  It'll be quicker than fixing everything you break by chowning and it's the proper way to do it.
Duncan Roe

I submit that the proposed accepted solution is not the best one and suggest another.
The asker posted in http:#23791929 "Is there any way I am going to be able to pull any files off this machine since last backup?" I provided a methodology for that in http:#23793445 and subsequent discussion.
"Restore from backup" is an easy one-liner that many of us use in response to a question like this one. It's shorthand for "doing anything else is going to take you more time than you'll care to spend". But in response to the specific question of rescuing recent files (e.g. before restoring from backup) then the method I posted can be used.
Suggest equal split omarfarid http:#23791839 and duncan_roe http:#23793445
omarfarid

hi duncan_roe

we are all professional here, and myself don't like long stories while providing a solution unless asker needs explanation. my comment was:

"I would suggest to restore from backup or backup your important files and reinstall"

Also, author commented that:

"Is there any way I am going to be able to pull any files off this machine since last backup? Right now I can't even ping..."

so quick network file transfer was not even possible.

Thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Kerem ERSOY

Hi,

The question was clearly abandoned by the asker. This behaviour is not only kind of rude it is against the asking questions ethics here. The question must be cleared somehow. Should the author participated it would have been different.

For the sake of clearing the mess here I agree with the rindi's decission. Although I'd suggest a similar suggestion with omerfarid. It is clear that he was the first to do so. Would duncan_roe's solution or some other persons solution would work?  We will never learn about it. Issues of this nature will always be forced accept by cleanup volunteers. I admire them. I won't object the cleanup volunteers suggestion to let them do their job. We can think that this is unjust at times and there's still a great possibility that it is so. But things had happened like that before and will happen in the future. We're all here long enough to know that we sometimes get some points that we don't really deserve. But sometimes we've never been awarded some points we should get to the last point I have some outstanding questions that goes-on which I proposed the correct solution at the first response yet the asker is still struggling not to do as I suggested or to modify some I've suggested or simple can not successfully execute single cp command after 95 notes that I'm warnig them against doing so).

Omerfarid will get the points this time. But it is clear that it will not be a question that he'll be proud of himself to answer it (though I still think that it is a valid and accurate answer not to mention he did this first). I prefer to accept the Cleanup volunteer' s suggestion and suggest the same for all the participants.

Cheers,
K.