We have an archive which is archived by someone else and we want to change file and directory permissions. In order to change all sub files and directories permissions we need to run chmod
recursively. Recursively means please apply given permissions all given files and folders and their sub files and folders.
-R or –recursive Option
In order to change files and directories permissions recursively chmod
provides recursive feature with -R
or --recursive
options. In this example we will change permissions to 720
recursively.
$ chmod -R 720 /home/ismail/
Check Current Permission
After we have converted read, write and execute permissions to 720
we can check the current status of the permissions with ls -l
command. This will list new permissions in the first column.
$ ls -l

Setting Recursive Permissions with Find Command
We can create similar effect to the recursive option of the chmod
. We will use find
command which is used to find and filter files and directories and than execute command with their names. We can list all or some of the files and directories with find
and than run chmod
command one by one to the filtered list. In this files we will change all files those ends with .txt
extension to the 720
.
$ find /home/ismail -print -exec chmod 720 {} \;