LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sudoers list (https://www.linuxquestions.org/questions/linux-newbie-8/sudoers-list-4175520455/)

prasan89na 09-29-2014 02:04 AM

Sudoers list
 
It would be a great help if someone help me to add my user in sudoers list. I have already created user using adduser command.

jdkaye 09-29-2014 02:08 AM

You need to edit your sudoers file in the appropriate way. You can find one explanation here. A quick search on the web will find you plenty of other explanations. You'll need to use visudo to do the job.
jdk

TenTenths 09-29-2014 02:12 AM

My preferred option is to use a group for this:

Code:

/usr/sbin/groupadd mysudoers
Then add the relevant user to the group
Code:

/usr/sbin/usermod -a -G mysudoers username
Then modify the sudoer file to allow this group to run any command add the following line with /usr/sbin/visudo

Code:

%mysudoers      ALL=(ALL)      ALL
Now that you've the group set up you can add or remove the user from the group accordingly.

Note that in this example the user will be able to execute ALL commands but will have to use their password to execute them.

prasan89na 09-29-2014 06:39 AM

How to add line with visudo
 
I tried to edit visudo using text editor like mc but failed. The output of
/usr/sbin/visudo
only displays the contents

TenTenths 09-29-2014 06:42 AM

running visudo lets you edit the file with "vi" commands, go read up on man visudo

Smokey_justme 09-29-2014 07:12 AM

Don't edit the file using visudo... You need to learn about vi and I remember my first passes at vi... I broke the script I tried to edit :P

use one of these commands (as root):
Code:

mcedit /etc/sudoers
pico /etc/sudoers

or any other text editor you feel like using (but I don't know any editors more "user-friendly" in cli)

Just make sure you understand what you need to add and don't go for the no password option...

P.S. Just in case you are curious what's all the fuss about vi/vim.. type
Code:

vimtutor
in a terminal emulator when you have some spare time ;) The worst case scenario, you just learn something new ..

JeremyBoden 09-29-2014 09:04 AM

nano is my favourite simple editor.

TenTenths 09-29-2014 09:06 AM

Quote:

Originally Posted by JeremyBoden (Post 5246294)
nano is my favourite simple editor.

+1 :)

btmiller 09-29-2014 07:45 PM

You can use any editor you like with visudo using the EDITOR environment variable, e.g.:

Code:

EDITOR=nano visudo
Will replace vi with nano when visudo is run.

EDDY1 09-29-2014 11:25 PM

Just typing visudo as root takes you directly to /etc/sudoers at 1 time in debian it was almost like using vim but now when I use it the interface is almost the sam as nano.

evo2 09-29-2014 11:34 PM

Hi,
Quote:

Originally Posted by Smokey_justme (Post 5246242)
Don't edit the file using visudo... You need to learn about vi and I remember my first passes at vi... I broke the script I tried to edit :P

use one of these commands (as root):
Code:

mcedit /etc/sudoers
pico /etc/sudoers


Do not do this. visudo will make sure the file is locked correctly and check for syntax errors. If you don't like the default editor used by visudo, then set your EDITOR environment variable to an editor that you do like.

Evo2.

JeremyBoden 09-30-2014 06:44 AM

So doing the following
Quote:

Originally Posted by btmiller (Post 5246593)
You can use any editor you like with visudo using the EDITOR environment variable, e.g.:
Code:

EDITOR=nano visudo

followed by
Code:

sudo visudo
will give you a better visudo experience.:)

Germany_chris 09-30-2014 07:35 AM

nano /etc/sudoers

or add yourself to the wheel group and uncomment wheel

evo2 09-30-2014 07:11 PM

Hi,
Quote:

Originally Posted by Germany_chris (Post 5246870)
nano /etc/sudoers

visudo, vipw and vigr exist for a reason. Feel free to ignore them at your own risk, but don't encourage others to do the same.

Quote:

Originally Posted by Germany_chris (Post 5246870)
or add yourself to the wheel group and uncomment wheel

OP has not stated what distro this is on so there is every chance the that wheel group doesn't even exist on this system.

Please be careful when offering advice.

Evo2.

Smokey_justme 09-30-2014 10:21 PM

@evo: I actually never knew (or never took to much care to notice) that the EDITOR variable existed.. Thanks..


All times are GMT -5. The time now is 10:14 PM.