View previous topic :: View next topic |
Author |
Message |
padoor Advocate


Joined: 30 Dec 2005 Posts: 4185 Location: india
|
Posted: Thu Feb 24, 2011 2:18 am Post subject: how to add user to sudoers file?[solved] |
|
|
Code: | ramaswamy@localhost ~ $ sudo
usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u user
name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g
groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file
...
ramaswamy@localhost ~ $ sudoer
-bash: sudoer: command not found
ramaswamy@localhost ~ $ groups
wheel audio cdrom video usb users plugdev portage ramaswamy
ramaswamy@localhost ~ $ sudo gtk-cpuspeedy
Password:
ramaswamy is not in the sudoers file. This incident will be reported.
ramaswamy@localhost ~ $ su
Password:
localhost ramaswamy # nano -w /etc/sudoers
localhost ramaswamy #
localhost ramaswamy # cat /etc/sudoers
## sudoers file.
##
## This file MUST be edited with the 'visudo' command as root.
## Failure to use 'visudo' may result in syntax or file permission errors
## that prevent sudo from running.
##
## See the sudoers man page for the details on how to write a sudoers file.
##
##
## Host alias specification
##
## Groups of machines. These may include host names (optionally with wildcards),
## IP addresses, network numbers or netgroups.
# Host_Alias WEBSERVERS = www1, www2, www3
##
## User alias specification
##
## Groups of users. These may consist of user names, uids, Unix groups,
## or netgroups.
# User_Alias ADMINS = millert, dowdy, mikef
##
## Cmnd alias specification
##
## Groups of commands. Often used to group related commands together.
# Cmnd_Alias PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \
# /usr/bin/pkill, /usr/bin/top
##
## Defaults specification
##
## You may wish to keep some of the following environment variables
## when running commands via sudo.
##
## Locale settings
# Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET"
##
## Run X applications through sudo; HOME is used to find the
## .Xauthority file. Note that other programs use HOME to find
## configuration files and this may lead to privilege escalation!
# Defaults env_keep += "HOME"
##
## X11 resource path settings
# Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH"
##
## Desktop path settings
# Defaults env_keep += "QTDIR KDEDIR"
##
## Allow sudo-run commands to inherit the callers' ConsoleKit session
# Defaults env_keep += "XDG_SESSION_COOKIE"
##
## Uncomment to enable special input methods. Care should be taken as
## this may allow users to subvert the command being run via sudo.
# Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER"
##
## Uncomment to enable logging of a command's output, except for
## sudoreplay and reboot. Use sudoreplay to play back logged sessions.
# Defaults log_output
# Defaults!/usr/bin/sudoreplay !log_output
# Defaults!/usr/local/bin/sudoreplay !log_output
# Defaults!/sbin/reboot !log_output
##
## Runas alias specification
##
##
## User privilege specification
##
root ALL=(ALL) ALL
## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL
## Uncomment to allow any user to run sudo if they know the password
## of the user they are running the command as (root by default).
# Defaults targetpw # Ask for the password of the target user
# ALL ALL=(ALL) ALL # WARNING: only use this together with 'Defaults targetpw'
## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir /etc/sudoers.d
localhost ramaswamy #
|
i cannot run any command as root using sudo including porthole, emerge, any command for the example
how can i overcome this limitation
i always get same error _________________ reach out a little bit more to catch it (DON'T BELIEVE the advocate part under my user name)
Last edited by padoor on Thu Feb 24, 2011 2:32 am; edited 1 time in total |
|
Back to top |
|
 |
mikegpitt Advocate


Joined: 22 May 2004 Posts: 3224
|
Posted: Thu Feb 24, 2011 2:24 am Post subject: |
|
|
This part is the key:
Code: | ## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL
|
Uncomment that line and add your user to the wheel group. Although your comment puzzles me a bit, since root doesn't need sudo to execute commands with privilege. You also will only want to run things like emerge as root. I'm not sure if there would be bad consequences if you ran emerges as a regular user with sudo. |
|
Back to top |
|
 |
dol-sen Retired Dev


Joined: 30 Jun 2002 Posts: 2805 Location: Richmond, BC, Canada
|
Posted: Thu Feb 24, 2011 2:25 am Post subject: |
|
|
you can edit the sudoers file. The best way is to use the command visudo as root in a terminal.
move down and uncomment teh ones you want enabled. I uncommented only the first one, so I need to use my user password when prompted to run a command via sudo.
This is the relevant section of mine. Code: | ## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL
|
_________________ Brian
Porthole, the Portage GUI frontend irc@freenode: #gentoo-guis, #porthole, Blog
layman, gentoolkit, CoreBuilder, esearch... |
|
Back to top |
|
 |
padoor Advocate


Joined: 30 Dec 2005 Posts: 4185 Location: india
|
Posted: Thu Feb 24, 2011 2:31 am Post subject: |
|
|
ok i edited the file with visudo
and now it seems to be working ok
thanks for a fast response  _________________ reach out a little bit more to catch it (DON'T BELIEVE the advocate part under my user name) |
|
Back to top |
|
 |
Logomachist n00b

Joined: 02 Jun 2014 Posts: 37 Location: PA, USA
|
Posted: Tue Nov 04, 2014 2:02 am Post subject: Where do you get visudo? |
|
|
dol-sen wrote: | you can edit the sudoers file. The best way is to use the command visudo as root in a terminal. |
Where do you get visudo? It doesn't seem to be in portage or any of the overlays. |
|
Back to top |
|
 |
kurly Apprentice

Joined: 02 Apr 2012 Posts: 260
|
Posted: Tue Nov 04, 2014 2:09 am Post subject: Re: Where do you get visudo? |
|
|
Logomachist wrote: | dol-sen wrote: | you can edit the sudoers file. The best way is to use the command visudo as root in a terminal. |
Where do you get visudo? It doesn't seem to be in portage or any of the overlays. | FYI, you are replying to a post that is over 3.5 years old. That said, visudo is at /usr/sbin/visudo if you have app-admin/sudo installed. |
|
Back to top |
|
 |
|