Linux Command Linx

Creating a New Linux User


Linux is a multi-user operating system and as such can support multiple users. In this brief tutorial, we show how to(1) create a user, (2) give him super-user privileges if needed, and finally (3) allow him to connect to the machine using ssh if remote access is required.

Add New User

The command to use is:

adduser <username>

Remember the “add” at the beginning. Don’t confuse this command with the “useradd” command.

Add the user to groups (Super-User group)

You may want to add the new user to a few groups. The most important group is “sud o” (supposing you want to give him the superuser permission).

sudo usermod -aG sudo <username>

Once granted, the user can add himself to other groups if needed.

Add the user to groups (self)

Once the user has super-user privileges (“sudo”) and is logged in, he/she should use this command to add itself to other groups.

sudo usermod -aG <groupname> <username>
newgrp <groupname>

For example to add itself to the docker group (necessary to run docker without the sudo):

sudo usermod -aG docker <username>
newgrp docker

Add SSH Connection

If the target machine is a server that supports connection only through ssh-key. Put the user ssh public key in “/home/<username>/.ssh/authorized_keys” file.

echo "<public key>" > /home/<username>/.ssh/authorized_keys

<username>: is the user’s alias

To create the couple of private and public keys, run the command



This is it for today's tutorial, feel free to comment or ask any questions. And don’t forget to clap and follow ;)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store



Big fan of technology with a recent interest in finance following the rise of cryptocurrencies.