DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Wednesday, March 23, 2016

How to restore default system permissions on Red Hat, CentOs, Fedora

I recently changed the file permission of root (/) directories to 777(recursively).
While I start my OS it does not shows any login screen.
 
The rpm has a parameter called --setperms and --setugids. Using this we can recover our Operating System


  1. Boot/reboot machine
  2. At blue RedHat screen press any key to enter the boot loader
  3. Press 'e' to edit the most recent boot command
  4. Use the arrow keys to select the line that starts with "kernel"
  5. Press 'e' to edit the kernel command
  6. Append 'S' to the end of the line. There should be a space before the previous end of the line (probably 'quiet') and the 'S'. Capitalization matters.
  7. Hit Enter to commit the change
  8. Hit 'b' to boot
Enter this in the root prompt.

 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







Done!! 

No comments: