How to create an Ubuntu Linux user account

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

Introduction : By default, the cloud server comes with a user named ubuntu. You can use this main user account for system administration tasks on Ubuntu. However, sometimes it is necessary to add a new user account on Ubuntu to perform additional system administration tasks. This page shows you how to create a user account or a system administrator account on the Ubuntu server.

Adblock detected ?

My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via PayPal/Bitcoin, or become a supporter using Patreon. Hop over to this web-site Linux Plesk server management.


Steps for creating a user account on Ubuntu Linux

  1. Open terminal application
  2. Enter the remote box by running ssh [email protected] subbox.
  3. To add a new user to Ubuntu, run sudo adduser userNameHere
  4. Enter your password and other necessary information to create a user account on the Ubuntu server.
  5. The new username will be added to /etc/passwd and the encrypted password will be stored in /etc/shadow.

Let’s take a detailed look at all the orders and

Create a Ubuntu user account for thecommand

Assuming you need to add a new user named vivek to Ubuntu, type the following command in the command line:
$ sudo adduser vivek
Enter your password and other information :
How to create an Ubuntu Linux user account


Use the command grep or cat as follows:
$ cat /etc/passwd
$ grep ‘^vivek’ /etc/passwd
Example output:

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

How do you register at ssh?

Boot from Windows (WSL) or MacOS or Linux desktop:
$ shh [email protected]
$ shh -i ~/.ssh/ [email protected]
Enter the password when prompted.

Create a user account with the useradd command on Ubuntu

You can also use the useradd command – a low-level utility to add users to Ubuntu. Syntax:
$ sudo useradd -s /path/to/shell -d /home/{filename} -m -G {subgroup}. {username}
$ sudo passwd {username}
Let’s create a new vivek user with the useradd command on Ubuntu:
$ sudo useradd -s /bin/bash -d /home/vivek/ -m -G sudo passwd
$ sudo vivek

  • -s /bin/bash – Set /bin/bash as the shell to log into your new account.
  • -d /home/vivek/ – Install /home/vivek/ as the home directory of your new Ubuntu account.
  • -m – Create a user’s home directory.
  • -G sudo – Make sure the vivek user can run sudo, i.e. give the administrator access to the new account.

I strongly recommend that you define your ssh keys when creating a new user account. The RSA/ed25519 key pair must be installed on the local desktop/laptop. Use the cat command to display the current RSA/ed25519 public key on your desktop:
$ cat ~/.ssh/
$ cat ~/.ssh/
How to create an Ubuntu Linux user account Show the ssh public key on Macos/unix/linux desktop
Execute the following commands on the Ubuntu server to ~/.ssh/id_ed25519 from the desktop:
$ sudo mkdir /home/vivek/.ssh/
$ sudo chmod 0700 /home/vivek/.ssh/
$ sudo — sh -c echo ‘ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAAILaLvLmaW9qIbUVo1aDHWZE9JewbNfIdTVif2aFGF0E0 [email protected]’ > /home/vivek/.ssh/authorized_keys
$ sudo chown -R vivek:vivek /home/vivek/.ssh/
You can now connect to ssh keys:
$ ssh [email protected] -ip-her
See more information :

How to delete my user account

Use the userdel command as follows:
sudo userdel {username}
sudo userdel vivek
To delete the home directory and the mail reel, also type:
sudo userdel -r {username}
sudo userdel -r jerry

Execute the following passwd command:
sudo passwd {username}
sudo passwd tom
To change your password, first type
, the user will be prompted to enter their current password. If the current password is entered correctly, a new password will be requested. The new password must be entered twice to avoid errors when changing the password.


In this Quick Start Guide you will learn how to add users to Ubuntu Linux using CLI. The same teams work for each Debian/Ubuntu distribution. View the custom man page with the man assignment or read it online here:
man 8 useradd
man 8 passwd
man 8 adduser


Published: Vivek gears

The author is the creator of nixCraft and an experienced system administrator, DevOps engineer and Linux/Unix shell script trainer. Receive the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly by email.ubuntu add user to sudo,ubuntu delete user and all files