- Plesk for Linux
Accidentally chown and chmod commands were run on system directories like
/var, /root, /etc. How to restore correct system files permissions and ownerships?
Permissions can be reset to their defaults using the following commands being connected to the server via SSH:
# for p in $(rpm -qa); do rpm --setugids $p; done
# for p in $(rpm -qa); do rpm --setperms $p; done
# chown root.psaadm /usr/local/psa/admin/sbin/mod_wrapper
Note: The order in which you execute the commands is important. When changing permissions and ownerships on files, always change the ownerships first, and then the permissions. Otherwise, if the files have a SUID bit set, for example, the bit set may get cleared.
See these forum threads for further reference:
In some cases, even after running the above commands, the ownerships for some files or folders may still be incorrect. Make sure you check these lists:
You can also verify the correctness of the ownerships you have reset by comparing them with those on a working server.