linux 中 chown命令
linux chown命令用于改变文件或者目录的所有者或者所属组。
001、改变所有者需要具备root权限,普通用户无法修改
[user01@pc1 test1]$ ls a.txt [user01@pc1 test1]$ ll -h ## 文件的所有者为user01 total 109M -rw-rw-r--. 1 user01 user01 109M Dec 30 18:09 a.txt [user01@pc1 test1]$ chown user02 a.txt ## user01尝试改变所有者为user02,即便是所有者,仍然无法改变 chown: changing ownership of ‘a.txt’: Operation not permitted

002、root改变所有者和所属组
[root@pc1 test1]# ls a.txt [root@pc1 test1]# whoami ## 显示当前用户 root [root@pc1 test1]# ll -h ## 所属组和所有者均为user01 total 109M -rw-rw-r--. 1 user01 user01 109M Dec 30 18:09 a.txt [root@pc1 test1]# chown user02 a.txt ## root只用一个参数时,修改所有者 [root@pc1 test1]# ll -h total 109M -rw-rw-r--. 1 user02 user01 109M Dec 30 18:09 a.txt [root@pc1 test1]# chown root:root a.txt ## root给与两个参数时,同时修改所有者和所属组 [root@pc1 test1]# ll -h total 109M -rw-rw-r--. 1 root root 109M Dec 30 18:09 a.txt

。

浙公网安备 33010602011771号