Linux - NewbieThis 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!
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.
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:
mount /dev/ubuntupartition /mnt
chroot /mnt bash # then run either:
usermod -G admin username # or
The latter command will open sudoers in an editor (with syntax checking when you close it). Add a line:
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
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.
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).
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:
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?
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
to exit and save.
Try the cmd vimtutor once you're up and running again.
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:
bash: ifconfig: command not found
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.