D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Ubuntu 13.04 - sudo

 

On 06/05/13 18:43, Philip Hudson wrote:
> On 5 May, 2013, at 9:40 pm, Jon Pilgrim wrote:
>
>> I, for my sins have been a devotee of Ubuntu since 8.04.  So I glibly
>> went for the latest rave, 13.04, thinking I can easliy avoid Unity
>> and go for my comfort zone that is Gnome and low and behold I can't
>> do a thing without being told I am not a 'sudoer'. I have never
>> encountered this problem before so I am left wondering if it is
>> pecular to 13.04.
>> If there is anybody out there who can help me get back control of my
>> machine, I'd be eternally grateful. I have glanced through man(5)
>> sudoers and decided it is all too much for my little brain.  I am
>> tempted to rename ubuntu 13.04 as Catchubuntu 22 as you can't do an
>> sudo without being first an sudo.  If I hadn't installed alongside my
>> 12.10, I would be really quite stuffed.
>
> The first user account created during install is sudo-enabled. If that
> is *not* your usual login, then you need to use that account to add
> your usual login to the sudoers list.
>
> Using sudo is not difficult. Run 'gksudo AppName' (? or Unity-specific
> equivalent ?) for running GUI apps, and 'sudo command' for running
> command-line apps. You'll be prompted for your password and away you go.
>

I didn't see the original email from Jon Pilgrim on the list yet, was it
sent to you directly Phil? I've seen a couple of replies on-list
recently that seem to be orphans, i.e., the original post is missing.
Sometimes they are delivered later out of order and sometimes not. This
may well be a problem at my end to be fair, this is
hotmail/live/outlook/whatever they're calling it today account after all...

To further clarify on sudo, something went wrong with your install
because you should definitely have sudo access on the user created
during install by default as Phil said. Issue 'less /etc/passwd' for a
complete list of users on your system, or 'grep bash /etc/passwd' for a
shorter list of the users who are mostly actually users (i.e., who have
/bin/bash set as their valid login shell - the many default daemons
running on your system will have /bin/false set as their login shells
and will be excluded from the second commands output). Check through the
values returned and ensure that whatever users are listed are what you
expect: there will be root listed and presumably any users you have created.

Get further information on specific users, particularly your own login,
by issuing: id *username*. So on my system:

ghost@failbot:~$ id ghost
uid=1000(ghost) gid=1000(ghost)
groups=1000(ghost),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),126(vboxusers),128(debian-tor),132(kvm),139(libvirtd)

As you can see, I am a member of multiple groups, particularly 27(sudo).
If your user account(s) are NOT members of (sudo), you have a serious
problem. During an ordinary Ubuntu install, you don't get to manually
specify a root password (which is one of the most monumentally stupid
decisions of all time in my opinion) so if you don't have sudo access on
any user account or access to the root password, you are screwed. You
either have to chroot into your system from 12.10 after manually
patching the passwords or achieve the same result from doing it offline
via a boot disk, etc. If you're not confident with setting sudoer
permissions and the like this is way out of your league and your easiest
option is to nuke and reinstall.

But, presuming that you can get access to a root level prompt, either by
finding a valid user account with sudo access or getting actual root,
here is your quick primer on achieving 'sudoing'. As a privileged user
do 'sudo visudo' (or just 'visudo' if you're root). This will invoke the
default text editor (nano unless you've changed it) on a special file:
look through it for a line like this:

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

This indicates that all members of group (sudo) can issue commands as
root with their password. If yours looks like this:

#%sudo   ALL=(ALL:ALL) ALL

Then delete the hash character at the start of the line (it's a comment
character, which means the line is NOT being read and activated by the
PAM subsystem) and save and exit. You now have a valid (sudo) user group
that you can now add normal users into. To add user(s), use the
following syntax:

usermod -aG sudo *account*

So for example, 'usermod -aG sudo ghost' would add user ghost to the
sudo group without deleting their other group memberships. Again, this
command has to be issued as a privileged user so either with sudo or as
root itself: you won't be able to do any of this unless you can solve
your first problem of not having either a sudo user or the root
password. Finally, if issued on a valid user account, the user will have
to be logged out and back in again (if applicable) before the changes
take place. Once done, issue 'id' again in your shell and confirm that
the user is now listed as having sudo membership. Job done.

Looking back quickly on these instructions they actually seem quite
wordy but it's honestly nowhere near as complex as it sounds, trust me.
I presume there are going to be mechanisms to do this via a GUI-based
system administration tool in the system settings somewhere but I really
wouldn't know; being a cmd line sort of person I never need to use them.

Hopefully that makes sense, feel free to ask if you need confirmation of
anything. Also, I've just remembered that you should be able to rescue
your current system by booting into rescue mode (duh!) which should get
you an automatic root login with no password (another unbelievably
stupid f*cking idea... I forget this because I always disable this
hideous security hole immediately). Remount your filesystem r/w and now
you've got both root access and a writable disk to save your changes so
you can do the above to unlock sudo for your primary account.

Good luck.

Regards

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq