Add User Linux: Create Accounts and Set Access

Linux User Administration: A Complete Guide to Managing Multi-User Systems

A new person who needs to sign in needs an account on the Linux system first. The adduser and useradd commands create accounts, and useradd can create a home directory when you request one.

I’ll show how to create and verify an account, then add supplementary group access without replacing existing memberships.

TL;DR: Add a user in Linux

Run adduser on Debian or Ubuntu, or use useradd on distributions that provide shadow-utils, then set a password and verify the account before granting extra access.

  • Create a home directory with the account.
  • Set the password with passwd so it is entered interactively.
  • Use usermod -aG to add supplementary groups without replacing existing memberships.

What is Linux user administration?

Linux user administration creates accounts and controls access. Each account has a name and numeric user ID (UID). Groups collect accounts under a group ID (GID).

Each account is identified internally by its UID, even when commands display the login name. Files record numeric ownership, so changing a username does not change the UID that owns existing files. Groups work the same way through GIDs.

Every account has one primary group, which provides the default group identity for new files. Supplementary groups add access to shared resources, such as a device or project directory.

Local account data appears in /etc/passwd, /etc/shadow and /etc/group. Name Service Switch (NSS) can also resolve accounts from directory services, so a name returned by getent may come from outside those local files. Check the configured source before changing an account.

Keep account database contents private: /etc/passwd stores account fields, while /etc/shadow stores protected password hashes and aging data.

Linux useradd creates accounts from the command line. Debian and Ubuntu also provide adduser, an interactive setup helper.

The commands have different defaults and prompts. Follow your distribution’s documentation, and see the useradd command guide for options.

How to add and configure a Linux user step by step

Use an administrator account with sudo and replace sam with the intended login name. Creating a user changes system state, so check the name and requested access first.

Step 1: Choose the account creation command

On Ubuntu or Debian, adduser prompts for a password and account details. Where shadow-utils is used, useradd -m creates the home directory. Check your distribution’s documentation if behavior is unclear.

sudo adduser sam
# On systems where useradd is the documented tool:
sudo useradd -m -s /bin/bash sam

Use one creation command. With useradd, -m requests a home directory and -s selects the login shell. Defaults can vary.

Step 2: Set or confirm the password

When adduser prompts for a password, enter it in that prompt. If you used useradd or need to set it afterwards, use passwd with the account name.

sudo passwd sam

passwd prompts for the password, keeping it out of shell history and process arguments. Avoid useradd -p with plaintext because it expects an encrypted value and may expose credentials.

Step 3: Verify the account and home directory

Use id to inspect memberships and getent to verify the configured home directory and shell.

id sam
getent passwd sam

The id command reports the UID, primary GID and supplementary groups. I created sam with useradd and ran id sam. It returned:

uid=1002(sam) gid=1002(sam) groups=1002(sam)
Terminal output showing sam account UID, primary group and group list

The output shows sam’s UID and primary group. The screenshot captures that same check. Use getent passwd sam to inspect the configured home and shell.

getent passwd prints colon-separated account fields, including the home directory and login shell.

Step 4: Add supplementary group access safely

A group grants access to shared files or devices. Create it only if it does not already exist, then append the user.

sudo groupadd project
sudo usermod -aG project sam
id sam

The -a flag makes -G append the group. Without -a, usermod -G replaces supplementary memberships. Check existing groups first, using the group-listing guide if needed.

Step 5: Review account options before customizing

Choose only options required by account policy. Check the useradd manual for behavior, especially whether -G sets the full group list. Use usermod -aG to append to an existing account.

OptionPurposePoint to check
-mCreate the home directoryDefaults vary by configuration
-d PATHSet a home directory pathConfirm the path is intentional
-s SHELLSet the login shellUse a valid installed shell
-u UIDRequest a numeric user IDEnsure the ID is not already assigned
-G GROUPSSet supplementary groups during creationSpecify every required group

Choose a custom UID only when policy requires it. Verify the number is unused, since duplicate IDs can map distinct login names to the same file owner.

Before adding a group, check id sam to distinguish the primary group from supplementary memberships. A running process keeps the groups it had at startup. After changing memberships, start a new login session and run id again to confirm the change.

Common errors when adding a Linux user

Use getent and id to check the account and its access. If a check fails:

  • An existing name: inspect getent passwd sam before changing the account.
  • Authentication failure: check whether a password is set or the account is locked, using documented tools.

Administrative access is a separate decision from creating an account. Ubuntu commonly grants it through the sudo group, while some distributions use wheel.

Confirm local policy before adding a user to either group. For Ubuntu, see how to add users to sudoers. Use the managed group or visudo workflow documented by the distribution.

Directory accounts may come from LDAP or another NSS source. When getent resolves a name absent from /etc/passwd, make changes in the authoritative directory service.

Protect account database contents. The user and group lookup guide covers membership checks.

Conclusion: verify the account and its access

To add a user in Linux, use the command your distribution supports, set a password interactively and verify the UID, home and group memberships. Add only the supplementary access the account needs, and use the distribution’s documented route for administrator privileges.

For command details, consult the useradd manual and usermod manual. Ubuntu’s user management documentation explains its account workflow and local-versus-directory distinction.

FAQ

These answers cover account creation and supplementary group access.

How do I add a user in Linux?

Use the account-creation command documented for your distribution, such as sudo adduser sam on Ubuntu or sudo useradd -m sam where useradd is used. Set a password with sudo passwd sam and verify the account with id sam.

How do I add a Linux user to a group?

Run sudo usermod -aG groupname username to append a supplementary group. Keep -a with -G so other supplementary memberships are not replaced, then verify with id username.