How do I create a superuser from the command line in Ubuntu?

3

2

Possible Duplicate:
How to create a admin user on ubuntu

How can I create a superuser in Ubuntu 11.10? I need to create it using the command line.

Either we could change a normal user to become a superuser, or we could create a superuser right away.

Thillai Narayanan

Posted 2012-03-14T17:35:34.783

Reputation: 131

Question was closed 2012-03-15T00:48:08.580

Answers

9

You can create a new user simply using the adduser(8) command.

To make it a user capable of performing sudo, add him to the sudo group using either of the following commands:

sudo usermod -a -G sudo <username>
sudo adduser <username> sudo

This works because the sudo group is predefined in /etc/sudoers. Note though that older versions of Ubuntu will use admin as group instead:

Until Ubuntu 11.10, the Unix group for administrators with root privileges through sudo had been admin. Starting with Ubuntu 12.04 LTS, it is now sudo, for compatibility with Debian and sudo itself. However, for backwards compatibility, admin group members are still recognized as administrators

For any other customization, refer to the Sudoers documentation.

slhck

Posted 2012-03-14T17:35:34.783

Reputation: 182 472

adduser can also add users to groups: adduser <username> <groupname> – Der Hochstapler – 2012-03-14T17:50:16.003

Yeah, it's just a nice frontend, you're right :) – slhck – 2012-03-14T17:53:15.660

Also, to my understanding, there is a slight distinction between the admin and sudo groups (both exist in 11.10), but I don't think I understand it myself. – Der Hochstapler – 2012-03-14T17:55:02.607

I thought it was uncommented by default in sudoers but I don't know exactly anymore. – slhck – 2012-03-14T18:02:46.990

This doesn't work in 12.04.2. "usermod: group 'admin' does not exist" – Cerin – 2013-06-04T04:38:01.437

@Cerin If you read my answer it says that you have to use sudo for newer Ubuntu versions. I'll rewrite the answer later for that to be the default, but it is there... – slhck – 2013-06-04T05:34:35.137