Recursively change the file’s permission in Linux operating system: Linux CHMOD tutorial.
Firstly, Let’s have a basic idea about the file permissions in Linux based operating system. Linux File Permission and Linux File Ownership are interrelated and go together. In Linux, the Owner of the files or directories can be categorized into User, Group, and Other. And in Linux, every file or directory has different types of file permissions defined for the various type of owners. In simple terms, You can find the read permission, write permission and execute permission. Linux File Permission is very specific and strict.
For example:
You can’t rename, move or remove the file from the directory if you don’t have written permission on the directory despite having write permission on file.
- Read permission give you the authority to open and read a file.
- Write permission on a file gives you the authority to modify the contents of a file and the write permission on a directory gives you the authority to add, remove and rename files stored in the directory
- Execute permission gives the authority to run a program or file in Linux
How To Recursively Change The File’s Permissions In Linux [CHMOD Linux]
Now, let’s see the solution for the question on how to recursively change the file permissions in Linux operating system. Chmod Recursive command will help us to achieve our solution using symbolic or numeric mode.
Recursively Change The File’s Permissions In Linux Using Chmod Command
chmod command with the -R (–recursive) option can recursively change the file permission in Linux.
chmod -R MODE DIRECTORY
Let’s go through the example of recursively changing the file permission in Linux.
Run the following command with the administrative or sudo privilege to change the permissions of all files and subdirectories under the /home/itsubuntu/newfolder
directory to 755
you would use:
chmod -R 755 /home/itsubuntu/newfolder
or
chmod -R u=rwx,go=rx /home/itsubuntu/newfolder
Recursively Change The File’s Permissions In Linux Using Find Command with Chmod
Run the following command to recursively change the file’s permissions to 644
and directory’s permissions to 755
.
find
/home/itsubuntu/newfolder
-type d -exec chmod 755 {} \;find
/home/itsubuntu/newfolder
/newfile -type f -exec chmod 644 {} \;