System administrator creating a new user account in Ubuntu terminal

Whether you are setting up a shared family computer, creating a separate account for work, or adding a user to an Ubuntu server, doing it from the terminal is faster and more precise than clicking through settings. This guide shows you how to create a new user in Ubuntu terminal step by step — including setting a password, granting administrator (sudo) access, and verifying everything worked. The whole process takes under five minutes, and every command is explained as we go.

In This Guide

adduser vs useradd: Which Command to Use

Ubuntu ships with two commands that sound identical, and picking the wrong one is the most common beginner mistake:

  • Terminal showing adduser command creating a new Ubuntu user with sudo accessadduser — the friendly, interactive wrapper. It asks you questions, creates the home directory, and sets up sensible defaults automatically. This is the one you want.
  • useradd — the low-level tool. It does the bare minimum unless you pass a dozen flags (-m for home directory, -s for shell, and so on). Useful in scripts, annoying by hand.

On Ubuntu and Debian-based systems, always reach for adduser for interactive work. (On Red Hat-based distros like Fedora, useradd is the friendlier one — one of Linux’s little inconsistencies.)

Everything below assumes you are running these commands as a user who already has sudo privileges. If the terminal is still new territory, our Ubuntu terminal commands cheat sheet covers sudo and the other basics you will see here.

Step 1: Create the User Account

Open a terminal (Ctrl + Alt + T) and run:

sudo adduser alex

Replace alex with the username you want. Usernames should be lowercase, with no spaces — letters, numbers, underscores, and hyphens are safe.

adduser then walks you through an interactive setup:

Adding user `alex' ...
Adding new group `alex' (1001) ...
Adding new user `alex' (1001) with group `alex' ...
Creating home directory `/home/alex' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for alex
Enter the new value, or press ENTER for the default
    Full Name []: Alex Morgan
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n] y

A few things to note. Ubuntu creates a private group with the same name as the user — this is normal and secure. The home directory /home/alex is created automatically, seeded with default config files from /etc/skel. The “Full Name / Room Number” fields are optional legacy info — you can just press Enter through them or fill in the name.

Step 2: Set (or Change) the Password

If you set the password during creation (recommended), you can skip this. To set or reset a password for any user later:

sudo passwd alex

You will be prompted twice for the new password. Note that the terminal shows nothing while you type — no asterisks, no dots. That is normal; type carefully and press Enter.

To lock an account without deleting it (the user cannot log in, but their files stay intact):

sudo passwd -l alex

To unlock it again:

sudo passwd -u alex

Account locking is the right move when someone leaves a team temporarily or you suspect a compromised account — it is instant and reversible, unlike deletion.

Step 3: Grant Sudo (Administrator) Access

A fresh user is a standard user: they cannot install software, edit system files, or run sudo. On Ubuntu, administrator rights come from membership in the sudo group. Add the user to it:

sudo usermod -aG sudo alex

The flags matter: -aG means append to the group list. If you forget the -a and write usermod -G sudo alex, you will replace all of the user’s groups with just sudo — silently stripping their other memberships. This is one of the most destructive typos in Linux user management, so always use -aG together.

Verify the group membership took effect:

groups alex
id alex

Expected output includes sudo in the list:

alex : alex adm cdrom sudo dip plugdev users lpadmin

Important: group changes only apply at the user’s next login. If alex is currently logged in (even in another terminal), they need to log out and back in before sudo works for them.

To remove sudo access later without deleting the account:

sudo deluser alex sudo

This is the clean, reversible way to demote an administrator back to a standard user.

Step 4: Verify the New User Works

Switch to the new account and confirm the essentials — login, home directory, and sudo:

su - alex

The - gives you a full login shell (correct home directory, environment variables, and working directory). Now check:

whoami
pwd
sudo -v

whoami should print alex, pwd should print /home/alex, and sudo -v validates sudo access (it will ask for alex’s password once, then succeed silently). Try a harmless sudo command to be thorough:

sudo apt update

If it runs without a “user is not in the sudoers file” error, everything is configured correctly. Type exit to return to your own account.

Managing Users: Info, Switching, and Deleting

See all users on the system

cut -d: -f1 /etc/passwd

This lists every account, including system accounts. Human users typically have UIDs of 1000 and above; you can filter with awk -F: '$3 >= 1000 {print $1}' /etc/passwd.

Check a user’s details

id alex
finger alex

id shows UID, GID, and group memberships. (finger may need installing via sudo apt install finger.)

Delete a user

sudo deluser alex

This removes the account but keeps the home directory by default — a safe default that protects against accidental data loss. To delete the user and their home directory and mail spool:

sudo deluser --remove-home alex

Always back up anything important from /home/alex before using --remove-home. There is no undo. For a broader refresher on safe file deletion, the rm section of our guide on installing tar.gz files in Ubuntu covers the same “no recycle bin” caution that applies here.

Extra Tips for Ubuntu Servers

On a server you SSH into, a few extra steps turn a basic account into a properly secured one:

  • Set up SSH key login for the new user instead of password login: copy their public key into /home/alex/.ssh/authorized_keys (owned by alex, chmod 700 on .ssh, chmod 600 on the file).
  • Disable password SSH login in /etc/ssh/sshd_config (PasswordAuthentication no) once keys work — this blocks brute-force attacks.
  • Give sudo a password timeout thought: the default asks for the password every 15 minutes of sudo inactivity, which is a sane balance for shared servers.
  • Create service accounts without login shells for daemons: sudo adduser --system --no-create-home --disabled-login svcname.

The official Ubuntu Server documentation covers user and security management in depth if you are hardening a production machine.

Changing a User’s Default Shell and Home Directory

Sometimes you need to tweak an existing account rather than create a new one. To change a user’s login shell (for example, switching from the minimal sh to the full-featured bash):

sudo usermod -s /bin/bash alex

Verify the change with grep alex /etc/passwd — the last field shows the shell. If a user was created without a home directory (common with useradd instead of adduser), you can create one and assign it:

sudo mkdir -p /home/alex
sudo cp -r /etc/skel/. /home/alex/
sudo chown -R alex:alex /home/alex
sudo usermod -d /home/alex alex

Copying /etc/skel gives the user the standard default config files (.bashrc, .profile) so their terminal behaves normally from the first login. The -R on chown applies ownership recursively — without it, the user would be locked out of their own dotfiles.

Frequently Asked Questions

What is the difference between adduser and useradd?

adduser is Ubuntu’s interactive, beginner-friendly wrapper — it creates the home directory, sets up groups, and prompts for a password automatically. useradd is the raw low-level command that does nothing unless you pass explicit flags. Use adduser unless you are writing automation scripts.

Why does sudo say “alex is not in the sudoers file”?

The user was never added to the sudo group, or they have not logged out and back in since being added. Run sudo usermod -aG sudo alex from an admin account, then have alex log out completely and log back in.

Can I change a username after creating it?

Yes, but it is fiddly: sudo usermod -l newname oldname renames the account, and you should also rename the home directory and group for consistency. It is cleaner to delete and recreate the account if no important data exists yet.

How do I create a user without a password?

Run sudo adduser --disabled-password alex. The account cannot log in with a password until you set one with passwd — useful for accounts that will only use SSH keys.

Is it safe to delete the default ubuntu user on a cloud server?

Only after you have created a replacement sudo user, verified you can SSH in as them, and confirmed sudo works. Lock yourself out of a cloud VM and recovery means using the provider’s console — avoidable with a two-minute verification step.

Key Takeaways

  • Use sudo adduser username — the interactive command that sets up home directories and groups automatically.
  • Set a strong password with sudo passwd username; the terminal hides password input, which is normal.
  • Grant admin rights with sudo usermod -aG sudo username — never forget the -a (append) flag.
  • Group changes require a fresh login to take effect.
  • Verify with su - username, then whoami, pwd, and a test sudo command.
  • Delete safely: sudo deluser username keeps the home directory; add --remove-home only when you are certain.

Conclusion

Learning how to create a new user in Ubuntu terminal step by step comes down to three commands: adduser to create the account, passwd to secure it, and usermod -aG sudo to grant administrator rights when needed. Verify with a quick login test, remember that deluser without --remove-home is the safe way to remove accounts, and you now have complete command-line control over who can use your Ubuntu system — on desktop or server alike.

Leave a Reply

Your email address will not be published. Required fields are marked *