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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-15-2009, 04:55 AM
|
#1
|
LQ Newbie
Registered: May 2009
Posts: 4
Rep:
|
User not in the sudoers file
Hi,
I'm working with Ubuntu 8.10, and trying to type the command:
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
|
|
|
05-15-2009, 08:28 AM
|
#2
|
Member
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653
Rep:
|
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 05:17 AM.
Reason: used wrong flag on usermod command
|
|
|
05-15-2009, 08:58 AM
|
#3
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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 09:00 AM.
|
|
|
05-15-2009, 09:08 AM
|
#4
|
Member
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653
Rep:
|
Quote:
Originally Posted by jschiwal
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 05:14 AM.
Reason: used wrong flag on usermod command
|
|
|
05-15-2009, 09:33 AM
|
#5
|
LQ Newbie
Registered: May 2009
Posts: 4
Original Poster
Rep:
|
Thanks for your proposal,
however I found a solution in the following thread:
which allow to solve this issue without using a live distro :-)
|
|
|
05-16-2009, 02:09 AM
|
#6
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Quote:
Originally Posted by Robhogg
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.
|
|
|
05-16-2009, 05:13 AM
|
#7
|
Member
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653
Rep:
|
Quote:
Originally Posted by jschiwal
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 05:16 AM.
|
|
|
06-04-2009, 07:06 PM
|
#8
|
Member
Registered: Feb 2003
Location: Dallas, TX
Distribution: CentOS 5.3
Posts: 131
Rep:
|
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!
|
|
|
06-05-2009, 01:27 AM
|
#9
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,405
|
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.
|
|
|
06-05-2009, 02:03 AM
|
#10
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
06-09-2009, 01:35 PM
|
#11
|
Member
Registered: Feb 2003
Location: Dallas, TX
Distribution: CentOS 5.3
Posts: 131
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 11:42 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|