Linux Users and Permissions

by Felix Kinaro About 2 min reading time

Overview

We explore the concept of users and permissions and their importance

User and Group Identifiers

How to find the UID and GID

sudo cat /etc/passwd

UID Demo
The columns are as follows:

Permissions

Permissions are divided into 4 categories of users:

There can be a combination of read (r), write (w) and execute (x). They can be assigned easily with the plus and minus signs to add or remove certain permissions. These modifications are done using the chmod command.

Binary references

We can use numbers as well to set the permissions of a file. Here is a simple table to demonstrate this.

For example we need to ensure that only I can view or modify my SSH keys directory. We can do this by running the following:

chmod 0600 ~/.ssh

This will deny all others the rights to view the contents. I on the other hand will be able to read (4) and write (2).

Ownership

The chown command is used to set the ownership of a file.

chown kinaro:kinaro text.txt

This sets the ownership of the file to user 'kinaro' and group 'kinaro' as well.

Other Attributes

Significance of permissions

Subscribe to receive weekly articles

Your data is handled by Buttondown.