How to Create a New User Account in Linux Using the adduser Command

When you need to grant a colleague access to your Linux server, or if you are setting up a dedicated service account for a web application, you must create a new user account. While there is a low-level command called useradd, it is notoriously tedious to use, as it requires you to manually create home directories and assign shell paths.

For Debian and Ubuntu-based systems, the vastly superior method is to use the adduser command. This is an interactive, high-level script that automatically handles all the heavy lifting, ensuring the new account is set up perfectly in seconds.

How to Create the New User

Because you are modifying system accounts, you must execute the command with root privileges (using sudo).

  1. Open your terminal.
  2. Execute the following command, replacing johndoe with the username you wish to create (usernames should be lowercase without spaces):
    sudo adduser johndoe

The terminal will immediately respond by confirming that it is automatically creating the user, creating a new group for the user, and generating a home directory at /home/johndoe.

The Interactive Setup Process

Next, the script will prompt you for several pieces of information:

  1. New password: You will be asked to type a password for the new user. As a security measure, the cursor will not move, and asterisks will not appear while you type. Type it blindly and press Enter.
  2. Retype new password: Enter the exact same password again to confirm it.
  3. Full Name, Room Number, Work Phone, etc.: The script will prompt you for the user’s real-world information (the GECOS fields). These are entirely optional. You can simply press Enter repeatedly to skip all of these fields and leave them blank.
  4. Is the information correct? [Y/n]: Type Y and press Enter to finalize the account creation.

The user account is now fully active. The user can immediately connect to the server via SSH using their new credentials.

How to Grant Administrator (Sudo) Privileges

By default, the new user you just created is a standard, unprivileged user. They cannot install software or modify system configurations. If you are creating this account for a fellow administrator, you must add them to the sudo group.

To grant the new user root privileges, use the usermod command to append (-a) them to the sudo group (-G):

sudo usermod -aG sudo johndoe

The user johndoe can now prefix commands with sudo to execute them with full administrative authority.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.