Linux Administration: Managing Users

I fell in love with Linux!

I’m back with something different. Not completely different, but not the usual stuff.

Since I started on this journey to learn the cloud, I’ve been enjoying Linux a lot. It’s super fun to learn, and to use. The Linux community is great, and it has so many possibilities. Linux is powering the world! And the cloud is made of Linux particles!

So besides learning Azure, which I’m very passionate about, I want to dive deep into Linux.

I’m a newcomer to this universe. I don’t know why, to be honest. I’ve always liked tech, and Linux was frequently catching my attention. Maybe what drew me those days to read about Linux, or to investigate more,.was mainly the culture around it. I found it fascinating! I don’t know why it took me so long to actually start using Linux. But here I am!

Last year I took the LPI Linux Essentials certification. It’s a great place to start, and I recommend it for beginners. Now I want to try and get the LPIC-1 certification. You need to pass two exams to get this one. I still haven’t planned anything solid, but I want to share my learning journey here on my blog.

So, here we go! In this article I will share some, or most, of what I’ve learned on managing users. I hope some of you can find it useful. You can always hit me up, to correct me, or to add something you believe I might have missed.

For this article, I used the Windows Subsystem for Linux. The screen captures are from the WSL running Ubuntu 20.04. I have another laptop running Xubuntu. It’s a flavor of Ubuntu, and I like it a lot. I highly recommend this distro if you have a machine that’s low on resources, and you want to make the most out of it.

Users on the Linux Operating System

Linux is a multi-user, multi-terminal operating system, which means that multiple accounts can exist, and they can be used at the same time. User accounts keep boundaries between the people who use your systems and between the processes that run on the system. That’s why every person using a Linux system should have a separate user account.

User accounts in Linux have the following features:

  • Username (or Login ID)
  • UID (User ID), a unique number that represents the user
  • Default group to which the user belongs
  • Comments
  • Shell
  • Home directory location
When a user is created, an entry is added to the /etc/passwd file.

The /etc/passwd file

/etc/passwd is a text file with one entry per line, with each line representing a user account. The file can only be modified by root users or users with sudo privileges, but can be read by all users of the system.

Modifying the /etc/passwd file by hand should be avoided. Always use commands designed for this purpose, like useradd or usermod.

To view the contents of the /etc/passwd file we can use the cat command.

$ cat /etc/passwd
The /etc/passwd file.

The first line describes the root user, followed by the system and normal user accounts.

Each line of the /etc/passwd file contains 7 fields, separated by a colon.

User details

The username

Even though Linux supports usernames of up to 32 characters in length, it is customary to keep usernames to 8 or fewer characters.

Usernames are case sensitive. Uppercase characters are allowed, but by convention usernames are all lowercase.

Numbers are allowed, but avoid using special characters.

The password

Encrypted passwords used to be stored in /etc/passwd. Now, passwords are stored in the /etc/shadow file, which can be read only by root. More on passwords later.


The UID is a unique number that represents each user account in the system.

The root account is always UID 0.

System accounts have UIDs which are lower than 1000

Regular users have UIDS of 1000 and up.


The group ID listed in the /etc/passwd file is the default group for the account.

The comments field

Also known as the GECOS field, the comments field typically contains the user’s full name. It may also contain additional information about the user, like phone number, building and room number. Each field is separated by a comma.

Non-root users can change their own information by using the chfn command.

The chfn command.

For system accounts, the GECOS field usually contains a short description of what the account is used for.

Home directory

When the user logs in to the system, he, or she is placed in their home directory specified in the /etc/passwd file. If the directory doesn’t exist, they’ll land in the root (/) directory.


The shell listed in the /etc/passwd file will be executed when the user logs in to the system.

A list of available shells can be found in /etc/shells.

Available shells.

If you set the shell to /usr/sbin/nologin, it will prevent the user to login to the system. The user will see a message that reads that the account is currently not available.

/bin/false is a type of shell similar to /usr/sbin/nologin. The user won’t be able to login to the system, but won’t see any message.

Creating new users

To create users, we use the useradd command.

$ sudo useradd [options] username

Options used with the useradd command:

  • -c "Comment": comments for the account.
  • -m: creates the home directory.
  • -s /shell/path: the path to the user’s shell.

Alternatively, we can use the adduser command, instead of useradd. The adduser command is more user-friendly and interactive, prompting you for the user details. It will automatically create a home directory for the user, unlike useradd where you need the -m flag.

The adduser command.

Linux Is Cool

This is what I’ve been studying these days. I want to talk about groups too. Maybe my next article will be about groups. But I definitely want to write about the Linux file system. This one is a must! It’s not something so simple to wrap your mind around if you’re coming from Windows.

Thank you for reading this far. Please let me know if you find anything wrong or if you feel something can be improved. I want to improve, and I want to do it together with you.

See you soon!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s