LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-27-2011, 08:02 AM   #1
george-lappies
Member
 
Registered: May 2011
Location: Secunda, South Africa
Distribution: Slackware 13.37
Posts: 181

Rep: Reputation: 9
Question How do I add a user to be able to sudo?


How do I add a user to be able to sudo?
 
Old 05-27-2011, 08:05 AM   #2
coolsreejith
LQ Newbie
 
Registered: Oct 2010
Distribution: CentOS 5.5
Posts: 23

Rep: Reputation: 2
iam not sure about Slackware but in rhel it is by the command visudo
 
1 members found this post helpful.
Old 05-27-2011, 08:06 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
You have to add the user to the /etc/sudoers file, using visudo.
For more information have a look at
Code:
man visudo
man sudoers
 
1 members found this post helpful.
Old 05-27-2011, 08:07 AM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Have you read the manual or searched the web? It would be quicker than waiting for a reply, and you would learn something.

http://www.gratisoft.us/sudo/sudoers.man.html
http://www.syntaxtechnology.com/2009/06/sudo-tutorial/

Summary:
1. As root, run "visudo" to edit the sudoers file
2. Add a line for the user you want. Most people just do "username ALL=(ALL) ALL" but some would argue this is not what sudo is meant for.
3. Save and quit
 
1 members found this post helpful.
Old 05-27-2011, 01:07 PM   #5
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
As mentioned, the normal way is to use the /usr/sbin/visudo command.

Technically you do not have to use visudo, but the /etc/sudoers file normally has 440 permissions. To manually edit sudoers without visudo requires manually changing the permissions, edit the file, hope you do not make any silly editing mistakes, and then reset the permissions. Do know that sudo complains if the permissions of /etc/sudoers is not 440.

Thus the basic advice is just use visudo. As you can guess from the command name, the default editor that is used is vi. Elvis is the default vi in the stock Slackware. Fortunately, the stock Slackware build script uses the --with-env-editor build option. If you set the EDITOR or VISUAL environment variable to your preferred console text editor, then you will not be forced to use vi to edit the /etc/sudoers list. I use mcedit.
 
Old 05-27-2011, 01:47 PM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by Woodsman View Post
If you set the EDITOR or VISUAL environment variable to your preferred console text editor, then you will not be forced to use vi to edit the /etc/sudoers list.
Like this:

Code:
EDITOR=your-favorite-editor visudo
visudo is not the only command that relies on the EDITOR variable. You can add this line to your ~/.bashrc if you want your editor setting to stay:

Code:
export EDITOR=your-favorite-editor
I'm not sure if you have to specify the full path or just the name. I'd put in the full path, just to be safe.

Last edited by MTK358; 05-27-2011 at 01:50 PM.
 
Old 05-27-2011, 03:03 PM   #7
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
After you have added your user account you might want to update your user's $PATH to include /sbin and /usr/sbin so that you don't have to type the full path for admin commands when running them with sudo
 
Old 05-27-2011, 04:40 PM   #8
samac
Senior Member
 
Registered: Mar 2004
Location: Kirkwall, Orkney
Distribution: Linux Mint 20.3 - Cinnamon
Posts: 1,425

Rep: Reputation: 139Reputation: 139
Or you could forget all about sudo and use su or su -, just add your user to the wheel group.

samac
 
3 members found this post helpful.
Old 05-27-2011, 08:43 PM   #9
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
The more sophisticated /etc/sudoers file than:

Code:
username ALL=(ALL) ALL
would be:

Code:
Defaults    timestamp_timeout = 0

User_Alias  FULL = john
User_Alias  PART = mary

Cmnd_Alias  KILL = /bin/kill, /bin/killall
Cmnd_Alias  HALT = /sbin/reboot, /sbin/halt, \
                   /usr/local/bin/suspend
Cmnd_Alias  MOUNT = /bin/mount, /bin/umount

root ALL =  (ALL) ALL

FULL ALL =  NOPASSWD: KILL, HALT, MOUNT

PART ALL =  PASSWD:   KILL, HALT, \
            NOPASSWD: MOUNT
As you can see in this case user john has full access to all commands while user mary has restricted access to kill, killall, reboot, halt commands and suspend script (she have to confirm these commands using her password).
 
Old 05-28-2011, 03:06 AM   #10
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 231Reputation: 231Reputation: 231
As Samac suggested just use "su -" and worry about sudo later... (if you still feel you need it)

Sudo is primarily aimed at giving certain users fine grained permissions to do certain tasks as root (with or without giving away the root password).

Ubuntu and friends totally bastardised/mis-used it making it seem to be the be-all and end-all of user safety/security.
 
4 members found this post helpful.
Old 05-28-2011, 04:53 AM   #11
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,900

Rep: Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023Reputation: 5023
Quote:
Originally Posted by samac View Post
Or you could forget all about sudo and use su or su -, just add your user to the wheel group.
No requirement to be a member of the wheel group unless you've locked it down in login.defs
 
2 members found this post helpful.
Old 05-28-2011, 05:13 AM   #12
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Quote:
Originally Posted by mRgOBLIN View Post
Ubuntu and friends totally bastardised/mis-used it making it seem to be the be-all and end-all of user safety/security.
Indeed, I have said this elsewhere but I think it is worth repeating here. For a home desktop/laptop set-up in particular, where typically only one person admins the machine there is no real advantage to sudo.

Consider if I wanted to run the fake command 'example' once as a root user. Here is what I would actually have to type (where $password is my actual password).

Using su:
su[Enter]$password[Enter]example[Enter][Ctrl]+d
(Note: That is '[Ctrl]' and 'd' together to exit the root session, you obviously aren't typing the '+' character)

Using sudo:
sudo[space]example[Enter]$password[Enter]

Ignoring the characters needed that are the same in both cases (i.e. 'example' followed by [Enter] and your password followed by [Enter]), you have to type 5 key presses to execute a single command as root via 'su' (s u [Enter] [Ctrl] d) and 5 key presses to execute a single command as root via 'sudo' (s u d o [space]). Or to put it another way, you save nothing using sudo.

If however you wanted to type two or more commands as root, you immediately start saving on the key presses by using 'su' instead of 'sudo'. Yes the second 'sudo' command does not require a password but as long as you have not closed your root session yet (i.e. no Ctrl+d) you don't have to type your password again with 'su' either and you save having to write 'sudo' for every single line.

There is also the point that outside of distros where 'sudo' is preconfigured (e.g. Ubuntu and derivatives) you save time configuring '/etc/sudoers' and setting up various admin variables for your regular user.

Indeed the other nice thing with using 'su' is that you can just open a root terminal for all your admin needs and you decide if and when you should close it, rather than relying on preconfigured time-out periods with 'sudo'.
 
2 members found this post helpful.
Old 05-28-2011, 05:37 AM   #13
george-lappies
Member
 
Registered: May 2011
Location: Secunda, South Africa
Distribution: Slackware 13.37
Posts: 181

Original Poster
Rep: Reputation: 9
Thanks all for the great responses. After some more reading I will be sticking with 'su -l' for now
 
Old 05-28-2011, 06:10 AM   #14
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
This is what I added to my sudoers file:
Code:
psionl0    ALL=(ALL) NOPASSWD:/sbin/shutdown
This allows me to shut down my pc via the fluxbox menu without giving me permission to use any other root commands.
For all other root functions, I use "su".
 
Old 05-28-2011, 06:52 AM   #15
samac
Senior Member
 
Registered: Mar 2004
Location: Kirkwall, Orkney
Distribution: Linux Mint 20.3 - Cinnamon
Posts: 1,425

Rep: Reputation: 139Reputation: 139
Quote:
No requirement to be a member of the wheel group unless you've locked it down in login.defs
When did that change? It was set to yes in Slackware 10, so I've just kept adding myself to the wheel group.

samac
 
  


Reply



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] "sudo: Can't mkdir /var/run/sudo/%user%: File exists" CNBarnes Linux - Server 7 01-10-2011 04:11 PM
add 'sudo-ed' command on startup qrange Debian 1 09-21-2010 02:05 AM
How to add SUDO access? Arty Ziff Linux - Newbie 11 07-15-2010 01:33 AM
unchecked link between pc user and sudo user on Mint5 how do I get it back,stop laugh Fred Caro Linux - Newbie 2 04-22-2009 08:36 PM
Gconf-editor settings not sticking for root, sudo user, or user when run sandaili Fedora 1 07-19-2008 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:06 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