chown-修改所属用户、用户组
使用chmod命令,可以修改文件、文件夹的所属用户和用户组
普通用户无法修改所属为其他用户或组,所以此命令只适用于root用户执行
语法: change owner
chown [-R] [用户][:][用户组] 文件或文件夹
- 选项 -R 对文件夹内的全部内容应用相同规则
- 选项 用户 修改所属用户
- 选项 用户组 修改所属用户组
- :用于分割用户和用户组
示例
chown root hello.txt
将hello.txt所属用户修改为root
chown :root hello.txt
将hello.txt所属用户组修改为root
chown root:itheima hello.txt
将hello.txt所属用户修改为root,所属用户组修改为itheima
chown -R root test
将test文件夹及下属所有文件所属用户修改为root