The Short Answer
| adduser | useradd | |
|---|---|---|
| Debian, Ubuntu | Interactive helper | Low-level tool |
| AlmaLinux, Rocky | Same as useradd | Low-level tool |
| Asks for a password | Yes, on Debian and Ubuntu | No |
| Best for | Typing by hand | Scripts |
On Debian and Ubuntu, use adduser when you create an account by hand. Use useradd in scripts and on the RHEL family, and give it the options you need.
adduser on Debian and Ubuntu
sudo adduser deploy
adduser is a separate program that calls the low-level tools for you. In one run it creates the user and a group of the same name, creates the home folder and copies the files from /etc/skel into it, sets the login shell, and asks for the password and optional details such as the full name. You end up with an account that can log in.
It also has a second job: with two names, it adds an existing user to an existing group.
sudo adduser deploy docker
Its settings are in /etc/adduser.conf.
useradd Needs Options
useradd does exactly what you tell it. On Debian and Ubuntu, useradd deploy on its own creates an account without a home folder, with the default shell from /etc/default/useradd, and without a usable password. For a normal login account, pass the options:
sudo useradd -m -s /bin/bash -G sudo deploy
sudo passwd deploy
-m: creates the home folder and copies/etc/skelinto it.-s /bin/bash: sets the login shell.-G: adds supplementary groups at creation, here sudo.-c "Deploy User": sets the comment, often the full name.-u 1500: sets a specific user ID.
Until you run passwd, the account has no usable password and cannot log in with one; it can still log in with an SSH key once you add one.
adduser on AlmaLinux and Rocky Linux
On the RHEL family, adduser is a link to useradd, so both commands behave the same. They also create the home folder by default there, because CREATE_HOME is set to yes in /etc/login.defs, but they do not ask for a password. The full sequence:
sudo useradd deploy
sudo passwd deploy
sudo usermod -aG wheel deploy
The form adduser user group does not work on these systems; use usermod -aG or gpasswd -a, as in how to add a user to a group.
Where the Defaults Come From
/etc/default/useradd: defaults for useradd, such as the shell and the home base folder.useradd -Dprints them./etc/login.defs: user ID ranges, whether home folders are created, and password aging defaults./etc/skel: the files copied into every new home folder, such as.bashrc./etc/adduser.conf: settings for adduser on Debian and Ubuntu.
System Accounts for Services
A service that should run under its own account needs no password and no login shell:
sudo useradd --system --no-create-home --shell /usr/sbin/nologin appsvc
On Debian and Ubuntu, sudo adduser --system appsvc does a similar job: it sets the nologin shell and creates no home folder unless you ask for one. System accounts get user IDs below the range for people, so they are easy to tell apart in the list of users. On the RHEL family the same shell is often written /sbin/nologin; there /sbin is a link to /usr/sbin, so both paths work.
Removing Accounts
The pair continues for deletion: deluser on Debian and Ubuntu, userdel everywhere. userdel -r also deletes the home folder and mail spool, so copy anything you need before you run it. If you only want to stop logins, lock the account with sudo usermod -L deploy and expire it with sudo usermod -e 1 deploy instead.
Which One to Use
By hand on Debian or Ubuntu: adduser. In a script that runs on several distributions: useradd with explicit options, then passwd or a key. To give the new account admin rights, follow how to create a sudo user.