How to restore permissions and ownerships for system files and folders to default?

Created:

2016-11-16 12:38:52 UTC

Modified:

2017-05-21 22:02:23 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to restore permissions and ownerships for system files and folders to default?

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk 10.x and below for Linux

Symptoms

Accidentally chown and chmod commands were run on system directories like /var , /root , /etc . How to restore correct system files permissions and ownerships?

Resolution

Permissions can be reset to their defaults using the following commands:

RedHat-like distributions

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

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:

Forum #115523

Forum #109342

Additional Information

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:

/usr/local/psa/version
/etc/psa/.psa.shadow
/usr/local/psa/admin/sbin/

You can also verify the correctness of the ownerships you have reset by comparing them with those on a working server.

Have more questions? Submit a request
Please sign in to leave a comment.