How to Configure sudo Command | root Give Some Permission to User

Sudo-super user do. Sudo permit to run some commands to the standard user. Sudo access is controlled by /etc/sudoers. Sudo to grand limited root privilege to a user.IN these case you must do the following things. First you have edited the file /etc/sudoers
So you must give the permission to 770 /etc/sudoers file
then edit. Because in the Linux some file like /etc/sudoers it is not have full permission for root. So change the permission through chmod command.

[root@studentwebsite ~]# cd /etc/
[root@studentwebsite etc]# chmod 700 sudoers
[root@studentwebsite etc]#vim /etc/sudoer
In these file
Add three lines in last
user1 ALL=/sbin/shutdown->user1 have privilege to shutdown the system
user2 ALL=/usr/sbin/useradd->user2 have privilege to create the new user
user2 ALL=/usr/bin/passwd ->user2 have privilege to set the password
...............................

...............................
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
## Allows members of the users group to mount and unmount the
## cdrom as root
# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
## Allows members of the users group to shutdown this system
# %users localhost=/sbin/shutdown -h now
user1 ALL=/sbin/shutdown
user2 ALL=/usr/sbin/useradd
user2 ALL=/usr/bin/passwd


After edit the file
run the command in user2
[user2@studentwebsite ~]# sudo /usr/sbin/useradd user22
sudo: /etc/sudoers is mode 0700, should be 0440
sudo command it will ask to change the permission 440 to the file /etc/sudoers
So change the file permission from 770 to 440
[user2@studentwebsite ~]# chmod 440 /etc/sudoers
[user2@studentwebsite ~]#sudo /usr/sbin/useradd user22
Then user22 has been successfully created by user2 and login to the user22
[user2@studentwebsite ~]# su user22
[user22@studentwebsite root]$

Related post