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!
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.
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
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.
... 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.
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:
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?
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.