restore default system permissions on Red Hat, CentOs, Fedora accidentally used chmod 777 /

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

I recently came across a system which had some directories set to 777(recursively), the sysadmin needed to install an application and changed all the permissions!!!! a mess, I didn't know where to start, but one of my colleagues pointed that rpm has a parameter called --setperms and --setugids.

I created a one 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








# ll /etc/ssh/
# chmod 600 /etc/ssh/ssh_host_rsa_key
# chmod 600 /etc/ssh/ssh_host_dsa_key
# service sshd restart


Comments

Popular posts from this blog

[SOLVED]* Please wait for the system Event Notification service

Rebuild the initial ramdisk image in Red Hat Enterprise Linux

Python reference Interview questions