Master Guide to Managing File Ownership and Permissions in Linux

Last update: 15/09/2026
Author Isaac
  • Technical differentiation between modifying access permissions using chmod and changing resource ownership with chown.
  • Permission representation system based on octal and symbolic notation for users, groups, and others.
  • Implementation of security strategies based on the principle of least privilege to prevent vulnerabilities in servers.

Setting up a dark room with code displayed on PC monitors highlighting cybersecurity and Linux system administration topics.

If you've ventured into managing your own VPS server or dedicated machine, you'll have realized that Linux is a system designed from the ground up for networking. That's why security is paramount , since controlling who can read, edit, or execute a file is what prevents your information from falling into the wrong hands or a malicious process from crashing the entire system.

To navigate this environment with ease, simply knowing how to run commands isn't enough; you need to understand the logic behind file ownership. In Linux, every resource belongs to a user and a group , and this is where the tools for adjusting these privileges come into play, allowing us to secure the system without blocking our applications from working.

Unlock file permissions in Linux
Related articles:
Complete Guide to Managing and Unlocking File Permissions in Linux

Understanding the anatomy of permits

Detailed view of a data center with servers and network cabling, representing the environment of a VPS or dedicated server.

When you launch a command ls -l In the terminal, you'll see a string of characters that looks like a secret code, something like -rwxr-xr--Don't worry, it's simpler than it seems. The first character tells us What type of element do we have in front of us?A hyphen indicates a regular file, 'd' a folder (directory), and 'l' a symbolic link. There are also less common characters such as 's' for sockets or 'p' for pipes.

The following nine characters are divided into three equal sets of three. The first set is for the owner (the one who created the file), the second for the owner group , and the third for all other users on the system. Each set of three characters can contain the letters 'r' (read), 'w' (write), and 'x' (execute), or a hyphen if that permission is not granted.

High-tech server with blue lighting in a modern data center, representing the distributed systems infrastructure.
Related articles:
Permission Management in Distributed Systems and Strategies to Mitigate Security Failures

What does each permit really mean?

  • Reading (r): In a file, it allows you to open it and see what's inside. If we're talking about a folder, it means you can list the files and subdirectories containing.
  • Writing (w): It gives you the power to modify the contents of a file or even delete it. In the case of directories, it allows you to create, delete or rename elements within it.
  • Execution (x): For a file, it's what allows a script or program to run. In folders, this permission is vital because it's what allows you to... access the directory using the command cd.

The chmod command: Adjusting access

Laptop displaying a security padlock icon on a table, symbolizing file and permission protection in Linux.

The command chmod (change mode) is our tool for altering these permissions. There are two ways to use it: symbolic, which is more intuitive, and octal, which is preferred by administrators because it is faster.

  How to share files and folders on a local network in Windows 11

On symbolic modeWe use letters to indicate who the change affects (u for user, g for group, o for others, a for everyone) and symbols like '+' to add or '-' to remove permissions. For example, if you want the group to be able to write to a file, you would use chmod g+w archivo.txtIt's a very flexible way to adjust permissions as needed without altering the rest of the configuration.

Professional view of server racks in a modern data center, representing the infrastructure where containers are deployed.
Related articles:
Complete Guide to Permission and Security Errors in Containers

El octal mode It uses numbers based on the binary system. Each permission has a value: read is 4, write is 2, and execute is 1. Adding these values ​​gives us a number from 0 to 7. For example, the value 7 (4+2+1) means full access, while 5 (4+0+1) means read and execute. Thus, a command like chmod 755 carpeta grants total control to the owner and only read/execute access for the group and others.

Managing the property with chown and chgrp

Close-up of colorful text on a computer screen showing cybersecurity concepts and terminal commands.

Sometimes, even if the permissions are correct, the file won't work because the owner isn't the right person. That's where [the appropriate tool/app/device] comes in. chown (change owner). This command allows change user and group who possess the file. The most common syntax is chown usuario:grupo archivo.

It is very common on web servers for files to belong to the server user (such as www-data in Apache or Nginx) so that the website can write to certain folders. If you need to apply this change to a folder and everything inside it, you must use the recursive option -R, for example, running chown -R www-data:www-data /var/www/html.

Detailed view of a DiskStation NAS server, representing the network-attached storage infrastructure.
Related articles:
Complete Guide to Configuring Users and Permissions on a NAS

User and group administration in the system

Hand holding a brass padlock, symbolizing permission management and access control to the system.

For all of the above to make sense, we first need to manage who those users are. In Linux, commands like useradd o adduser to create accounts, and passwd to assign them a key. All this information is stored in critical files such as / Etc / passwd (account details) and / Etc / shadow (encrypted passwords).

  Practical examples of using nice, renice and ionice in Linux

Groups are essential to avoid having to assign permissions one by one. groupadd We created the group and with usermod -aG We add users to it. In this way, we can give collective permits for a work team on a specific folder without compromising the security of the rest of the system.

Professional workstation with multiple monitors displaying Linux terminals and system monitoring, ideal for representing system administration.
Related articles:
How to recover the root password in Linux: A complete guide

Sweats and elevated privileges

It's not recommended to always work as root, since a mistake could wipe the entire system. For this, we use sudowhich allows us to execute commands with superuser privileges. The configuration of who can do what is found in the file / Etc / sudoerswhich must always be edited with the command visudo all with troubleshooting sudo errors in Linux and avoid syntax errors that would leave us out of the system.

Security and best practices on servers

A common mistake many beginners make is assigning 777 permissions to a folder when something isn't working. This opens the door wide to any attacker. Ideally, you should follow the principle of least privilege : grant only the minimum access necessary to complete the task.

As a general rule, files should have permissions of 644 (the owner writes, everyone else can only read) and folders 755. For extremely sensitive files, such as SSH keys or password-protected configuration files (.env), permission 600 is the correct setting, ensuring that no one other than the owner can even read the contents.

Modern server with blue lighting in a data center, representing the robust infrastructure of Linux.
Related articles:
Complete Guide to Linux Security: Managing Critical Updates and Patches

If you encounter the dreaded 403 Forbidden error on your website, it's most likely due to an ownership or permissions issue. Before making any drastic changes, verify that the web server owns the files and that the directories have the execute bit set to allow navigation.

  Windows .SYS Files: What They Are and How to Manage Them

Proper management of users, groups, and permissions using tools like chmod and chown is the first line of defense for any Linux server. From using the umask mask to define default permissions, to recursive directory management and strict control of sudoers, every adjustment contributes to creating a stable and resilient environment against potential intrusions, ensuring that system processes and human users can coexist without compromising data integrity.

Modern server rack with blue lighting in a secure data center, representing the Linux server infrastructure.
Related articles:
Linux: A complete guide to configuring the UFW firewall and protecting your server