Files
My-Notes/笔记/Linux/基础指令/chmod&chown.md
T
2026-06-30 22:02:28 +08:00

39 lines
886 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# chmod \[-R] \[权限] \[文件或文件夹]
作用:修改文件/文件夹本身的权限
参数:
- r:对文件夹及以内的所有内容做同样的操作
示例:
- chmod u=rwx,g=rx,o=x hello.txt
- chmod -R u=rwx,g=rx,o=x test
权限还能用数字来表示
特殊写法:
- `r=4`
- `w=2`
- `x=1`
- 所以 `rwx=7``rw-=6``r-x=5`
示例:
- chmod 755 hello.sh
- chmod 644 text.txt
- chmod -R 755 test
# choown \[-R] \[用户] \[:] \[用户组] \[文件或文件夹]
作用:修改文件或文件夹的所属用户或用户组
参数:
- R:同chmod
- ::分隔用户何用户组
示例:
- chown kister test.txt //只修改用户
- chown :kister test.txt //只修改用户组
- chown root:kister test.txt //都改
- chown -R root test.txt //递归修改
注意:
- 不能直接把用户或用户组改到其他用户身上,一般都是root执行