How to give normal user root privileges using sudo in Linux/Unix
In this post I will be very brief on the topic we need to do. As for more knowledge on sudo command and sudoers file follow the below link
How to give permission to user to run some commands in Linux
As per my knowledge there are two methods to do the same. I have tested these commands and methods in Red Hat Linux.
Method 1
# visudo
Add an extra line in the last and make this entry
deepak ALL=(ALL) ALL
Using this above line you are telling your Linux box to give full permission for user deepak on all the hosts and all the commands
[deepak@test ~]$ sudo /etc/init.d/network restart
[sudo] password for test:
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
[ OK ]
Method 2
Add the user to wheel group
# usermod -G wheel deepak
Verify the same
# cat /etc/group | grep wheel
wheel:x:10:root,deepak
Now uncomment this line from sudoers file
# visudo
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
The reason we did this because be default root is a member of wheel group so in case you want to give root level permission to any normal user then add him/her in wheel group.
$ sudo /etc/init.d/vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
Add an extra line in the last and make this entry
deepak ALL=(ALL) ALL
[sudo] password for test:
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
[ OK ]
wheel:x:10:root,deepak
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
No comments:
Post a Comment