Linux: Creating New User

Published

Here we will look at the procedure of creating a new user in a Linux-based OS, as well as configuring the user's settings for SSH connection. We will add a user in Ubuntu 22.04 LTS, but the steps will be similar on most Linux-based operating systems.


By default, when accessing our Linux or Unix based virtual machine or server, you are assigned the password of a root user with unlimited rights. However, for remote management, we recommend creating a new user or multiple users, giving them only the rights they need to perform their specific tasks.

Prerequisites

1. The virtual machine or server must have a Linux-based operating system.

2. A Linux terminal must be available on the system.

3. You must connect to the virtual machine or server, for example, through the noVNC console, as described in the section "Connecting via Control Panel Console".

Creating User

1. Add a user with the command:

		
useradd <user_name> -d /home/<user_name> -m

For example:

		
useradd myuser1 -d /home/myuser1 -m

This command creates a new user myuser1, will create the directory /home/myuser1, which will be set as the myuser1 user's home directory.

We need to know exactly where the user folder will be located and make sure it is created so that we can place the SSH public key in this folder.


2. Set the password for the user with the command:

		
passwd <user_name>

For example:

		
passwd myuser1

This command will prompt for the password for the user myuser1, and then prompt you to re-enter the password. If the passwords entered are different, you will be prompted to re-enter them. While the password is being entered, the characters are not displayed on the screen. If the password does not meet the security criteria, you will be prompted and may be required to re-enter a different password.

 3. If necessary, add privileges to the new user with the command:

  • For most distributions such as Ubuntu, Debian, Linux Mint, Arch Linux command:
		
usermod -aG sudo <user_name>

For example:

		
usermod -aG sudo myuser1

The command will add the user myuser1 to the sudo group, delegating to this user the permissions set for the sudo group, usually allowing them to execute commands as root.

  • For Red Hat-based distributions such as: Fedora, CentOS, Red Hat Enterprise Linux (RHEL), AlmaLinux, Rocky Linux by the team:
		
usermod -aG wheel <user_name>

For example:

		
usermod -aG wheel myuser1

The command will add the user myuser1 to the wheel group, delegating him the rights set for the wheel group, usually allowing him to execute commands as root.

OpenBSD uses its own doas utility instead of sudo by default, and OpenSolaris uses the pfexec command.


After creating the user, you can proceed to install the OpenSSH client that you will use to manage the server. The process of installing the OpenSSH client is described in the section "Installing OpenSSH Client".

Additional

More about the Сommands

Ubuntu 24.04 LTS

Red Hat