1

I accidentally changed the ownership of several files including system files in our Centos 7 server due to a syntax error. I was trying to change it for a particular folder, but missed the . and ended up executing \. Now I can't even remote login to the machine through Putty/Cygwin. It says Connection disconnected. Is the server hosed or is there a way to restore the default permissions to atleast system files so I can login and go from there?

So far from my research I think I'm out of luck. Any tips?

Also, is there a way to copy files from the hard disk if it can't be restored like connecting it as slave in Windows machine?

3
  • Starting from the end, Windows does not support any of the file systems typically used in Unux/Linux. And the attempts to restore the default file permissions have to be done locally.
    – user772515
    Commented Jan 30, 2018 at 2:01
  • I can login to the machine, seems like its not fully corrupted. But cant remote login using Putty/Cygwin. Tried reassigning ssh/sysconfig folders and sub folders groups back to root but still no luck. What else could be missing that prohibits the remote connection?
    – yonikawa
    Commented Jan 30, 2018 at 15:48
  • I think I fixed it. Ended up reinstalling the openssh as the host key files were having issues. Now it connects through putty/cygwin.
    – yonikawa
    Commented Jan 30, 2018 at 19:14

2 Answers 2

1

Consider this link http://www.adminlinux.org/2009/07/how-to-restore-default-system.html ne liner that does the job, it takes time but It works !!!!!

  1. To reset uids and gids on files and directories: for u in $(rpm -qa); do rpm --setugids $u; done

  2. To permissions on files and directories: for p in $(rpm -qa); do rpm --setperms $p; done

0

You can boot off a live CD, mount the filesystem to a mount point, chroot into it, and restore rpm file permissions with rpm --setperms {packagename}

oooor, you can reinstall :-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .