[root@localhost test6]# ll ---xr--r-- 1 root users 302108 11-30 08:39 linklog.log ---xr--r-- 1 root users 302108 11-30 08:39 log2012.log -rw-r--r-- 1 root users 61 11-30 08:39 log2013.log -rw-r--r-- 1 root users 0 11-30 08:39 log2014.log -rw-r--r-- 1 root users 0 11-30 08:39 log2015.log -rw-r--r-- 1 root users 0 11-30 08:39 log2016.log -rw-r--r-- 1 root users 0 11-30 08:39 log2017.log [root@localhost test6]# chown mail:mail log2012.log [root@localhost test6]# ll ---xr--r-- 1 root users 302108 11-30 08:39 linklog.log ---xr--r-- 1 mail mail 302108 11-30 08:39 log2012.log -rw-r--r-- 1 root users 61 11-30 08:39 log2013.log -rw-r--r-- 1 root users 0 11-30 08:39 log2014.log -rw-r--r-- 1 root users 0 11-30 08:39 log2015.log -rw-r--r-- 1 root users 0 11-30 08:39 log2016.log -rw-r--r-- 1 root users 0 11-30 08:39 log2017.log [root@localhost test6]#
實例2:改變文件擁有者和羣組 shell
命令:[root@localhost test6]# ll 總計 604 ---xr--r-- 1 root users 302108 11-30 08:39 linklog.log ---xr--r-- 1 mail mail 302108 11-30 08:39 log2012.log -rw-r--r-- 1 root users 61 11-30 08:39 log2013.log -rw-r--r-- 1 root users 0 11-30 08:39 log2014.log -rw-r--r-- 1 root users 0 11-30 08:39 log2015.log -rw-r--r-- 1 root users 0 11-30 08:39 log2016.log -rw-r--r-- 1 root users 0 11-30 08:39 log2017.log [root@localhost test6]# chown root: log2012.log [root@localhost test6]# ll 總計 604 ---xr--r-- 1 root users 302108 11-30 08:39 linklog.log ---xr--r-- 1 root root 302108 11-30 08:39 log2012.log -rw-r--r-- 1 root users 61 11-30 08:39 log2013.log -rw-r--r-- 1 root users 0 11-30 08:39 log2014.log -rw-r--r-- 1 root users 0 11-30 08:39 log2015.log -rw-r--r-- 1 root users 0 11-30 08:39 log2016.log -rw-r--r-- 1 root users 0 11-30 08:39 log2017.log [root@localhost test6]#
實例3:改變文件羣組 spa
命令:[root@localhost test6]# ll 總計 604 ---xr--r-- 1 root users 302108 11-30 08:39 linklog.log ---xr--r-- 1 root root 302108 11-30 08:39 log2012.log -rw-r--r-- 1 root users 61 11-30 08:39 log2013.log -rw-r--r-- 1 root users 0 11-30 08:39 log2014.log -rw-r--r-- 1 root users 0 11-30 08:39 log2015.log -rw-r--r-- 1 root users 0 11-30 08:39 log2016.log -rw-r--r-- 1 root users 0 11-30 08:39 log2017.log [root@localhost test6]# chown :mail log2012.log [root@localhost test6]# ll 總計 604 ---xr--r-- 1 root users 302108 11-30 08:39 linklog.log ---xr--r-- 1 root mail 302108 11-30 08:39 log2012.log -rw-r--r-- 1 root users 61 11-30 08:39 log2013.log -rw-r--r-- 1 root users 0 11-30 08:39 log2014.log -rw-r--r-- 1 root users 0 11-30 08:39 log2015.log -rw-r--r-- 1 root users 0 11-30 08:39 log2016.log -rw-r--r-- 1 root users 0 11-30 08:39 log2017.log
實例4:改變指定目錄以及其子目錄下的全部文件的擁有者和羣組 code
命令:[root@localhost test]# ll drwxr-xr-x 2 root users 4096 11-30 08:39 test6 [root@localhost test]# chown -R -v root:mail test6 「test6/log2014.log」 的全部者已更改成 root:mail 「test6/linklog.log」 的全部者已更改成 root:mail 「test6/log2015.log」 的全部者已更改成 root:mail 「test6/log2013.log」 的全部者已更改成 root:mail 「test6/log2012.log」 的全部者已保留爲 root:mail 「test6/log2017.log」 的全部者已更改成 root:mail 「test6/log2016.log」 的全部者已更改成 root:mail 「test6」 的全部者已更改成 root:mail [root@localhost test]# ll drwxr-xr-x 2 root mail 4096 11-30 08:39 test6 [root@localhost test]# cd test6 [root@localhost test6]# ll 總計 604 ---xr--r-- 1 root mail 302108 11-30 08:39 linklog.log ---xr--r-- 1 root mail 302108 11-30 08:39 log2012.log -rw-r--r-- 1 root mail 61 11-30 08:39 log2013.log -rw-r--r-- 1 root mail 0 11-30 08:39 log2014.log -rw-r--r-- 1 root mail 0 11-30 08:39 log2015.log -rw-r--r-- 1 root mail 0 11-30 08:39 log2016.log -rw-r--r-- 1 root mail 0 11-30 08:39 log2017.log