Restore user to admin group in Ubuntu

Q I have been a bit of a fool and removed admin privileges from all three users on my Ubuntu system. This cut down the System-Administration menu to only a few items. At the moment, I do not have a user in the admin group that I can log in as to manage system items. I can use Gnome Terminal as sudo but cannot work out how to add one of the users back in to the admin group. I tried to use the usermod -g command but cannot get it right. That is, of course, if I am using right command. How can I add my user 'master' to the admin group again?

A First, don't worry about having made a mistake, we all do it. The two most important aspects of making a mistake are learning from it and not letting anyone else know you've done it. The command to add your user to the admin group is

gpasswd -a master admin

However, only the root user can manipulate the password and group databases, so you have a Catch 22 situation here: you need to use gpasswd to add yourself to the admin group, but you need to be a member of the admin group to do this.

Do not despair, there is a simple solution. The installation disc is also a Live distro, set up so you can run root commands with sudo. Boot from the disc, open a terminal and run

sudo bash
mount /dev/hdaN /mnt
nano /mnt/etc/group

Replace hdaN with whichever partition contains your Ubuntu installation. Nano is an easy-to-use console text editor. Scroll down to the line beginning 'admin:x:112:' and add 'master' to the end, so it reads

admin:x:112:master

You can add more than one user if you wish by separating them with commas, for example:

admin:x:112:master,slave

Don't worry if the number is not 112; leave it as is. Press Ctrl-X to save the file and exit, then reboot from your hard disk. You should now have your admin privileges again.

Back to the list