LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-05-2012, 01:33 PM   #1
r00ster
Member
 
Registered: May 2007
Location: boundary beach, bc
Distribution: 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux
Posts: 224

Rep: Reputation: 15
How create sudoers file


I recently installed Squeeze from
[Debian GNU/Linux 6.0.4 _Squeeze_ - Official i386 kde-CD Binary-1 20120128-12:53]

Although there is a 'sudoers' file in '/etc/sudoers' it only contains a "Read Me" file; which is empty.
In order to avoid the necessity of doing routine stuff as root (su) I'd like to start using sudo.
I've read the man pages and done all the searching I can think up, but the literature all seems directed at making changes to a sudoers file, not creating one from scratch. I've also learned that messing up a 'sudoers file' can create serious problems. So I want to be sure I do it right. AFAICT no 'visudo' editor is on my system; either.

This is my personal home desktop and am the only user.

I would appreciate seeing something like a mock example of a single-user sudoers file that I can edit with my particulars.

r.
 
Old 05-05-2012, 01:35 PM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Please note that 'visudo' needs to be run as root.
 
Old 05-05-2012, 01:41 PM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
What is the output of the following?
Code:
cat /etc/sudoers
If you don't have a sudoers file or visudo (which, as mentioned needs to be run as root) installed then I would suggest there is likely to be a problem.
 
Old 05-05-2012, 04:01 PM   #4
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
Quote:
Originally Posted by r00ster View Post
In order to avoid the necessity of doing routine stuff as root (su) I'd like to start using sudo.
Be aware that in fact you are root when using sudo.

Quote:
Although there is a 'sudoers' file in '/etc/sudoers' it only contains a "Read Me" file; which is empty.
Quote:
AFAICT no 'visudo' editor is on my system; either.
Are you sure you have sudo installed? Also, keep in mind that there is a sudoers-file (/etc/sudoers) and a sudoers-directory (/etc/sudoers.d).
 
Old 05-06-2012, 02:44 AM   #5
r00ster
Member
 
Registered: May 2007
Location: boundary beach, bc
Distribution: 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux
Posts: 224

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by 273 View Post
What is the output of the following?
Code:
cat /etc/sudoers
If you don't have a sudoers file or visudo (which, as mentioned needs to be run as root) installed then I would suggest there is likely to be a problem.
Code:
# cat /etc/sudoers
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
Code:
# visudo -c
/etc/sudoers: parsed OK
Well; there it is b'gosh! It's time like this I seriously doubt I have the chops to be running deb/linux at all.

I fussed a bit with what I could understand from 'man visudo'. I don't know what to do to get an 'editor'(Defaults env_reset ?) or what to modify if I do get one.

r.
 
Old 05-06-2012, 02:56 AM   #6
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
So according to your sudoers file sudo is installed and setup on your system. As indicated by
Code:
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
At this point you need to check what groups your username belongs to.
Code:
~ $ id fukawi1
uid=1000(fukawi1) gid=1000(fukawi1) groups=1000(fukawi1),10(wheel)
~ $
If you see the group "sudo" listed there then sudo should work, by using
Code:
 $ sudo command
And then entering the users (not roots) password.

If you do not see the "sudo" group listed, you will need to add yourself to that group, by su'ing to root, and running usermod
Code:
# usermod -a -G sudo username
What this does is append (-a) the group (-G) to the username (username).
 
Old 05-06-2012, 03:31 AM   #7
r00ster
Member
 
Registered: May 2007
Location: boundary beach, bc
Distribution: 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux
Posts: 224

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by 273 View Post
What is the output of the following?
Code:
cat /etc/sudoers
If you don't have a sudoers file or visudo (which, as mentioned needs to be run as root) installed then I would suggest there is likely to be a problem.
Code:
# cat /etc/sudoers
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
Code:
# visudo -c
/etc/sudoers: parsed OK
Well; there it is b'gosh! It's times like this I seriously doubt I have the chops to be running deb/linux at all. I don't want to start a philosophical discussion I'm not qualified to participate in, but just as an observation, ...expecting a pilgrim penguin like me to assimilate 1362 lines of 'techno-arcana' in the 'sudoers' man page is rather optimistic. 'Yous guyses' seem to treat this like a book report on "Dick and Jane". To the kid here, it's more like presenting a copy of "The Differential CALCVLVS." to a gerbil.

I fussed a bit with what I could understand from 'man visudo'. I don't know what to do to get something I might recognize as an 'editor'(Defaults env_reset ?) or what to modify if I do get one.

r.
 
Old 05-06-2012, 04:11 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Code:
%sudo ALL=(ALL) ALL
As was already mentioned, this line is already set up for you. You need to add yourself to the "sudo" group. You don't need to edit your /etc/sudoers file. It is already configured. So you don't need to learn using vi after all (visudo).

Last edited by jschiwal; 05-06-2012 at 04:18 AM.
 
Old 05-06-2012, 04:14 AM   #9
r00ster
Member
 
Registered: May 2007
Location: boundary beach, bc
Distribution: 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux
Posts: 224

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by fukawi1 View Post
So according to your sudoers file sudo is installed and setup on your system. As indicated by
Code:
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
At this point you need to check what groups your username belongs to.
Code:
~ $ id fukawi1
uid=1000(fukawi1) gid=1000(fukawi1) groups=1000(fukawi1),10(wheel)
~ $
If you see the group "sudo" listed there then sudo should work, by using
Code:
 $ sudo command
And then entering the users (not roots) password.

If you do not see the "sudo" group listed, you will need to add yourself to that group, by su'ing to root, and running usermod
Code:
# usermod -a -G sudo username
What this does is append (-a) the group (-G) to the username (username).

Just so you know; I'm experiencing frequent screen freezes that cause hard shut-downs and restarts... and Konqueror isn't 'restoring' even though the option is given. I have to start over from scratch which has made posting here a PITA.

OK, here goes:
Code:
~$ id fukawi1
id: fukawi1: No such user
rooster@royrogers:~$ uid=1000(fukawi1) gid=1000(fukawi1) groups=1000(fukawi1),10(wheel)
I entered:
Code:
# usermod -a -G sudo [username]
I again tried
Code:
~ $ id fukawi1
uid=1000(fukawi1) gid=1000(fukawi1) groups=1000(fukawi1),10(wheel)
~$ id fukawi1
id: fukawi1: No such user
rooster@royrogers:~$ uid=1000(fukawi1) gid=1000(fukawi1) groups=1000(fukawi1),10(wheel)cd
bash: syntax error near unexpected token `('
Then I tried:
Code:
~$ id (username)
uid=1000(username) gid=1000(username) groups=1000(username),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),114(powerdev),115(scanner)
What next?
r.
 
Old 05-06-2012, 04:19 AM   #10
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
Ok replace any instances of "fukawi1" or "username" within [code][/code] tags, with your username (on the system, not the forum).

I think my post did a reasonable job of explaining itself, and it is fairly obvious that MY username is not going to work on YOUR system, and thus you should change it, which leads me to believe you didnt read the post, and you are just looking for a cut and paste solution to your problem. This is not how LQ works.

Last edited by fukawi1; 05-06-2012 at 04:23 AM.
 
Old 05-06-2012, 04:49 AM   #11
r00ster
Member
 
Registered: May 2007
Location: boundary beach, bc
Distribution: 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux
Posts: 224

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by fukawi1 View Post
Ok replace any instances of "fukawi1" or "username" within [code][/code] tags, with your username (on the system, not the forum).

I think my post did a reasonable job of explaining itself, and it is fairly obvious that MY username is not going to work on YOUR system, and thus you should change it, which leads me to believe you didnt read the post, and you are just looking for a cut and paste solution to your problem. This is not how LQ works.
It's not that I'm not paying attention. An you are definitely doing a reasonable job; especially under the circumstances. All the screen freezes and cold restarts are messing up my ability to post properly. I did insert my username, it's just that I couldn't edit the post to show what I had done in terminal before another freeze. Note: this is the third time I've tried to reply to this post and I'm just going to hit "Submit" without risking the extra "Preview" before I proceed further.

r.
 
Old 05-06-2012, 05:24 AM   #12
r00ster
Member
 
Registered: May 2007
Location: boundary beach, bc
Distribution: 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux
Posts: 224

Original Poster
Rep: Reputation: 15
fukawi1:

Trying the 'sudo' command...
Code:
~$ sudo kwrite
[sudo] password for (username): 
(username) is not in the sudoers file.  This incident will be reported.
WRT your previous suggestion to check what groups my username belongs to.,
Code:
~$ id rooster <snip> ,groups=1000(username),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),114(powerdev),115(scanner)
I'm not sure if I'm supposed to, but I'm not seeing my (username) associated with ',27(sudo)' even after having entered
Code:
# usermod -a -G sudo [username]
r.
 
Old 05-06-2012, 05:24 AM   #13
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
Before doing anything else on your machine you should really fix your freezing problems. Open another thread for this problem, so that we can better help you.
 
Old 05-06-2012, 05:36 AM   #14
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If your name is listed after the line beginning with "sudo:" in the /etc/group file, then reboot and try using sudo again. To run a desktop program like kwrite, use "kdesu" instead of "sudo". It woiyrks like sudo but also gives the root user access to your screen.
 
Old 05-08-2012, 07:50 AM   #15
r00ster
Member
 
Registered: May 2007
Location: boundary beach, bc
Distribution: 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u3 i686 GNU/Linux
Posts: 224

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jschiwal View Post
If your name is listed after the line beginning with "sudo:" in the /etc/group file, then reboot and try using sudo again. To run a desktop program like kwrite, use "kdesu" instead of "sudo". It woiyrks like sudo but also gives the root user access to your screen.
My name is listed in the '/etc/goup' file: "sudo:x:[name]

Testing:
Code:
~$ sudo -V
Sudo version 1.7.4p4
rooster@royrogers:~$ sudo -l
[sudo] password for rooster: 
Matching Defaults entries for rooster on this host:
    env_reset

User [name] may run the following commands on this host:
    (ALL) ALL
Code:
~$ sudo kwrite                                                   
[sudo] password for rooster: 
No protocol specified
kwrite: cannot connect to X server :0

'kdesu' is what I was used to in Etch and Lenny; ... worked like a charm. However in Squeeze:
Code:
~$ kdesu kwrite
bash: kdesu: command not found
[by edit] Found the problem. Squeeze uses 'kdesudo' instead.
http://www.linuxquestions.org/questi...3/#post4141562

WRT 'sudo', it pretty much looks like you got me to where the topic can be closed.

Thanks,
r.

Last edited by r00ster; 05-08-2012 at 08:13 AM.
 
  


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
Fedora /etc/sudoers file and sudoers.d directory davejjj Linux - Newbie 2 10-21-2011 06:19 PM
[SOLVED] Regarding sudoers file Ajit Gunge Linux - Newbie 6 10-05-2010 12:38 AM
Create two entries for the sudoers configuration file - help! SheMoves Linux - Newbie 1 06-23-2008 01:30 PM
I deleted /etc/sudoers and creates a new file call sudoers but now it doesnt for visu abefroman Linux - Software 1 11-10-2005 05:03 PM
The Sudoers File Rubicone Linux - Security 0 05-02-2002 06:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

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