How to create a user account on Ubuntu Linux

I have Ubuntu Linux 18.4/20.04 LTS server running on AWS cloud. How do I create a user account on Ubuntu Linux server using the command line? How can I add users on Ubuntu?

Introduction : By default, the cloud server comes with a user named ubuntu. You can use such primary user account for system admin tasks on Ubuntu. However, sometimes you need to add a new user account on Ubuntu for additional sysadmin tasks. This page shows how to create a user account or sysadmin account on the Ubuntu server.

Steps to create a user account on Ubuntu Linux

  1. Open the terminal application
  2. Log in to remote box by running the ssh user@your-ubuntu-box-ip
  3. To add a new user in Ubuntu run sudo adduser userNameHere
  4. Enter password and other needed info to create a user account on Ubuntu server
  5. New username would be added to /etc/passwd file, and encrypted password stored in the /etc/shadow file

Let us see all commands in details and

Ubuntu create user account commands

Let us say you need to add a new user in Ubuntu called vivek, type the following command in your shell:
$ sudo adduser vivek
Type your own password and other info:


Use the grep command or cat command as follows:
$ cat /etc/passwd
$ grep '^vivek' /etc/passwd

Sample outputs:

vivek:x:1001:1001:Vivek Gite,,,:/home/vivek:/bin/bash

How do I log in using ssh?

From your Windows (WSL) or macOS or Linux desktop, run:
$ ssh vivek@your-aws-ubuntu-server-ip
$ ssh -i ~/.ssh/ vivek@your-aws-ubuntu-server-ip
Enter the password when prompted.

Creating a user account using useradd command on Ubuntu

Alternatively, you can use the useradd command is a low level utility for adding users on Ubuntu. The syntax is:
$ sudo useradd -s /path/to/shell -d /home/{dirname} -m -G {secondary-group} {username}
$ sudo passwd {username}

Let us create a new user named vivek using the useradd command on Ubuntu:
$ sudo useradd -s /bin/bash -d /home/vivek/ -m -G sudo vivek
$ sudo passwd vivek


  • -s /bin/bash – Set /bin/bash as login shell of the new account
  • -d /home/vivek/ – Set /home/vivek/ as home directory of the new Ubuntu account
  • -m – Create the user’s home directory
  • -G sudo – Make sure vivek user can sudo i.e. give admin access to the new account

I strongly recommend installing ssh keys while creating the new user account. You must have RSA/ed25519 key pair on your local desktop/laptop. Use the cat command to view your current RSA/ed25519 public key on the desktop:
$ cat ~/.ssh/
$ cat ~/.ssh/

View public ssh key on your macos/unix/linux desktop

Run the following commands on your Ubuntu server to install above ~/.ssh/ key from your desktop:
$ sudo mkdir /home/vivek/.ssh/
$ sudo chmod 0700 /home/vivek/.ssh/
$ sudo -- sh -c "echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILaLvLmaW9qIbUVo1aDHWZE9JewbNfIdTVif2aFGF0E0 vivek@nixcraft' > /home/vivek/.ssh/authorized_keys"
$ sudo chown -R vivek:vivek /home/vivek/.ssh/

Now you can log in with ssh keys:
$ ssh vivek@your-aws-server-ip-here
For more info see:

How to delete a user account

Use the userdel command as follows:
sudo userdel {userName}
sudo userdel vivek

To remove home directory and mail spool too, enter:
sudo userdel -r {user-name}
sudo userdel -r jerry

How to change Linux user password

Run the following passwd command:
sudo passwd {username}
sudo passwd tom

To change your own password, enter:
First, the user is prompted for their current password. If the current password is correctly typed, a new password is requested. The new password must be entered twice to avoid password mismatch errors.


In this quick tutorial, you learned how to add users in Ubuntu Linux using the CLI. The same commands works for any Debian/Ubuntu based distribution too. See useradd man page using the man command or read it online here:
man 8 useradd
man 8 passwd
man 8 adduser

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • JKY Jul 7, 2017 @ 12:45

    This was useful. I created EC2 VM. It came preinstalled with ubuntu user and ssh key from AWS portal. I added jky user and key as shown here. I use jky single user for admin tasks. Can i delete ubuntu user?

  • Pedro Ayala Sep 4, 2020 @ 17:24

    Should be an explanation on how to create a standard user password with ubuntu user interface.

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @