1.释义
目录或文件的属主、属组、其它权限修改
1.1.常见权限说明
目录默认权限:755
,文件默认权限:644
目录和文件常见权限值:
- 目录:
755
750
700
- 文件:
644
640
600
2.系统帮助
用法:chmod [选项]... 模式[,模式]... 文件... 或:chmod [选项]... 八进制模式 文件... 或:chmod [选项]... --reference=参考文件 文件... Change the mode of each FILE to MODE. With --reference, change the mode of each FILE to that of RFILE. -c, --changes like verbose but report only when a change is made -f, --silent, --quiet suppress most error messages -v, --verbose output a diagnostic for every file processed --no-preserve-root do not treat '/' specially (the default) --preserve-root fail to operate recursively on '/' --reference=RFILE use RFILE's mode instead of MODE values -R, --recursive 权限递归 --help 显示此帮助信息并退出 --version 显示版本信息并退出 Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'. GNU coreutils online help: <http://www.gnu.org/software/coreutils/> 请向<http://translationproject.org/team/zh_CN.html> 报告chmod 的翻译错误 要获取完整文档,请运行:info coreutils 'chmod invocation'
3.图解
文件下载 | 文件名称:文件权限图.vsdx | 文件大小:34.7kb |
下载声明:本站文件大多来自于网络,仅供学习和研究使用,不得用于商业用途,如有版权问题,请联系我! | ||
下载地址:点击下载 |
提取密码:
4.示例
4.1.移除用户写权限
[root@itbkz s]#mkdir mulu [root@itbkz s]#touch mulu/test.txt [root@itbkz s]#ll -d mulu drwxr-xr-x 2 root root 22 12月 5 17:00 mulu [root@itbkz s]#ll mulu/test.txt -rw-r--r-- 1 root root 0 12月 5 17:00 mulu/test.txt 方法1: [root@itbkz s]#chmod u=rx mulu [root@itbkz s]#ll -d mulu dr-xr-xr-x 2 root root 22 12月 5 17:00 mulu 方法2: [root@itbkz s]#chmod u-w mulu [root@itbkz s]#ll -d mulu dr-xr-xr-x 2 root root 22 12月 5 17:00 mulu 方法3: [root@itbkz s]#chmod 555 mulu [root@itbkz s]#ll -d mulu dr-xr-xr-x 2 root root 22 12月 5 17:00 mulu
4.2.增加属组写权限
方法1: [root@itbkz s]#chmod g+w mulu [root@itbkz s]#ll -d mulu drwxrwxr-x 2 root root 22 12月 5 17:00 mulu 方法2: [root@itbkz s]#chmod g=rwx mulu [root@itbkz s]#ll -d mulu drwxrwxr-x 2 root root 22 12月 5 17:00 mulu 方法3: [root@itbkz s]#chmod 775 mulu [root@itbkz s]#ll -d mulu drwxrwxr-x 2 root root 22 12月 5 17:00 mulu
4.3.增加其它写权限
方法1: [root@itbkz s]#chmod o+w mulu [root@itbkz s]#ll -d mulu drwxr-xrwx 2 root root 22 12月 5 17:00 mulu 方法2: [root@itbkz s]#chmod o=rwx mulu [root@itbkz s]#ll -d mulu drwxr-xrwx 2 root root 22 12月 5 17:00 mulu 方法3: [root@itbkz s]#chmod 757 mulu [root@itbkz s]#ll -d mulu drwxr-xrwx 2 root root 22 12月 5 17:00 mulu
4.4.相同权限修改
方法1: [root@itbkz s]#chmod go=rwx mulu [root@itbkz s]#ll -d mulu drwxrwxrwx 2 root root 22 12月 5 17:00 mulu 方法2: [root@itbkz s]#chmod 777 mulu [root@itbkz s]#ll -d mulu drwxrwxrwx 2 root root 22 12月 5 17:00 mulu
4.5.不同权限修改
方法1: [root@itbkz s]#chmod u=rx,g=rwx,o=rwx mulu [root@itbkz s]#ll -d mulu dr-xrwxrwx 2 root root 22 12月 5 17:00 mulu 方法2: [root@itbkz s]#chmod u=rx,go=rwx mulu [root@itbkz s]#ll -d mulu dr-xrwxrwx 2 root root 22 12月 5 17:00 mulu 方法3: [root@itbkz s]#chmod 577 mulu [root@itbkz s]#ll -d mulu dr-xrwxrwx 2 root root 22 12月 5 17:00 mulu
4.6.删除全部权限
方法1: [root@itbkz s]#chmod a= mulu [root@itbkz s]#ll -d mulu d--------- 2 root root 22 12月 5 17:00 mulu 方法2: [root@itbkz s]#chmod 000 mulu [root@itbkz s]#ll -d mulu d--------- 2 root root 22 12月 5 17:00 mulu 方法3: [root@itbkz s]#chmod =0 mulu [root@itbkz s]#ll -d mulu d--------- 2 root root 22 12月 5 17:00 mulu
4.7.权限递归
方法1: [root@itbkz s]#chmod -R 700 mulu [root@itbkz s]#ll -d mulu mulu/test.txt drwx------ 2 root root 22 12月 6 22:21 mulu -rwx------ 1 root root 0 12月 6 22:21 mulu/test.txt 方法2: [root@itbkz s]#chmod -R u=rwx,go= mulu [root@itbkz s]#ll -d mulu mulu/test.txt drwx------ 2 root root 22 12月 6 22:24 mulu -rwx------ 1 root root 0 12月 6 22:24 mulu/test.txt
将会修改目录和目录下目录及文件的所有权限
5.注意
[root@itbkz s]#chmod 7777 mulu [root@itbkz s]#ll 总用量 0 drwsrwsrwt 2 root root 6 12月 5 23:34 mulu [root@itbkz s]#chmod 7666 mulu [root@itbkz s]#ll 总用量 0 drwSrwSrwT 2 root root 6 12月 5 23:34 mulu
当权限中出现大写
S
或是大写T
时说明没有执行权限