# Understanding File Permissions On Linux With Chmod

> In this blog post, we will go over basic file permissions, what they are, how they are represented, how to check, and how to change them.

- Author: [CJ Saathoff](https://www.namehero.com/blog/author/cj-saathoff/)
- Published: 2024-06-27
- Updated: 2024-06-27
- Category: [Linux Command Line](https://www.namehero.com/blog/category/linux-command-line/)
- Web page: https://www.namehero.com/blog/understanding-file-permissions-on-linux-with-chmod/

[![](https://blogcdn.namehero.com/blog/wp-content/uploads/2024/05/10105654/understandingchmod-1024x576.jpg)](https://blogcdn.namehero.com/blog/wp-content/uploads/2024/05/10105654/understandingchmod.jpg)

On Unix-like operating systems like Linux, the operating system consists of files and folders. With everything coming back to files and folders, access control of them is extremely important. Think about it with the right level of access you can do anything. File permissions allow us to restrict access to only those who should have that access.

In this blog post, we will go over basic file permissions, what they are, how they are represented, how to check, and how to change them.

## What Are File Permissions?

File permissions control access to files and directories. It specifies what users or groups can access, read, and write to specific files and directories.

Permission on Linux is split into three groups which help separate who has access to what files and directories. Below are those three in the order they will be shown.

- File Owner
- Group Owner
- Other users

## How Permissions Are Represented

Permissions are represented in one of two ways text or numeric. They include no permission, read access, write permission, and execute permissions (for example needed by applications, shell scripts, and folders). Below shows how they are represented both ways.

**Text**

- **r** The file can be read
- **w** The file can be written to
- **x** The file has execute permission (allows a file to be run as an application)
- **–** no permissions

**Numeric**

Now let’s see which number matches to the text version shown above:

- **r**=**4**
- **w**=**2**
- **x**=**1**
- **–**=**0**

## Putting It Together – Checking File Permissions

The easiest way to check file permissions is to use the ls command using the -l flag as shown below.

```

ls -l

```

Running this command will list the files and directories in your current working directory

For example:

```

-rw-r--r-- 1 example example 2541 May  8 18:25 file.txt

```

In this example the example user has read and write.
Where the example group and other users would only have read access

In numeric form, this would be displayed as 644.

## Changing File Permissions

To change file permissions on Linux use the chmod command. The basic syntax for the command is shown below.

```

chmod [options] file

```

Options would typically be the file permissions you want to apply or change as shown in the below section.

### Chmod Examples

Both text and numeric options can be used with chmod as shown in the examples below.

**Adding a specific permission for all three groups**

```

chmod +x file.txt

```

This option will remove the executable bit to all three permissions so if the file was 755 it would now be 644 or -rwxr-xr-x.

Note this can be used with the other options (r and w) just remember it applies to all three permission groups.

**Removing specific permission for all three groups**

```

chmod -x file.txt

```

This option will make remove the executable bit to all three permissions so if the file was 755 it would now be 644 or -rwxr-xr-x.

**Setting permissions in numeric form**

```

chmod 640 file.txt

```

Setting the permission means that only the file owner can edit the file, whereas the only other users who can access the file below belong to the group owner.

## Conclusion

File permissions on Linux, are an absolute necessity for access control. It allows for varied levels of keeping users away from files they don’t need access to. In this blog post, we focused on file permissions from the command line. We explored basic Linux file permissions from what they are, how they are respresented, how to check, and how to change them.

## Additional Links

Done reading and looking for additional links why not check these out?

- [Arch Wiki File Permissions](https://wiki.archlinux.org/title/File_permissions_and_attributes)
- [Wikipedia File System Permissions POSIX](https://en.wikipedia.org/wiki/File-system_permissions#POSIX_permissions)

## Related posts

- [Understanding The Mv Command In Linux](https://www.namehero.com/blog/understanding-the-mv-command-in-linux/)
- [How to Run a .sh File in Linux](https://www.namehero.com/blog/how-to-run-a-sh-file-in-linux/)
- [How to Rename a File in Linux](https://www.namehero.com/blog/how-to-rename-a-file-in-linux/)
- [Understanding The chown Command In Linux](https://www.namehero.com/blog/understanding-the-chown-command-in-linux/)
