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:
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>
For example to add itself to the docker group (necessary to run docker without the sudo):
sudo usermod -aG docker <username>
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 ;)