chmod 递归修改权限_如何使用Chmod递归更改文件和目录权限

chmod 递归修改权限

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
Check Current Permission
Check Current Permission
检查当前权限

使用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 {} \;
LEARN MORE  Windows Robocopy Command Tutorial with Examples To Copy Files In Safe Way
了解更多Windows Robocopy命令教程,并提供以安全方式复制文件的示例

翻译自: https://www.poftut.com/how-to-change-file-and-directory-permissions-with-chmod-recursively/

chmod 递归修改权限

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值