Marcio Cunha

Understanding 755 and 644 Permissions in Linux: How They Work

Learn how the numeric permission codes 755 and 644 work in Linux files, ensuring robust security without breaking servers and web applications.

Marcio Cunha12 min
Also available in:EspañolPortuguês
Summary
  • The numbers 755 and 644 represent mathematical sums of permissions to read, write, and execute files in Unix systems.
  • The 644 code protects common files like source code and web pages from unauthorized modifications by visitors.
  • The 755 permission grants execution rights exclusively to directories and scripts, allowing the operating system to navigate them.
  • Changing permissions carelessly exposes severe security flaws or prevents web apps from reading their own files.
  • The chmod command translates these numbers automatically into the operating system core without requiring complex daily math.

What Are Linux Permissions and Why Do They Matter

When you use a Linux-based operating system, every single file and folder comes with an invisible set of rules that defines exactly who can view, modify, or run that content. These rules form the foundation of system security, preventing malicious programs from altering vital operating system files or stopping users from peeking at confidential data. In practice, managing permissions is like keeping a house locked where certain people have the main door key, others can only look through the window, and casual visitors cannot enter at all.

To organize this system, Linux divides actors into three distinct categories: the owner, who usually created the file; the group, which gathers team members or related processes; and others, representing the rest of the world, including any internet visitor. Each of these three groups receives independent permissions for reading, writing, and executing. When we talk about codes like 755 and 644, we are looking at a numeric system that summarizes these permissions compactly so the computer can process them efficiently.

The Math Behind the Numbers: Read, Write, and Execute

Before grasping 755 and 644 in practice, it helps to uncover the mathematical secret behind these digits. The classic Linux permission system assigns a numeric value to each basic action: reading a file is worth 4 points, modifying or saving it is worth 2 points, and executing it — running a program or opening a directory — is worth 1 point. If you want someone to both read and write, you add 4 and 2, resulting in 6. If you want to allow everything, you add 4, 2, and 1, reaching the number 7.

Since we have three user categories — owner, group, and others —, we need three digits to represent a complete rule set. The first digit defines the owner's powers, the second indicates group rules, and the third controls the rest of the world. When someone says a file has 755 permission, it means the owner has value 7 (everything allowed), the group has value 5 (read and execute, since 4 plus 1 equals 5), and the rest of the world also has value 5.

Anatomy of 644 Permission in Common Files

The 644 permission is the most recommended default setting for static files on web servers, such as HTML pages, CSS style sheets, images, and simple configuration files. The number 6 for the owner means they can read and alter the document at will. The number 4 for the group indicates that other users on the same server can read the file, but cannot modify it by accident or malice. The last number 4 repeats this same restriction for the rest of the world.

In practice, this prevents an intruder who gains access to your server from injecting malicious code into your script files or web pages. If a static page were configured with write permission for everyone, any random web visitor could modify it and deface the site. The 644 setting ensures that only the legitimate owner — usually the user account managing the system — can perform structural alterations.

The Necessity of 755 in Folders and Executable Scripts

Unlike regular text files, folders and executable programs require an extra permission: the execution capability. In the Linux world, a folder is not just storage space; it functions as a corridor that the operating system must walk through to find files inside it. If you remove the execution permission from a folder, the operating system loses the ability to enter it or list its contents, even if you have read permission over the internal files.

This is why directories and scripts that need to run in the system use the number 755. The 7 for the owner grants full read, write, and navigation access. The numbers 5 for the group and the rest of the world ensure that any person or process can navigate the directory and read or execute the programs inside it, without risking modifications to the original structure. On web servers, for instance, the server must navigate folders to deliver pages to visitors, making 755 mandatory for directories and 644 essential for files.

How to Change Permissions Using the Chmod Command

To apply these rules in practice, we use the chmod command directly in the Linux terminal. The name comes from change mode. If you have a text file named index.html and want to transform it into the secure web file standard, simply type chmod 644 index.html. Immediately, the system rewrites internal permissions according to the math we discussed, without requiring bit-by-bit manipulation.

Similarly, if you created a new folder named images on your server and want the system to access it correctly, the proper command will be chmod 755 images. It is crucial to remember that applying overly open permissions, like giving full write access to the world using 777, creates critical security vulnerabilities that invite cyber attacks. Conscious use of 755 and 644 balances application usability with strict data protection.

Final Considerations on Security Best Practices

Mastering how 755 and 644 permissions work in Linux is a turning point for anyone managing servers or developing applications for production environments. While they might look like abstract numbers at first, they represent the first and most crucial firewall against unwanted access and operational failures. By rigorously adopting 644 for static files and 755 for folders and executables, you ensure your infrastructure remains accessible to those who need it, while firmly locked against unauthorized changes.