Jacques Duplessis
by Jacques Duplessis
1 min read

Categories

Tags

Print Friendly and PDF


Did you know that you can reset file permission to what they were when you installed the package. This may become helpful if somebody made a mistake and change the permission on a number of files (This never happen right).

This is where the command “rpm –setperms ” become handy.

In our example we will change the permission on the “find” command.
Let’s find out what package contains the “/usr/bin/find” command.

# rpm -qf /usr/bin/find
findutils-4.2.27-5.el5

Let’s see what are the actual permission of the find program (755).

# ls -l /usr/bin/find
-rwxr-xr-x 1 root root 151244 Jul  7  2008 /usr/bin/find

Let’s change them to 777 with the chmod command

# chmod 777 /usr/bin/find

Now the program “find” have this permission.

# ls -l /usr/bin/find
-rwxrwxrwx 1 root root 151244 Jul  7  2008 /usr/bin/find

Let’s run our command to reset all files included in the package “findutils”.

# rpm --setperms findutils

You can see now that the permission of the ‘find’ are back to their initial state.

# ls -l /usr/bin/find
-rwxr-xr-x 1 root root 151244 Jul  7  2008 /usr/bin/find

Be aware that this command only reset the permission and not the owner/group of the file, as you can see from the example below.

# ls -l /usr/bin/find
-rwxr-xr-x 1 root root 151244 Jul  7  2008 /usr/bin/find
# chmod 777 /usr/bin/find
# chown jacques.jacques /usr/bin/find
# ls -l /usr/bin/find
-rwxrwxrwx 1 jacques jacques 151244 Jul  7  2008 /usr/bin/find
# rpm --setperms findutils
# ls -l /usr/bin/find
-rwxr-xr-x 1 jacques jacques 151244 Jul  7  2008 /usr/bin/find