Linux VPS

Add a new user on Linux (adduser vs useradd)

Create a new user account on your Linux VPS with adduser on Ubuntu and Debian or useradd on AlmaLinux and Rocky Linux, with a password, home folder and the right shell.

BeginnerLinux server5 min read

Every person and every app that logs in to your server should have its own account. Working as root all day makes mistakes costly and hides who did what. This guide shows how to add a user on Ubuntu, Debian, AlmaLinux and Rocky Linux, and explains the difference between the two commands you will meet: adduser and useradd.

Before you start

  • A Linux VPS running Ubuntu 22.04 or 24.04, Debian 12, or AlmaLinux or Rocky Linux 8 or 9.
  • An SSH session as root or a user with sudo. Your root login details are in your VPS provider's control panel.
  • A name for the new account. Use lowercase letters, digits, hyphens or underscores, starting with a letter, for example deploy.

adduser vs useradd

Both commands create users, but they behave differently:

  • useradd is the low-level tool and exists on every distribution. It does only what you tell it with options. On Debian and Ubuntu it does not create a home folder unless you pass -m, and it may set the shell to /bin/sh.
  • adduser on Debian and Ubuntu is a friendly wrapper. It creates the home folder, copies the default files from /etc/skel, sets the shell to Bash and asks for a password.
  • On AlmaLinux and Rocky Linux, adduser is just a link to useradd. It does not ask questions, but the defaults there already create a home folder and use Bash.

In short: use adduser on Debian and Ubuntu, and useradd on AlmaLinux and Rocky.

Add a user on Ubuntu and Debian

Run:

Bash
sudo adduser deploy

The command creates the group and home folder, then asks for a password twice and for optional details such as full name. Press Enter to skip the details. The output starts like this:

info: Adding user `deploy' ...
info: Adding new group `deploy' (1001) ...
info: Adding new user `deploy' (1001) with group `deploy (1001)' ...
info: Creating home directory `/home/deploy' ...
info: Copying files from `/etc/skel' ...
New password:

Older releases print the same lines without the info: prefix.

To create the user without the questions, for example in a script, set the details on the command line and the password separately:

Bash
sudo adduser --disabled-password --gecos "" deploy
sudo passwd deploy

Add a user on AlmaLinux and Rocky Linux

Use useradd with explicit options so the result is clear:

Bash
sudo useradd -m -s /bin/bash deploy
sudo passwd deploy
  • -m creates /home/deploy and copies files from /etc/skel.
  • -s /bin/bash sets the login shell.
  • passwd sets the password. Until you do, the account cannot log in with a password.

The same two commands also work on Debian and Ubuntu if you prefer one method everywhere.

Useful extra options

  • -c "Deploy user" adds a comment, usually the full name.
  • -G wheel (AlmaLinux, Rocky) or -G sudo (Ubuntu, Debian) adds the user to that group at creation, which grants sudo rights.
  • -u 1050 picks a specific user ID, handy when IDs must match across servers.
  • -e 2026-12-31 sets an expiry date for a temporary account.

Give the user sudo rights (optional)

Only add sudo if the person really needs to administer the server.

Ubuntu and Debian:

Bash
sudo usermod -aG sudo deploy

AlmaLinux and Rocky Linux:

Bash
sudo usermod -aG wheel deploy

The full walkthrough, including testing, is in Create a sudo user on Linux.

Set up SSH key login for the user

A password works, but SSH keys are safer. Copy your public key into the new account from your own computer:

Bash
ssh-copy-id deploy@203.0.113.10

If you work from Windows without ssh-copy-id, follow Set up SSH keys to add the key by hand to /home/deploy/.ssh/authorized_keys.

Check it works

Confirm the account exists and has the right shell and home:

Bash
getent passwd deploy
deploy:x:1001:1001::/home/deploy:/bin/bash

The last two fields are the home folder and shell. Then check the groups and test a login from a new terminal:

Bash
id deploy
ssh deploy@203.0.113.10

Once logged in, pwd should print /home/deploy.

Troubleshooting

  • "useradd: user 'deploy' already exists": the name is taken. Check with getent passwd deploy and pick another name or work with the existing account.
  • Login drops you into $ with no colours or tab completion: the shell is /bin/sh. Fix it with sudo usermod -s /bin/bash deploy.
  • "Could not chdir to home directory": the account was made without -m. Create the folder with sudo mkhomedir_helper deploy, or by hand with sudo mkdir /home/deploy and sudo chown deploy:deploy /home/deploy.
  • "Permission denied" at SSH login with the right password: password login may be disabled in sshd_config. Use SSH keys for the new user instead.
  • "adduser: Please enter a username matching the regular expression": the name has capitals or unusual characters. Use lowercase letters and digits.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.