Linux – How to make a non-root user to use chown for any user group files

linuxpermissionsroot

I would like to make a user super powerful, with almost all root rights but unable to touch a the root user (to change the password of the root).

My goal is to user "B" to manage my web server. The problem is user B need to able to run the chown and chmod commands on some files belonging to other users.

I tried to put B in root group or use visudo, but it's not enough.

I'm working an Centos 6 system.

If some body have ideas!

Best Answer

You best bet is to use an appropriately configured /etc/sudoers file.

If you want bob to be able to change the permissions and owners on the files of users fred, joe and sara, put this in your sudoers file. With this line, bob will need to use e.g. sudo -u fred chmod ... to change the permissions on fred's files.

Runas_Alias  USERS = fred, joe, sara
bob          ALL = (USERS): /bin/chmod, /bin/chown
Related Question