How to Create a New User on Ubuntu

If you are managing an Ubuntu server, it is a dangerous security practice to let multiple people log in using the same root account. Every administrator, developer, or guest should have their own unique username and password. This ensures you can track exactly who made changes to the system and easily revoke access if someone leaves the project.

Creating a new user on Ubuntu via the command line is incredibly simple, requiring only a single command. Here is how to create a new user and, if necessary, grant them administrator (sudo) privileges.

Step 1: Use the ‘adduser’ Command

In the Linux world, there are two different commands for creating users: useradd and adduser. You should always use adduser. It is a much friendlier script that automatically creates a home directory for the user and prompts you to set a password.

  1. Open your terminal or connect to your server via SSH.
  2. Type the following command (replace john with the actual username you want to create):
    sudo adduser john
  3. Press Enter.

Because you are making a system-level change, Ubuntu will ask for your current password to verify you have permission to do this. Type your password and press Enter.

Step 2: Set the Password and User Details

The adduser script will immediately begin setting up the account and will ask you for a few pieces of information.

  1. New password: Type a strong password for the new user. Note: As you type, nothing will appear on the screen. This is a normal Linux security feature. Press Enter when finished.
  2. Retype new password: Type the exact same password again to confirm it.
  3. Full Name, Room Number, Work Phone, etc.: The script will ask you for optional contact information. You can type answers if you want, but you can also just 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.

The new user account is now fully created. They can log into the server using their username and the password you just set.

Step 3: Grant Administrator Privileges (Optional)

By default, the new user you just created is a standard user. They can browse the system and create files in their own home folder (/home/john), but they cannot install new software or change system settings.

If this person is a trusted administrator and needs the ability to run sudo commands, you must add them to the “sudo” group.

  1. Type the following command (again, replacing john with the correct username):
    sudo usermod -aG sudo john
  2. Press Enter.

Command Breakdown:

  • usermod: The command used to modify an existing user account.
  • -aG: Stands for Append to Group. This tells the system to add the user to a new group without removing them from their current groups.
  • sudo: The name of the specific group that grants administrator privileges.

The user now has full administrative access and can execute system commands by typing sudo before them.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

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

Receive our best articles and tips delivered straight to your inbox.