Modify file permissions in batches on Linux¶
During use, you often encounter the following situations: It is necessary to modify the folder permissions in a certain directory to: 0755, the owner is root, the file permissions are: 0644, the owner is root
1. Set the permissions of all folders in a directory individually```¶
find -type d -exec chmod 0755 {} \;
## 2. Set the permissions of all files in a directory individually```
find -not -type d -exec chmod 644 {} \;
3. If you want to set the owner of the folder individually, you only need to change the command to the following:¶
Add- Scope of authority: ```¶
u :目录或者文件的当前的用户
g :目录或者文件的当前的群组
o :除了目录或者文件的当前用户或群组之外的用户或者群组
a :所有的用户及群组
```
- Permission code:
r :读权限,用数字4表示 w :写权限,用数字2表示 x :执行权限,用数字1表示 – :删除权限,用数字0表示 s :特殊权限