How to restrict a user to run only two commands in sudoers

Restrict a user “pooja” to run only two root commands.

This task is very simple, just modify the previous permissions assign to pooja.

Let’s give pooja to run only #fdisk and #parted command access.

First check the complete path of those command by using following command

  • # which fdisk
  • # which parted

 

Lets assign both above paths in sudoers file.

# visudo

  • Login as a pooja and try assigned commands and other commands as well

 

Note : Try the same commands for group also. It is exactly same.

How to allow any group or user to run only network related commands as sudo user in Linux.

To allow a group run only network commands, first uncomment the following line.

 

Observe that you have just remove # before the line to make the line readable and also observe that it contains all networking commands.

Just replace “ALL” with “NETWORKING” from the last field of group line.

 

Note: NETWORKING is the name of the command alias where uncommented the line.

  • Now login as one of the member of rp group and try some commands assigned it.

 

I Hope You enjoyed reading this article…

Leave a Reply

Your email address will not be published. Required fields are marked *