Ubuntu: Add a New User from the Terminal
The Two Commands, and Why There Are Two
You need two commands to create a working user on Ubuntu. One makes the account. The other gives it permission to do anything useful.
sudo adduser USERNAME
sudo usermod -aG sudo USERNAME
That is genuinely it. But the second line is where people quietly break their own systems, so it is worth understanding what both lines do rather than pasting them.
adduser is the interactive front end. It creates the account, makes /home/USERNAME, copies the skeleton files from /etc/skel, prompts you for a password, and sets sensible defaults for the shell and the GECOS fields. It writes the entry through useradd and passwd under the hood but saves you from six flags you would have got wrong.
usermod -aG sudo USERNAME appends the new user to the sudo group. The -a is not optional and it is the single most common way people lock themselves out of a server.

What adduser Actually Creates
Here is what exists after the first command finishes.
| Path | Purpose |
|---|---|
/home/USERNAME |
Home directory, mode 0750 on modern Ubuntu |
/etc/passwd |
Entry with uid/gid, home path and shell |
/etc/shadow |
The password hash, never the plaintext |
/etc/group |
A matching group with the same name as the user |
/var/mail/USERNAME |
Local mail spool |
The uid it picks is the next free one above UID_MIN in /etc/login.defs, usually 1000 on a desktop and 1000 or higher on a server, depending on what already exists.
A subtle one: the user's primary group is a group with the same name, not users. That matters when you set permissions on shared directories. If you want two accounts to share a project folder, using the matching-named groups means you will be adding each user to each other's group, which is not what you want. Make a real project group and put both users in it.
sudo groupadd project
sudo usermod -aG project alice
sudo usermod -aG project bob
sudo chgrp project /srv/project
sudo chmod 2775 /srv/project
The 2 in 2775 sets the setgid bit, so files created inside inherit the project group instead of each user's private group. Without it, every file lands in the creator's own group and the other user cannot touch it.
The -a Flag, and the Lockout It Prevents
usermod -G sudo alice sets alice's supplementary groups to exactly sudo. Every other group she was in is removed. If you do that to your own account while it is your only sudo user, you have just locked yourself out of administrative access.
usermod -aG sudo alice appends instead. Always use -aG. There is no case where leaving -a off is what you wanted, unless you are deliberately resetting the whole group list.
If you have already done it, the recovery depends on whether you have another sudo account, physical console access, or a provider rescue shell. On a cloud VM, most providers offer a serial console; boot to single-user mode or rescue and fix /etc/group by hand. It is an awkward fifteen minutes that the a avoids entirely.
Verify Before You Walk Away
Do not assume. Check the account from a second session while your original one stays open, so a mistake does not cost you the connection.
id alice
groups alice
getent passwd alice
id should show sudo in the supplementary groups. If it does not, the usermod did not run or you typo'd the username.
Then test the login path you actually care about:
su - alice
sudo -l
su - with the hyphen gives you a proper login shell with alice's environment. sudo -l lists her sudo rights, and it will prompt for her password, which is the other thing worth testing, because a locked or expired password fails here rather than two weeks later.

SSH Keys, Because Passwords Are the Weak Half
If this account will be reached over SSH, a password is the wrong mechanism. Set up a key for the user before you hand the account over.
From the machine you will connect from:
ssh-keygen -t ed25519 -C "alice@laptop"
ssh-copy-id alice@server
Or, if ssh-copy-id is not available, paste the public key by hand into /home/alice/.ssh/authorized_keys and fix the permissions, which is the part people get wrong:
sudo -u alice mkdir -p /home/alice/.ssh
sudo -u alice chmod 700 /home/alice/.ssh
sudo -u alice tee -a /home/alice/.ssh/authorized_keys < alice.pub
sudo -u alice chmod 600 /home/alice/.ssh/authorized_keys
Use sudo -u alice rather than sudo plus a chown afterwards. It creates the files with the correct ownership in one step, so you cannot end up with a root-owned authorized_keys that silently refuses every key. That failure gives you no error message at all; the server just rejects the key and you spend an hour reading logs that say nothing.
With the key working, turn off password authentication for SSH in /etc/ssh/sshd_config, then sudo systemctl reload ssh. Do this only after confirming the key login works in a second session with your current one still open.
Accounts With Expiry Dates
For contractors, temporary access, or anyone who should not still have a login in six months, set the expiry at creation time instead of remembering later.
sudo adduser --gecos "" contractor
sudo usermod -aG sudo contractor
sudo chage -E 2026-06-30 contractor
sudo chage -l contractor
chage -E sets the account expiry date. chage -l prints the full aging report, including the expiry, so you can confirm it took. When the date passes, the account is locked from login but the files stay where they are, which is what you want; nothing is deleted, access simply stops.
A related setting: force a password change on first login when you set someone up with a temporary one.
sudo passwd -e alice
That expires the password immediately, so the next login prompts for a new one. It is a small step that stops a temporary password from becoming a permanent one.

Removing the Account Cleanly
userdel alice removes the account but leaves /home/alice and any running processes. deluser --remove-home alice on Debian and Ubuntu removes the home directory too. Neither touches files the user created elsewhere, which is usually correct: audit those before you delete them.
Check for processes owned by the user before you delete anything:
ps -u alice -o pid,cmd
A departed employee's cron job or background process can outlive the account in unexpected places, particularly if it was started from a systemd unit with User= set.
The Short Version
Create the account with adduser, grant sudo with usermod -aG (never without -a), verify with id and a fresh su - session, set up an SSH key before you announce the account exists, and put an expiry date on anyone temporary. Five minutes of doing it in that order saves the twenty-minute rescue later, and it means the account you hand over is one you can actually describe.
Don't trust the download button. Trust the hash.
If this was useful, More hands-on tech guides at TechGeek. No pressure — read it whenever it's useful.