How users are created in Linux, under the hood

Published on 2026-09-12 by frfrand

What adduser really does: the four files where a user lives, what /etc/skel is for, and the two classic traps when creating and deleting accounts.

How users are created in Linux, under the hood

Short answer: creating a user on Linux is writing a few lines in text files: /etc/passwd (the public record), /etc/shadow (the password hash), /etc/group (the groups) and a home directory copied from /etc/skel. adduser does all that for you; what you need to watch out for is using usermod -aG (with the a) and, when deleting, cleaning up sudoers, crontab and orphaned files.

adduser deploy and done. But what exactly happened?

Nothing magical: four plain text files were written. Understanding which ones changes your relationship with the system quite a bit, because from there you can read the state of your server instead of guessing it.

/etc/passwd, the public record

deploy:x:1001:1001:Deploy user:/home/deploy:/bin/bash

Seven fields separated by colons: name, password placeholder, uid, gid, comment, home directory and shell.

This file can be read by anyone. That's why the password is no longer here: the x means "it's in shadow". In the seventies it did live in this file, and that was exactly the problem that led to /etc/shadow.

Two things you pick up along the way:

  • A user with shell /usr/sbin/nologin or /bin/false cannot log in. That's how almost all service users are set up.
  • The uid is what matters. Two different names with the same uid are, for the kernel, the same user.

/etc/shadow, the private part

deploy:$y$j9T$Kx2...:20028:0:99999:7:::

Here is the hash of the password, not the password itself. The prefix indicates which algorithm was used to generate it: $y$ is yescrypt, $6$ is SHA-512. If you see $1$ (MD5) on a modern server, something is being dragged from way back.

The numbers that follow are the aging policy: when it was last changed, how often it can and must be changed, how many days of notice.

An exclamation mark or an asterisk at the beginning of the hash means that the account does not have a valid password. In practice, this prevents password login, which is usual on a server where you log in via SSH key.

/etc/group and the trap of -a

sudo:x:27:deploy,ana docker:x:989:deploy

Each line is a group with the list of its secondary members.

And here is one of the most expensive traps in Linux:

usermod -G docker deploy # DELETES all other groups usermod -aG docker deploy # adds, which is what you wanted

Without the "a", the command replaces the complete list of secondary groups. If deploy was in sudo and you run the first one, you just removed your administration permissions. If you also had root login disabled, you need the provider's console to fix it.

Always write it -aG, as if it were a single word.

/etc/skel, the template of the home folder

When a user is created, their folder is not born empty: the contents of /etc/skel are copied.

That's where the .bashrc, the .profile, and whatever you want to add live. It's the right place to leave the configuration you want everyone on that server to have: useful aliases, a reasonable .vimrc, a welcome message with the team's conventions.

$ ls -a /etc/skel . .. .bash_logout .bashrc .profile

Changing it doesn't affect existing users, only those created after.

Deleting a user has more steps than it seems

$ deluser --remove-home deploy

That deletes the account and the folder. But there are loose ends worth reviewing:

  • /etc/sudoers.d/: if there was a rule for that user, it's still there. And since rules are written by name, the day another user with the same name is created, they inherit the permissions.
  • crontab -u deploy -l: the user's scheduled tasks.
  • Orphaned files: "find / -uid 1001" finds what was left with the old uid. If later another user is created with that uid, they become the owner of those files without knowing it.
  • Their SSH keys on other servers, which aren't on this machine.

The short way

For day-to-day use, adduser (Debian and Ubuntu's interactive wrapper) does everything right and asks what's necessary. useradd is the low-level command: more control, and also more ways to forget something.

$ adduser deploy $ usermod -aG sudo deploy $ mkdir -p /home/deploy/.ssh && chmod 700 /home/deploy/.ssh $ chown -R deploy:deploy /home/deploy/.ssh

In ArduMaker, VPS users are created by a Company Admin from the panel (or an agent with the MCP tool crear_usuario_vps): name, password, and, if necessary, sudo, without having to remember the order or the "a". By default, the person is asked to change the password on first login, and SSH keys are not loaded per user: the SSH Access app installs them for a single Linux user on the VPS (root, by default). But knowing what files are being touched underneath is what allows you to diagnose when something doesn't close properly.

Creating users does not mean granting unrestricted access

A new user can exist in Linux without being authorized to log in via SSH or run sudo. For an ArduMaker VPS, I decided separately who can connect, which folders they need, and which services they can manage.

Instead of sharing an administrator account, assign an identity per person, associate their SSH key, and keep a procedure to revoke it. This practice facilitates auditing and prevents locking out the entire team when a credential is compromised.

Related: Team access · What is SSH.

Frequently Asked Questions

What is the difference between adduser and useradd? adduser is the interactive wrapper for Debian and Ubuntu: it creates the folder, asks for the password, and sets up the groups. useradd is the low-level command and only does what you tell it to do.

Where is a user's password stored? In /etc/shadow, as a hash, never in plain text. The prefix ($y$, $6$) indicates the algorithm used to generate it.

Why did usermod -G remove me from the sudo group? Because without the -a flag it replaces the entire list of secondary groups. Always use usermod -aG.

What should you check when deleting a user? Their rules in /etc/sudoers.d/, their crontab, files left with their uid (find / -uid), and their public keys on other servers.

  • Linux
  • usuarios
  • permisos
  • administración
  • fundamentos

Keep reading

All articles · VPS plans