LinuxQuestions.org
Review your favorite Linux distribution.
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 05-15-2009, 03:55 AM   #1
ersek
LQ Newbie
 
Registered: May 2009
Posts: 4

Rep: Reputation: 0
User not in the sudoers file


Hi,

I'm working with Ubuntu 8.10, and trying to type the command:
Code:
sudo su -
I got the following result
Code:
user is not in the sudoers file.  This incident will be reported.
I have no root user enabled, how could I reinsert the user inside the sudoers file?

Thanks
 
Old 05-15-2009, 07:28 AM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
Is your current user in the admin group (run id and see if it's listed)? By default in Ubuntu, all members of the admin group are allowed to use sudo. If not, have you got another user set up who is in the admin group?

If the answer to both of these is no, you will need to boot your PC from a live disk (you have to have root privileges to alter sudoers), su to root (or use sudo -i ), then run:
Code:
mount /dev/ubuntupartition /mnt
chroot /mnt bash # then run either:
usermod -G admin username # or
visudo
The latter command will open sudoers in an editor (with syntax checking when you close it). Add a line:
Code:
username ALL=(ALL) ALL
Save, reboot, and your user should be able to access sudo.

BTW, to get a root shell in Ubuntu I would normally use sudo -i or sudo bash instead of sudo su -.

Last edited by Robhogg; 05-16-2009 at 04:17 AM. Reason: used wrong flag on usermod command
 
Old 05-15-2009, 07:58 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Or become a member of the admin group instead of explicitly adding a user in sudoers. The first user is normally automatically made a member during installation. The first user and add you or you can edit /etc/groups from a live distro, adding your user after the colon.

Last edited by jschiwal; 05-15-2009 at 08:00 AM.
 
Old 05-15-2009, 08:08 AM   #4
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
Quote:
Originally Posted by jschiwal View Post
Or become a member of the admin group instead of explicitly adding a user in sudoers...
Yes, 'tis what this command does:
Code:
usermod -G admin username
... though I probably should have pointed that out .

Last edited by Robhogg; 05-16-2009 at 04:14 AM. Reason: used wrong flag on usermod command
 
Old 05-15-2009, 08:33 AM   #5
ersek
LQ Newbie
 
Registered: May 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for your proposal,

however I found a solution in the following thread:

which allow to solve this issue without using a live distro :-)
 
Old 05-16-2009, 01:09 AM   #6
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Quote:
Originally Posted by Robhogg View Post
Yes, 'tis what this command does:
Code:
usermod -g admin username
... though I probably should have pointed that out .
Well, since he can't use sudo, in the first place. The proper way of doing it won't work.

I don't like the idea of adding individual users to the sudoers file when unnecessary. Often the only edit that is needed is uncommenting an entry already there.
 
Old 05-16-2009, 04:13 AM   #7
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
Quote:
Originally Posted by jschiwal View Post
Well, since he can't use sudo, in the first place.
Except that what I'd suggested was to boot from a live disk, become root in the live environment and then chroot into the Ubuntu partition, before issuing the usermod command. Just done this using a Mint live CD, and can confirm that it works.

The error that you could have pulled me up on was that I'd used usermod -g ... rather than usermod -G ... - the former command changes the user's primary login group, rather than adding the user to a group (I've now corrected this in my original post).

Last edited by Robhogg; 05-16-2009 at 04:16 AM.
 
Old 06-04-2009, 06:06 PM   #8
saxophobe
Member
 
Registered: Feb 2003
Location: Dallas, TX
Distribution: CentOS 5.3
Posts: 131

Rep: Reputation: 15
Ok, I have been trying to do this for the past couple of hours with little success. In answer to your questions, I'm using CentOS 5.3, not Ubuntu, so I have the root user that is a member of the Admins group. And I can get into visudo, but I have to use /usr/sbin/visudo for some reason. In any case, every instruction I've seen says to save/close and reboot. How do you do that?!?!!?? I hate vim. I like nano, which has all the commands at the bottom, which is very helpful for an aging ID10T like me! So now, when I try to edit the sudoers file, I get the following error:

Quote:
E325: ATTENTION
Found a swap file by the name "/etc/.sudoers.tmp.swp"


"/etc/sudoers.tmp" 94L, 3185C
Press ENTER or type command to continue
So, 1) How do I prevent this error message from coming up? and 2) How do I save/close in visudo?

Thanks in advance for your time!
 
Old 06-05-2009, 12:27 AM   #9
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
This

/etc/.sudoers.tmp.swp

is a temp backup file created by vi/vim when being used. Start by deleting it before starting the editor. Normally it only exists if the editor crashed or you broke out of it.
Now use visudo, do your edits, the use the 'esc' key then

:x

to exit and save.
Try the cmd vimtutor once you're up and running again.
 
Old 06-05-2009, 01:03 AM   #10
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I don't use CentOS, but I think you need to add the user to the wheel group instead of the admin group.

There is a line near the bottom of the sudoer file that may be commented out. You simply need to delete the "# " at the beginning of the line to enable it. Then add the user to the wheel group.

When adding groups or editing the sudoers file, you may need to reboot for sudo to operate correctly.
 
Old 06-09-2009, 12:35 PM   #11
saxophobe
Member
 
Registered: Feb 2003
Location: Dallas, TX
Distribution: CentOS 5.3
Posts: 131

Rep: Reputation: 15
Resolved!

Folks, thanks for all your help! I'm not sure where I am right now with this, as I edited the file so I do not get the error that says my account does not belong to the sudoers group; I had to add my account to the command section under root to get it to work. I tried the suggestion of adding to the wheel group, but still got the error, I even added my account to the wheel group to make sure, but no dice.

In any case, now I can edit this file using sudo! Now I have to figure out why I can't run ifconfig?!?!?! Every time I do, I get the following response:

Quote:
bash: ifconfig: command not found
-or
Quote:
sudo: ifconfig: command not found
This happens even when I'm in ROOT! But this is really a different issue. I'll post elsewhere on this one.
 
  


Reply

Tags
sudo, sudoers, ubuntu


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
adding user to sudoers file in moblin retsoced Linux - Mobile 3 03-17-2009 05:31 AM
Adding a user to the sudoers file? annihilan Slackware 5 11-13-2008 04:36 PM
how a user can be added to sudoers file. afaheem1988 Linux - Newbie 5 08-10-2008 07:15 PM
user is not in the sudoers file after clean install Mark_667 Red Hat 3 02-11-2008 11:16 AM
Debian user not in sudoers file... phantom_cyph Linux - General 3 04-08-2007 01:08 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration