User Management

User Management

While using Linux it is important to understand how to add and delete users. Linux a true multiuser operating system as it supports (with ease) remote users. During this section you will learn how to go add a user, change user information, configure a password policy and even learn how to expire an account. Linux is a secure OS already, but we want to make sure that we do our part to keep it as secure as possible!

adduser and/or useradd

These two commands (adduser and useradd) provide you with the ability to create a new user in Linux. When adding a user I like to use the adduser script, but this is not always available in each distro of Linux.

The adduser script (we will learn about scripting later) uses the useradd compiled binary, so even if you use adduser you are still using useradd.

This is why it is also important to learn how to use useradd.

https://linux.die.net/man/8/useradd

https://linux.die.net/man/8/adduser


userdel

Just as we need to be able to add a user to our system, we also need the ability to remove a user. This is where the deluser commands assists our needs. Depending on the options provided to deluser you can either maintain a users file or delete them.

https://linux.die.net/man/8/userdel

usermod

Once an account has been created we need the ability to update this accounts settings. This can be done by using the usermod command. A majority of the time I use this account to set an expire date or update the groups an account belongs too (groups are covered next).

https://linux.die.net/man/8/usermod

Please visit the following website to see 15 great examples of the usermod command and what it can do.

https://www.tecmint.com/usermod-command-examples/

chage

The chage command also has the ability to update an user accounts password expiry information. As mentioned before, Linux provides multiple ways of doing the same thing. Just get comfortable with one of these ways.

https://linux.die.net/man/1/chage


passwd

The passwd command allows a user (or root user) to update an accounts password. This is a very straightforward command, so please make sure to read the examples of using it.

https://linux.die.net/man/1/passwd

https://www.linuxtechi.com/10-passwd-command-examples-in-linux/



Important Files

Below are a two important files and a directory that you need to understand how they are used and what they are used for.

They are:

  1. /etc/passwd (a file)

  2. /etc/shadow (a file)

  3. /etc/skel/ (a directory)

The /etc/passwd file is used to store basic user account information. While the /etc/shadow file is used to store the hashed password of the account. Finally, the /etc/skel/ directory is copied over to a new users home directory. If you want a specific directory structure of even file added to every new users you can by placing it in the /etc/skel/ directory and when a new account is created it will automatically be copied over!