Often permissions are lost on accidentally running the command on Linux System (RPM- Based),
This blog will guide you to restore the permissions back to the original state.
Let’s begin the fun !!!
1. Type the below command on your test VM
#chmod -R 777 /
2. Now check the permission for / file system.
User may encounter the following issues on running #chmod 777 / command:
1. SSH Service will not start as shown in the below screenshot:
2. Users wont be able to switch accounts even after having root privileges.
3. Users would not be able to login via SSH.
4. SUID will be revoked from the files and binaries.
Run the below two commands to restore the permissions of all files and directories. Ignore the permission denied error and can’t access error, which may occur while running the below command.
#rpm --setugids -a
#rpm --setperms -a
The options used here are --setugids, --setperms and -a
--setperms – sets permissions of files in the given package.
--setugids – user/group ownership of files in the given package.
-a – While we using -a or –all it applied for all installed RPM packages.
Refer man page using below command:
To reset permission on the whole / directory, one can use the following commands:
#for package in $(rpm -qa); do rpm --setperms $package; done
#for package in $(rpm -qa); do rpm --setugids $package; done
The RPM package installed in the system creates its own RPM database which holds the information such as file sizes, md5sums of files, ownership, permissions, and more. Hence this is the reason a user can restore the file ownership and permissions.
Subscribe to get latest updates