一個linux目錄或文件,都會有一個全部者和所屬組。全部者,即文件的擁有者;所屬組,即該文件全部者所在的一個組。這樣的設置目的是爲了文件的安全。linux
chown命令能夠更改文件的全部者和所屬組。安全
命令格式:spa
chown [-R] 帳戶名 文件名test
chown [-R] 帳戶名:組名 文件名文件
-R 只做用於目錄,級聯更改co
[root@localhost~]# ls -l test.shlocalhost
-rwxrw-r-x 1 root root 0 11月 10 08:55 test.sh
[root@localhost~]# chown ly test.sh
[root@localhost~]# ls -l test.sh
-rwxrw-r-x 1 ly root 0 11月 10 08:55 test.sh
[root@localhost~]# chown :aly test.sh
[root@localhost~]# ls -l test.sh
-rwxrw-r-x 1 ly aly 0 11月 10 08:55 test.sh
[root@localhost~]# chown root:root test.sh
[root@localhost~]# ls -l test.sh
-rwxrw-r-x 1 root root 0 11月 10 08:55 test.sh