Linux Labs

Users, permissions, and processes / Stage 6 of 13

Accounts and their lifecycle

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 7 · on a machine · 4 min

An account is a line in a list

An account is one line in the file /etc/passwd. No line, no user, however many directories with that name lie on the disk.

getent passwd name prints the line. Its fields are separated by colons:

bash
getent passwd student newhire
Field For student
name student
password x — the password itself is kept in /etc/shadow
UID and primary group GID 1000, 1000
comment empty
home directory /home/student
login shell /bin/bash

For newhire getent printed nothing: there is no such line. The kernel stores a file's owner as a number, and ls and id take the name from this list. UID 1500 has no line, so ls -l printed the number. This happens after sudo userdel name: without the -r option it removes the line and leaves the home directory on disk.

The login shell is the program the system starts when the user logs in. Usually it is /bin/bash.

Check yourself 1 question

Which program will the system start when deploy logs in?

deploy:x:1001:1001::/home/deploy:/bin/sh
  • The last field of the line sets the login shell, and deploy has /bin/sh there. /bin/bash is in student's line.

  • x means the password is kept in /etc/shadow. Whether there is one, sudo passwd -S deploy shows.

  • That is the home directory, the sixth field: the login moves into it. The program it starts comes from the last field.

The line's last field is the login shell, and deploy's is /bin/sh. sudo usermod -s /bin/bash deploy would change it.

Key points

  • An account is a line in /etc/passwd: name, UID, GID, home directory, and login shell.
  • A directory in /home does not create an account and means nothing without one.
Ubuntu 24.04
Loading…