Like most modern operating systems, Linux can manage different user accounts. There are not only accounts for the actual users, but also some hidden accounts for programs. The different user accounts can have different rights. In general, the "useradd" command is used to create a new user.
In the following, we'll show you how to create users using console commands . Of course you can also create new accounts in the user interface . However, this is not uniformly regulated on all Linux distributions. The console commands should work with the usual Linux operating systems without any problems.
Create a user for someone else
If you want to set up an account for someone else , it makes sense if the user has access to his own directory. Depending on the standard configuration of the operating system, it is possible that such a home directory is not automatically created when a user is created. You can ensure that a home directory is created by using the following command: Instead of the wildcard , you must specify the username. Make sure that there is a small "m" in the command. If there is a capital "M", NO home directory will be created . Finally, you have to activate the new account .
sudo useradd -m <Benutzername>
<Benutzername>
Set up a new user for a program
Sometimes you have to create a user if you want to install a certain program. These special users usually do not need their own home directory . So to create a new account without such a directory, use the command Instead of the wildcard you have to enter the user name. Make sure that there is a capital "M" in the command. With a lower case "m" a home directory is set up . Finally, you have to activate the new account. Then the new user has already been created.
sudo useradd -M <Benutzername>
<Benutzername>
Create an account with an expiration date
A temporary account can also be created. This means that the account can only be used for a certain period of time and will then be deleted . This is particularly useful if, for example, you want to provide a visitor with an account or hire a temporary employee. It's just as easy to create as the other account types. Use the command:
sudo useradd -e JAHR-MONAT-TAG <Benutzername>
Instead of the wildcard <Benutzername>
, you must of course specify the user name.
For example, if you want to create the user "Guest" whose account will expire on July 20, 2018, the command must look like this:
sudo useradd -e 2018-07-20 Gast
Now the account only needs to be activated ..
Activate a user
After creating an account, the user still has to be activated. To achieve this, a password must be set for the user . This is done using the command Replace the user name for the placeholder. You will then be asked to set a password for the new account.
sudo passwd <Benutzername>