31.08.2023

File permissions in Linux

Introduction

Access and permission control for files serve critical purposes in the realm of data management and security:

In summation, access and permission control are instrumental in upholding the security, confidentiality, and soundness of files and data. They thwart unauthorized access, prevent data breaches and losses, and contribute to regulatory compliance.

Requirements

Permission and attributes on Linux

In the Linux environment, the management of files and permissions is a thorough and intricate process, designed to ensure the utmost security and precision in handling data. Here's a more in—depth look. Linux recognizes a spectrum of file types, including regular files, directories, symbolic links, and devices. Each type possesses unique attributes and permissions. In the Debian 12 we can check all attributes and permission of all users by the command below:

ls -l

Screenshot №1 — List of permission

But if we want to chek out determine file, then we need to use command below, indicate file that you want to check:

ls -l /etc/network/interfaces

Screenshot №2 — Single file

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

Each file is linked to an individual user (owner) and a designated group. The act of creating a file establishes the creator as its owner, while a specific group is assigned to the file. Linux segments permissions into three categories: user, group, and others. Every category can be assigned distinct read, write, and execute permissions. And we can change all of that if we have right and straight permission to that by the chmod utility.

Permissions are also translatable into numeric forms, where read (r) equates to 4, write (w) to 2, and execute (x) to 1. The cumulative sum represents the numerical permission, such as 755.

chmod 755 interfaces

Screenshot №3 — Chmod numeric

But if we want to deny all permissions to the all type of users, we need to write command below:

chmod 000 interfaces

Screenshot №4 — Chmod numeric deny

The chmod command serves to modify permissions. This command accepts both symbolic and numeric notations. For instance, chmod u+w filename confers write permission to the owner. The u means owner, g assign to group, o for others and a for all . Then we indicate + or - or = to add, delete, indicate explicitly permission 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

That's basics of permission on the system, but what if we need more?

Utility for addition control permission

In Linux, the core kernel provides a solid foundation for the operating system, but it doesn't include all possible features and functionalities by default. The reason additional modules and packages are required for controlling access and file permissions is to give system administrators and users the flexibility to tailor the system's behavior to their specific needs. Here are a few reasons why this approach is taken:

As you could highlight standart access control system have several lack: there isn't system protect by random deletion significant file, integrity file system and etc. Let's upgrade system!

Umask Usage: The umask command regulates default permissions for novel files and directories. It achieves this by deducting the specified mask from the maximum permission value to set defaults. By the default we can see that list of permission:

Screenshot №6 — Default permission

You can see default list of permission for file, lets change it:

umask u=rwx,go=

Screenshot №7 — Umask

That solution will help for time before you turn of machine or connection, for more long working that system you can add to the .bashrc or bash_login needed raw!

Conclusion

The combination of well—defined access controls, precise permission settings, and the flexibility to add supplementary tools empowers system administrators to create a secure and tailored environment for managing files and data in the Linux ecosystem.