Frequently Asked Question
In this guide, we will describe how to handle the user creation on one of your VM's . You can check the manual of your distribution in the terminal with
This article goes hand in hand with the Group creation Article.
2. How to Add a New User in Linux
The basic syntax of the command is:
ubuntu@eodc:~$ sudo useradd [options] username
To create a user you need to have adequate permissions on the system. You can either get them while logging in as the root user or with the
sudo (superuser do) command. By default, a group with the same name will also be created for the new user.
3. Create a User
As a privileged user run
ubuntu@eodc:~$ sudo useradd -m -G sudo,developers,webadmin -s /bin/bash your_user
Depending on the distribution you might already be asked for an password while the creation. If not and in the case that your user doesn't have shell access but needs RDP or other services which are depending on the native authentication create a password with the
ubuntu@eodc:~$ sudo passwd your_user
-m will create a home directory for af new user under /home. This option is needed when your user should be authenticated with an SSH key.
-G (Group) flag will add your_user to previously created groups. How to create groups
ubuntu@eodc:~$ sudo useradd -G sudo,developers,webadmin your_user
Sometimes, you want to add a user which has nothing to do with the login shell. You can assign a different login shell with the
-s (shell) flag.
ubuntu@eodc:~$ sudo useradd -s /sbin/nologin your_user
4. Other options
4.1. Add an User with an expiry Date
You can use the
-e (expiry) flag for this.
ubuntu@eodc:~$ sudo useradd -e 2038-01-19 your_user
The format is YYYY-MM-DD. This is helpful for creating temporary accounts for a specific period of time.
4.2 Do not create a Home diretory
You're supposed to run the command with all the flags at the same time. Check the man page for all available options
ubuntu@eodc:~$ sudo useradd -M -G samba -e 2038-01-19 your_user