01. User Permissions id

Let's talk some history before we get into the technicalities..

A multi-user system

Before the advent of the personal computer, computer systems were centralized. For example, in a university, a computer would be located in one building on campus, while multiple users in other buildings accessed it via ssh (secure shell, just a way to login to another computer via the command line).

A centralized computing system

Since there were multiple users accessing this centralized computer at once, computer architects had to come up with a way to secure files and folders.

For example in the figure above, we needed a way for Professor Paul to read and edit students' grades files, while Bobby, Anna and Joe could only read their respective grade reports.

Thus, scientists came up with user permissions to manage the security threats of hosting a multi-user system.

Three groups for accessions

There are three groups in the Linux world in which permissions apply to.

The creator of the file, who has control over the file's accessions.
One or more users who are given access to the file/directories.
World (all)
Everyone else.

Using id to see who you are

To display the user and group names and numeric IDs of a calling process, use the id command.

$ id
uid=501(JohnDoe) gid=20(staff) groups=20(staff)

When accounts are created, they are given a uid (user ID), which is then mapped to a username. The user can then be assigned a primary gid (group ID).

Using who to see who is logged in

To display all current users logged in, use the who command.

$ who
JohnDoe console  Aug  3 12:56
JohnDoe ttys000  Aug 30 21:17
JohnDoe ttys002  Sep  5 21:49
JohnDoe ttys003  Sep  6 19:35

To display just the terminal session where the commands are coming from, user:

$ whoami
JohnDoe ttys000 Aug 30 21:17

Last logged in users

The to check who was last logged in, use the last command.

$ last
JohnDoe ttys000 Mon Apr 20 12:00 - 16:28 (2+04:27) JohnDoe ttys002 Mon Apr 20 11:27 - 11:48 (00:21) JohnDoe ttys001 Mon Apr 20 11:27 - 11:48 (00:21) JohnDoe ttys000 Mon Apr 20 11:27 - 11:48 (00:21) JohnDoe console Mon Apr 20 11:26 - 12:46 (94+01:19) reboot ~ Mon Apr 20 11:26 shutdown ~ Mon Apr 20 11:26 JohnDoe ttys002 Mon Apr 20 00:17 - 11:26 (11:08) JohnDoe ttys001 Sun Apr 19 23:09 - 11:26 (12:16) JohnDoe ttys000 Sun Apr 19 20:17 - 11:26 (15:08) JohnDoe ttys000 Sun Apr 19 09:32 - 19:25 (09:53)

Important files regarding permissions

There are two main files that store permission information on uid and gid.


The /etc/passwd is a file that contains information about every registered user on a system. It is a colon-separated file that contains the username, encrypted password, and user ID number.


The /etc/group text file defines which groups users belong to.


This file contains encrypted passwords and information about accounts and password reset dates. This information is held secure from normal users, and is only accessible by root.


This is a directory that contains the base files and directories moved into a new user's home folder upon creation.

Take your Linux skills to the next level!

Linux for Beginners

Take your Linux skills to the next level! Try Linux & UNIX

Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.

$ Check price
24.9924.99Amazon 4.5 logo(101+ reviews)

More Linux & UNIX resources

Aching back from coding all day?

Inversion Therapy Table

Aching back from coding all day? Try Back Problems

Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.

$$ Check price
119.98119.98Amazon 4.5 logo(1,700+ reviews)

More Back Problems resources