22.08.2023

Linux chmod command

Introduction

By the default set of module in various of distributes UNIX-like systems have Discretional Access Control on the panel for control permission. That mean every user of the system have own rights and access to processes and files. Highlight, in Linux is pretty more things could be a file: devices, common file, directories, links and etc. For that type of data we manage attributes of the file, which contain: owner, group, size, type data. By the first and second parameters we can track who has access and rights to change permission.

Requirements

Permission and attributes on Linux

In Linux we can check attributes and permission by the command below:

ls -l

Screenshot №1 — List of attributes

But if we want to look at attributes single file, that you need type command below:

ls -l /etc/network/interfaces

Screenshot №2 — Single file attributes

Let's be clear and explain every parameter in that screen:

Each individual file is associated with a single user (owner) and a designated group. When a file is created, the person creating it becomes its owner, and a particular group is allocated to that file. Linux divides permissions into three primary categories: user, group, and others. Each category can receive separate permissions for reading, writing, and executing. These permissions can be modified using the chmod utility, provided the user has the necessary authorization and explicit permissions to do so.

Permissions also can be represent like sum of numbers. That we use for assign permission: 4 - for read, 2 - for write and 1 for execute:

chmod 755 interfaces

Screenshot №3 — Numeric chmod

However, if our intention is to completely prohibit all forms of access for all categories of users, we must enter the following command:

chmod 000 interfaces

Screenshot №4 — Numeric deny

The chmod command is utilized for altering permissions and supports both symbolic and numeric representations. For example, when using chmod u+w filename, it grants the owner write permission. In this context, u signifies the owner, g is assigned to the group, o represents others, and a encompasses all users. Afterward, the +, -, or = signs are used to respectively add, remove, or explicitly define permissions for users.

chmod u+rwx interfaces && chmod go-rwx interfaces

Screenshot №5 — Chmod symbolic

Or we can use equal command:

chmod u=rwx, go= interfaces

If you want to save write permission for other and group users, but you need protect them from delete, then use command below:

chmod +t interfaces

Conclusion

This journey has unraveled the complexities of permissions and attributes in the Linux realm. Mastery of these concepts is crucial for maintaining data security and effective system administration.