改变所属群组
chgrp [-R] groupname dirname/filename
-R: 同目录下的所有档案、目录都更新成为这个群组。
实例:chgrp pi test.txt
更改test.txt的用户组为pi
改变文件拥有者
chgrp [-R] username dirname/filename
实例:chown pi text.py
更改test.py的拥有者为pi
拥有者和所属群组一起更改
chown [-R] username:groupname dirname/filename
chown pi:root test.py
更改test.py的拥有者和所属群组为pi和root
更改权限
chmod [-R] xyz dirname/filename
x表示owner权限,y表示group权限,z表示other权限
实例:把文件test.py权限改为如下表所示。
身份 | owner | group | others | 权限分数: r : 4 w : 2 x : 1 |
---|---|---|---|---|
权限 | rwx | rw- | r— | |
分数 | 7 | 6 | 4 | |
xyz | 764 | |||
更改文件权限命令:chmod 764 test.py |
实例:chmod 664 test.py
把test.py文件权限修改user和group为可读可写,other为可读。
符号类型更改权限
chmod | u(user) g(group) o(other) a(all) |
+(加入) -(除去) =(设定) |
r(读) w(写) x(可执行) |
file/dir |
---|---|---|---|---|
实例:chmod u=rwx,go=rx .bashrc
把文件.bashrc修改为user可读可写可执行,group和other可读可执行;
chmod u+x .bashrc
文件.bashrc,给user可执行权限;
chmod a+w test.py
文件test.py,给所有用户添加写权限。