How to Recursively Change File Permissions in Linux

how to recursively change file permissions in linux

There will surely be a time when you will try to access and open a file or a directory but you could not. You will get a permission denied message from your terminal. This is because of the permissions that refrain us to open or access that file.

In Linux, permissions are a very important aspect of system security. These permissions are read, write and execute.

This article will discuss and explain these permissions in detail.

chmod command and its syntax

chmod is a command that we use to set up the permissions for our files and folders. It has a syntax that we need to follow.

chmod [options] [permissions] [file or directory]

There are some options that we use along with the chmod command and these are as follows.

  • R: Used forRecursively changing the permissions of files and directories
  • -v: Used to output a message.
  • -c: It gets used to output a message only for files that have changed.

We have three types of users. The first one is the owner who creates the file of the directory in Linux. The second one is the group of which the user is part. The last one is the other type of users who either are owners or the part of any group

Now let’s have an example.

Let’s take an example as we have a file on our desktop and we need to assign all permissions to all the users. We have three types of users in Linux distributions “users”, “groups”, and “other” types of users.

$ chmod -R 777 file.txt

Now, we will use the ls command to verify and make sure if the permissions got changed or not.

$ ls -l file.txt

Here it shows that we have successfully changed the permissions for the file.

How to change permissions recursively with symbolic mode?

This is another way of assigning permissions as it allows us to assign permissions in a more granular way. We can assign different permissions to different users. As we have three kinds of users in our Linux distributions.

Let’s see the syntax.

chmod -R [who][operator][permissions] [directory]

Now let’s take an example here and let’s say, we want to assign all the permission to the owner of the file, read and write permission to the group and only read permission to the other users. For that, we will use the permissions with the chmod command like the following.

$ chmod -R u=rwx,g=rx,o=x file.txt

The below table shows the permission along with the symbols and numbers we can use to assign different permission to our files and folders.

Octal Notation BInary Symbolic Representation Permissions
0 000 No permission
1 001 –x Execute
2 010 -w- Write
3 011 -wx Write and Execute
4 100 r– Read
5 101 r-x Read and Execute
6 110 rw- Read and Write
7 111 rwx Read, write, and Execute


Keeping permission on the files allows us to have more security and also helps us to keep the authorizations over the content. This phenomenon is very useful and handy when we have more than one user on one system. Permissions will make sure that only privileged users are allowed to use and see the content of files and folders.

This article was all about how we can use the permission on our files and folders along with different methods that we can use to do that.

Similar Posts