What is the Meaning of chmod 755, and How to execute and Verify It?

In Linux, chmod is a built-in command that manages the access permission of file objects (files and directories). It can assign groups, users, and others to have permission for executing, reading, and writing permission on a certain file or directory.

The number defined after chmod represents the permissions. The chmod 775 is an essential command that assigns read, write, and execute permission to a specific user, group, or others.

In this guide, check out how to use chmod 755.

Chmod basics

Before diving deeper, let’s have a look at the basics of chmod. Because Linux is a multi-user system, it’s important to have a proper file permission system that controls user access. For any file or directory, there are 3 types of permissions.

  • Read permission
  • Write permission
  • Execute permission

Using the chmod command, it can set custom permissions to files and directories. Here’s the command structure of any chmod command.

$ chmod permission> file_or_directory>

For this guide, we’ll be focusing on the chmod 755 commands.

$ chmod file_or_directory>

User and group ownership

First, run the following ls command. It’ll print information about the files and directories under the home directory.

Have a look at the left column. It may look like gibberish, but it actually encodes the file permissions. For example, the first character of the first column describes whether it’s a file or a directory. For a directory, the value will be “d”. For a single file, the value will be “-“.

The third column indicates the “user owner” of the file/directory. It’s the user who created this specific file/directory.

The fourth column indicates the “group owner”. It indicates the user group that has access to the file/directory. Any user from the group can access the file/directory.

Read, write and execute permissions

Run the ls command again.

As mentioned earlier, the first character indicates whether it’s a file or a directory. What do the next characters mean? Here’s a quick breakdown.

  • Character 1: File (-) or directory (d).
  • Character 2-4: Permission for the user owner.
  • Character 5-7: Permission for the group owner.
  • Character 8-10: Permission for others, for example, users that aren’t the owner and not part of the user group.

Note that characters 2-10 feature only a handful of values.

  • r: read
  • w: write
  • x: execute

The values will come in the form of “rwx”. If a certain value is “-“, then the permission isn’t set. For example, “rw-“ means that the file has read and write permission but execute permission isn’t set.

How does the read, write, and execute permission apply to files and directories?

  • Read
    • File: Reading file content.
    • Directory: Listing directory contents.
  • Write
    • File: Modify the content of the file.
    • Directory: Rename, add, and delete files in the directory.
  • Execute
    • File: Defines an executable file, for example, a bash script.
    • Directory: Access the directory.

Octal representation of permissions

This leads back to our original question. What does the chmod 755 value mean?

Instead of using characters, it’s also possible to use octal values to signify the permissions. The value ranges from 0 to 7 (in octal).

  • 4: read
  • 2: write
  • 1: execute

Here, 755 is an octal expression of the permission “rwxr-xr-x”. Now, breaking down the chmod 755 value,

  • 7: 4 + 2 + 1: Read, write, and execute (user owner).
  • 5: 4 + 0 + 1: Read and execute permissions (group owner).
  • 5: 4 + 0 + 1: Read and execute permissions (others).

Let’s break down chmod 644.

  • 6: 4 + 2 + 0: Read and write permissions for the user owner.
  • 4: 4 + 0 + 0: Read permission for the group owner.
  • 4: 4 + 0 + 0: Read permission for others.

So, 644 signifies the file permission “rw-r–r–“.

Applying chmod 755

It’s time to put chmod 755 in action. To set the permission to 755, run the following chmod command.

$ chmod -v 755 file_or_directory>

What if the directory contains one or more sub-directories? To apply chmod 755 to all the subsequent files and directories, run chmod in recursive mode.

$ chmod-v  -R 755 file_or_directory>

Verify the changes using the ls command.

Final thoughts

This guide covers a lot of concepts. It explains the basics of the chmod command, with an in-depth explanation of chmod values and their usage. It also demonstrates how to apply various chmod values to files and directories.

For further examples, here’s an awesome guide on various chmod usage with examples. It demonstrates numerous applications of chmod with different values. The information from this guide will help to understand the steps better.

A multi-user system must also have a robust user permission management system to control the behaviors of the users. In Linux, the sudoers file decides which users get to execute sudo commands. Learn more about how to add users to sudoers.

Happy computing!