chmod 递归修改权限
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.
我们有一个由其他人归档的归档文件,我们想更改文件和目录的权限。 为了更改所有子文件和目录的权限,我们需要递归运行chmod
。 递归意味着请对所有给定的文件和文件夹及其子文件和文件夹应用给定的权限。
-R或–递归选项 (-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
或--recursive
选项的递归功能。 在此示例中,我们将递归将权限更改为720
。
$ 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.
将读取,写入和执行权限转换为720
,可以使用ls -l
命令检查权限的当前状态。 这将在第一列中列出新的权限。
$ ls -l
使用Find命令设置递归权限(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
.
我们可以创建与chmod
的递归选项类似的效果。 我们将使用find
命令,该命令用于查找和过滤文件和目录,然后使用其名称执行命令。 我们可以使用find
列出所有或某些文件和目录,然后逐个运行chmod
命令到过滤列表。 在此文件中,我们将所有以.txt
扩展名结尾的文件都更改为720
。
$ find /home/ismail -print -exec chmod 720 {} \;
翻译自: https://www.poftut.com/how-to-change-file-and-directory-permissions-with-chmod-recursively/
chmod 递归修改权限