Sharing Ilmu

Sharing for useful things

How To Configuration sudo access for regular user (Interactive root shell) in Linux system

When you use linux system and you have user or new user, sometimes you need to run command that’s need to root permissions or you need to access root. Usually you can use sudo at first command and sudo -i  to move from regular user to root.

But when you try to access with sudo command and appears error like this :

user1@taufik:~$ sudo apt update
[sudo] password for user1:
user1 is not in the sudoers file. This incident will be reported.
user1@taufik:~$ sudo -i
[sudo] password for user1:
user1 is not in the sudoers file. This incident will be reported.

It means user1 is doesn’t access to sudo. To gaining sudoers access you need to add configuration on /etc/sudoers.d/

for example we need to enable sudo access to user1. Add new configuration on /etc/sudoers.d/user1 :

root@taufik:~# nano /etc/sudoers.d/user1

Then add the following script on the configuration :

user1 ALL=(ALL) ALL

 

Try it again :

user1@taufik:~$ sudo -i
[sudo] password for user1: entertheuserpassword
root@taufik:~#

 

In the preceding configuration you’re configure sudo access for user. But how if you need to enable sudo access for group ? do the configuration like this :

root@taufik:~# nano /etc/sudoers.d/groupname

then add the following script on the configuration :

%groupname ALL=(ALL) ALL

 

If you need to enable sudo access on user that the user is can run command as another user without entering their password. do the configuration like this :

root@taufik:~# nano /etc/sudoers.d/youruser

Then add the following script on the configuration :

youruser ALL=(ALL) NOPASSWD:ALL

 

 

z

Leave a Reply

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

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>