adduser – How can I create an administrator user from the command line? – Ask Ubuntu

To create a new user with admin privileges in Ubuntu 12.04 and later:

adduser sudo
In Ubuntu 11.10 and earlier, use this instead:

adduser admin
To modify a existing user (12.04 and later):

sudo usermod -aG sudo
(Or for 11.10 and earlier: sudo usermod -aG admin )

-a stands for append whereas -G stands for groups. With the -a and -G flags as shown above, the sudo (or admin) group will be added to the list of groups of which the user is a member.

The other answers are correct but you also asked about the home directory. You will also need a password for the new user.

sudo useradd *new-admin-username* -s /bin/bash -g sudo -m
-s sets the user’s login shell
-m makes the user’s home directory if it doesn’t exist: /home/*new-admin-username*
-g adds the user to the sudo group so they will have admin privileges (>11.10)

Once created, add a password for the user:
sudo passwd *new-admin-username*

Login to the user to see if everything worked:
su *new-admin-username*
cd ~/
pwd

Comments

comments