Linux Fundamentals 4: User Management

Quick Facts

  1. In Linux users and groups are used for access and permissions.
  2. Each user has their own UID and home directory.
  3. When running a process it will run as the owner of the process.
  4. Groups are a set of users with permissions set by the group.
  5. The superuser or root is the most powerful user - use sudo to run the with root


To view the user configuration you can look in the /etc/passwd file

cat /etc/passwd

The user is displayed in the following format.

username : user password (if x stored elsewhere) : user id : user group id : GECOS field (comments) : user home directory :  users shell


The /etc/shadow file stores info about the users authentication.

sudo cat /etc/shadow

The results can be read in the following format.

username : encrypted password : date of last password changed : minimum password age : maximum password age : password warning period  : password inactivity period  : account expiration date : reserved field for future use


The /etc/group shows groups with the assigned users.

/cat /etc/group

The results can be read in the following format

group name: x : group id : list of users

Add a User

For this example I will create a user called 'aem'.

sudo useradd aem

check the user exits by running

cat /etc/passwd

We can see the user is assigned 1001, this is because id's + 1000 plus are reserved for local users. system users are assigned 1 to 999. Id 0 is always for the root user.

Set the user password

To set the users password I will run the following command.

sudo passwd  aem

You will be asked to set the password. Once complete check  /etc/shadow and you will see the created authentication for the AEM user.

Modifying a User

The usermod command can be used to modify the users configuration. Some of the common uses are below. Use man usermod for full details

  • Add/Modify a users group
  • Change GECOS - user info
  • Change user home directory.
  • Change user Shell

Delete a User

To delete a user you can use the userdel command.

sudo userdel aem

you can confirm removal by checking the /etc/passwd/.

Next up in part 5 of Linux fundamentals we will discuss user permissions.