AI Hints
Home›Linux Tutorial›Users and Permissions
Linux · Lesson 62 of 120

The User List

/etc/passwd and /etc/group.

⏱ 2 min read▶ Video at 1:20:26🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

Linux keeps its list of users in a plain text file. You can read it yourself, with the commands you already know. It's a nice reminder, that on Linux, almost everything is a file.

The User List
From the video: The User List
  • Users live in a text file
  • Read it yourself
  • Almost everything is a file

Reading slash etc slash passwd

The file is slash ETC slash passwd. Each line is one user, with fields separated by colons. There are lots of system users, so we only look at the last two lines, with tail. There's Sam, and a second person, Alex.

Terminal
tail -n 2 /etc/passwd
sam:x:1000:1000::/home/sam:/bin/bash
alex:x:1001:1001::/home/alex:/bin/bash
grep sam /etc/passwd
sam:x:1000:1000::/home/sam:/bin/bash

The fields

Let's read Sam's line, field by field. The username, sam. An X, which means the password is stored somewhere else, in a protected file. The user number, one thousand. The group number. A description. The home folder, slash home slash sam. And the shell, bash.

FieldValueMeaning
1samusername
2xpassword kept elsewhere
3, 41000:1000user and group numbers
6/home/samhome folder
7/bin/bashlogin shell

Groups are in a file too

Groups live in slash ETC slash group, in the same colon separated style. The sudo group lists its members at the end. That's how Linux knows Sam is allowed to run admin commands.

Terminal
grep sudo /etc/group
sudo:x:27:sam

Summary

Users are listed in slash ETC slash passwd, and groups in slash ETC slash group. Passwords are kept somewhere safer. Next, permissions.

Key takeaways
  • /etc/passwd
  • /etc/group
  • Fields split by :
Next up: Permissions Explained — read, write and execute