5

Linux 对特定类型文件设置权限

 3 years ago
source link: http://i.lckiss.com/?p=7167
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Linux 对特定类型文件设置权限

2021-07-10

这两天在容器化的过程中遇到不少主机与容器文件权限的问题,当然对于不需要物理映射的容器不存在这个问题,但对于存在物理映射的容器,这个问题跑不掉。大多数时候主要的问题还是在于用户组。但偶尔也需要动到权限。所以备份两条命令。

  • 指定当前文件夹下的所有目录以及子目录为0755(-d 为 directory):
find . -type d -exec chmod 0755 {} \; 
  • 指定当前文件夹下的所有文件以及子文件为0644(-f 为 file):
find . -type f -exec chmod 0644 {} \; 
  • 更改特定后缀(如:php)文件权限为0644
find . -type f -name "*.php" -exec chmod 0644 {} \; 

注意:

网上大多数都是这么写的对吧,但网上复制的往往没这么简单,还会遇到一个错误:

find: 遗漏”-exec”的参数

解决办法:{} 后面还需要加个空格,当然上面已经加了。


  • 2021051300031389.jpg

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK