Linux Permissions That Protect Your Data — Ownership, Inodes and Symbolic Links Without Headaches
> cd .. / HUB_EDITORIALE
Sistemi Operativi & Sicurezza

Linux Permissions That Protect Your Data — Ownership, Inodes and Symbolic Links Without Headaches

[2026-08-08] Author: Ing. Calogero Bono
> share
Zenithby Meteora Web The operating system for your business. Social, clients, bookings and invoices in one platform. Gyms, barbers, professionals. Discover Zenith Free demo · no card

Your Linux server goes live and someone uploads a file with wrong permissions. The site breaks, the client calls you at 8 PM, and you discover the issue is a chmod 777 in the wrong place. It happens every day. And it's not bad luck: it's a lack of understanding of the filesystem. At Meteora Web, we see it in projects that come to us: permissions left for convenience, confused ownership between users, symbolic links pointing nowhere after a deploy. This guide gives you the tools to really understand how permissions, ownership, inodes and symbolic links work in Linux. No theory for its own sake: only what you need to avoid waking up with an offline server.

How do Linux permissions work and why is chmod 777 a trap?

Permissions in Linux are your basic security system. Every file and directory has three permission groups: read (r), write (w) and execute (x). These apply to three user categories: owner (u), group (g) and others (o). When you see -rw-r--r--, you're reading: the owner can read and write, the group and others can only read. Simple, right? The problem comes when someone applies chmod 777 — everyone can do everything. On a shared or internet-exposed server, it's like leaving your front door open. An attacker can modify files, inject malicious code or delete data. We always tell clients: permissions are your first line of defense. Don't sacrifice them for convenience.

The three chmod numbers and how to read them without a calculator

chmod accepts a numeric notation: chmod 755 file. Each digit is the sum of values: 4 for read, 2 for write, 1 for execute. So 7 = 4+2+1 (read, write, execute), 5 = 4+1 (read and execute), 6 = 4+2 (read and write). For a directory, execute means being able to enter with cd. A common mistake is giving chmod 777 to an upload directory: the web server can write, but so can anyone else. Better to use chmod 755 for directories and chmod 644 for files. If you need to give group write access, consider chmod 775 — but only if the group is restricted.

Sponsored Protocol

# Set correct permissions for files and directories
chmod 644 index.php
chmod 755 /var/www/html/uploads
# Verify permissions
ls -l index.php
# Output: -rw-r--r-- 1 user group 1024 Jan 1 12:00 index.php

The golden rule: never use 777. If you think you need it, your architecture is wrong. At Meteora Web, we fix problems caused by overly permissive permissions every week. An attacker with write access to a PHP file can execute arbitrary code. That's how many ransomware attacks start.

How to manage ownership and groups to avoid conflicts between users and services?

Ownership — who owns a file — determines who can apply permissions. In Linux, every file has an owner and a group. When the web server (e.g., www-data) needs to write to a directory, but the owner is root, the system blocks. The classic mistake: you create a site with your user, then the server can't upload images. The solution isn't chmod 777, but changing ownership with chown. For example, chown -R www-data:www-data /var/www/html assigns everything to the web server. But careful: if you need to modify files via FTP with another user, you create a conflict. The right strategy is to use groups. Add your user to the www-data group and set group permissions to 775. That way both you and the server can work without lockouts.

The chown command and managing secondary groups

To add a user to a group: usermod -a -G www-data your_user. Then verify with id your_user. Once in the group, you can write to files owned by the group. Remember: the change requires logout and login to take effect. At Meteora Web, we use this technique for projects shared between developers and servers. It's clean, secure, and doesn't require permissive permissions.

# Change ownership recursively
chown -R www-data:www-data /var/www/mysite
# Add your user to the server group
usermod -a -G www-data your_user
# Verify groups
id your_user

Another common mistake: using chown -R on the whole filesystem or system directories. You can break boot. Limit the command to your project directories. And when you deploy, think about who needs to write: if you use a separate deploy user, don't give access to everything, only what's needed.

Sponsored Protocol

What are inodes and why can't you ignore them when the disk fills up?

Inodes are the ID cards of files. Every file and directory has an inode that stores metadata: permissions, owner, size, timestamps, and the location of data blocks. The file name is just a label pointing to the inode. When you copy a file, you create a new inode; when you move it, you reuse the same one. The practical problem: the filesystem has a finite number of inodes. If you create millions of small files (e.g., cache, sessions), you exhaust inodes even if the disk has free space. The server errors with messages like "No space left on device" even though df -h shows GB free. We've seen this on servers with misconfigured cache. The solution is to monitor inodes with df -i and clean temporary files.

How to check and free exhausted inodes

Use df -i to see inode usage. If the percentage is high, find directories with too many files: find /var/www -type f | wc -l. To delete old files, find /tmp -type f -mtime +7 -delete. Be careful not to delete system files. Another strategy: configure logrotate for system logs and limit PHP sessions with session.gc_maxlifetime. Prevention is better than cure.

# Check inode usage
df -i
# Find directories with many files
find /var/www -type f | wc -l
# Delete temporary files older than 7 days
find /tmp -type f -mtime +7 -delete

Remember: inodes don't expand. If your filesystem is nearly full on inodes, you need to clean or resize. At Meteora Web, we recommend monitoring both space and inodes in your alerting systems. A disk with exhausted inodes is a server that freezes without warning.

How do symbolic links work and when to use them to avoid breaking deploys?

Symbolic links (symlinks) are shortcuts: a file that points to another file or directory. They're essential for deploys: instead of overwriting files, you create a new version and change the link. Downtime is zero. The command is ln -s /real/path /link/path. A common mistake: creating wrong relative links. If you use ln -s with a relative path, the link points to a nonexistent place. Better to use absolute paths. Another mistake: deleting the original file. The link becomes broken and the application errors. We see this often with config files: someone moves the file and the symlink hangs.

Sponsored Protocol

Symbolic links vs hard links — what changes and when to choose

Hard links are another name for the same inode. If you modify a hard link, you modify the original too. But you can't create hard links for directories or across filesystems. Symbolic links, instead, point to the file name, not the inode. If you delete the original, the symlink breaks. For deploys, symlinks are the right choice: you can change the active version with a single command. Hard links are useful for deduplicating identical files, but they're less flexible.

# Create a symbolic link with absolute path
ln -s /var/www/releases/v2.1 /var/www/current
# Verify the link
ls -l /var/www/current
# Output: lrwxrwxrwx 1 root root 22 Jan 1 12:00 /var/www/current -> /var/www/releases/v2.1
# Remove a symbolic link (not the original file)
unlink /var/www/current

Be careful: when deploying with symlinks, make sure the link points to the right directory. A ln -sfn command updates the link without errors. And don't forget: the link's permissions don't matter, only those of the pointed file. If the file has 600 permissions and the web server can't read it, the symlink doesn't help.

How to diagnose permission and link issues with terminal tools?

When something doesn't work, the terminal is your best friend. Commands like ls -l, stat, namei and readlink tell you everything. stat shows inode, permissions, ownership and timestamps. namei resolves paths and shows if a link is broken. readlink tells you where a symlink points. At Meteora Web, we use these commands daily to debug client servers. An example: the site doesn't load images. ls -l on the directory shows 755 permissions, but the file is 644 and owned by root. The web server can't write. The solution is changing ownership or permissions, not the link.

Sponsored Protocol

Quick diagnosis checklist

Here are the steps we always take: 1) ls -l to see permissions and ownership. 2) stat file for details on inode and timestamps. 3) namei -l /full/path to verify every path component. 4) readlink link to check the destination. If the link points to a nonexistent file, ls -l shows a question mark. That tells you immediately the issue is a broken link.

# Full diagnosis of a file
stat index.php
# Resolve the path and verify permissions
namei -l /var/www/current/config.php
# Check the destination of a link
readlink /var/www/current

Another powerful tool is find with permission options: find /var/www -perm 777 finds dangerous files. Or find /var/www -type l ! -exec test -e {} \; -print to find broken links. These commands save your day. We include them in audit scripts for our clients.

How to protect the filesystem with ACLs and extended attributes?

Basic permissions aren't always enough. ACLs (Access Control Lists) allow giving specific permissions to multiple users and groups, beyond the owner and group. For example, you can give one user read-only on a directory, and another read-write. The command is setfacl -m u:user:rwx directory. Extended attributes, like chattr +i, make a file immutable: it can't be modified, even by root. This is useful for critical config files or protecting against ransomware. We use chattr +i on backup files and private keys. But careful: to remove the attribute, you need chattr -i, and it doesn't work on all filesystems.

Sponsored Protocol

When to use ACLs over traditional permissions

ACLs are useful in environments with multiple users sharing directories (e.g., team projects). Traditional permissions suffice for most cases. But if you need granular control, ACLs are the answer. An example: the web server needs write access to a directory, but a development user should only read. With basic permissions, if the group has write, all members write. With ACLs, you give the web server write and the user read-only. Management is more complex, but control is total.

# Set an ACL for a user
setfacl -m u:developer:r-x /var/www/project
# Verify ACLs
getfacl /var/www/project
# Make a critical file immutable
chattr +i /etc/nginx/nginx.conf
# Remove immutability
chattr -i /etc/nginx/nginx.conf

ACLs are a powerful feature, but don't use them if not needed. Unnecessary complexity is a cost. At Meteora Web, we recommend them only when basic permissions aren't enough. And for extended attributes, test on a dummy file first: a chattr +i on a system file can block updates and services.

What to do now

Don't wait for the server to break. Put these actions into practice right away: 1) Check your file permissions with find /var/www -perm 777 and fix dangerous ones. 2) Verify ownership of your project directories: ls -l /var/www and change with chown if needed. 3) Monitor inodes with df -i and set an alert if the percentage exceeds 80%. 4) Use symbolic links for deploys: create a releases/ structure and a current link. 5) Protect critical files with chattr +i and document exceptions. If you need a hand, we at Meteora Web work on these topics daily: our pillar guide on shell scripting and Linux automation is a good starting point for deeper dives. And if you want to understand how cyber threats are evolving, read our article on the first AI-created virus: filesystem security is your first trench.

> share
Ing. Calogero Bono

> AUTHOR_EXTRACTED

Ing. Calogero Bono

Ingegnere informatico, fondatore di Meteora Web e Zenith OS. System administrator e progettista di piattaforme, app e CMS proprietari, con esperienza in sviluppo full-stack, marketing digitale ed ecosistema Google.
[ Read Full Dossier ]

> METEORA_WEB // DIGITAL AGENCY

We build the digital presence your business deserves.

Websites, social media, online advertising, e-commerce and high-performance hosting, engineered with method by computer engineers in Sciacca, for all of Italy.

> MW_JOURNAL

> READ_ALL()