LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-29-2014, 02:04 AM   #1
prasan89na
LQ Newbie
 
Registered: Sep 2014
Posts: 12

Rep: Reputation: Disabled
Smile 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.
 
Old 09-29-2014, 02:08 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
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

Last edited by jdkaye; 10-01-2014 at 01:19 AM.
 
Old 09-29-2014, 02:12 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,469

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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.
 
Old 09-29-2014, 06:39 AM   #4
prasan89na
LQ Newbie
 
Registered: Sep 2014
Posts: 12

Original Poster
Rep: Reputation: Disabled
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
 
Old 09-29-2014, 06:42 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,469

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
running visudo lets you edit the file with "vi" commands, go read up on man visudo
 
Old 09-29-2014, 07:12 AM   #6
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
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 ..

Last edited by Smokey_justme; 09-29-2014 at 07:15 AM.
 
Old 09-29-2014, 09:04 AM   #7
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
nano is my favourite simple editor.
 
Old 09-29-2014, 09:06 AM   #8
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,469

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by JeremyBoden View Post
nano is my favourite simple editor.
+1
 
Old 09-29-2014, 07:45 PM   #9
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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.
 
1 members found this post helpful.
Old 09-29-2014, 11:25 PM   #10
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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.
 
1 members found this post helpful.
Old 09-29-2014, 11:34 PM   #11
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by Smokey_justme View Post
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.
 
Old 09-30-2014, 06:44 AM   #12
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
So doing the following
Quote:
Originally Posted by btmiller View Post
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.
 
Old 09-30-2014, 07:35 AM   #13
Germany_chris
Senior Member
 
Registered: Jun 2011
Location: NOVA
Distribution: Debian 12
Posts: 1,071

Rep: Reputation: 497Reputation: 497Reputation: 497Reputation: 497Reputation: 497
nano /etc/sudoers

or add yourself to the wheel group and uncomment wheel
 
Old 09-30-2014, 07:11 PM   #14
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by Germany_chris View Post
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 View Post
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.
 
Old 09-30-2014, 10:21 PM   #15
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] removed myself from sudoers list faizlo Linux - Newbie 6 12-16-2011 10:40 AM
[SOLVED] sudoers list citi Linux - Newbie 15 01-27-2011 09:03 PM
sudoers question about cmnd_alias/list and directories. trey85stang Linux - General 2 12-02-2010 03:59 PM
How do I add myself to the sudoers list? Cultist Debian 6 07-26-2010 06:31 PM
sudoers list Pedroski Fedora 4 11-06-2009 10:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration