【Linux】一步一步学Linux——chown命令(112)
生活随笔
收集整理的這篇文章主要介紹了
【Linux】一步一步学Linux——chown命令(112)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. 命令概述
- 02. 命令格式
- 03. 常用選項
- 04. 參考示例
- 05. 總結(jié)
- 06. 附錄
01. 命令概述
chown - 修改文件所有者和所屬組
Linux/Unix 屬于多用戶多任務(wù)操作系統(tǒng),所有的文件皆有擁有者。利用 chown 命令可以將指定文件的擁有者改為指定的用戶或組,用戶可以是用戶名或者用戶ID,組可以是組名或者組ID,文件是以空格分開的要改變權(quán)限的文件列表,支持通配符。 一般來說,這個指令僅限系統(tǒng)管理者(root)所使用,普通用戶沒有權(quán)限改變文件所屬者及所屬組。
02. 命令格式
用法:chown [選項]... [所有者][:[組]] 文件...或:chown [選項]... --reference=參考文件 文件...03. 常用選項
當(dāng)使用 --referebce 參數(shù)時,將文件的所有者和所屬組更改為與指定參考文件相同。-c, --changes 類似 verbose,但只在有更改時才顯示結(jié)果--dereference 受影響的是符號鏈接所指示的對象,而非符號鏈接本身-h, --no-dereference 會影響符號鏈接本身,而非符號鏈接所指示的目的地(當(dāng)系統(tǒng)支持更改符號鏈接的所有者時,此選項才有用)--from=當(dāng)前所有者:當(dāng)前所屬組只當(dāng)每個文件的所有者和組符合選項所指定時才更改所有者和組。其中一個可以省略,這時已省略的屬性就不需要符合原有的屬性。--no-preserve-root 不特殊對待"/"(默認(rèn)值)--preserve-root 不允許在"/"上遞歸操作-f, --silent, --quiet 去除大部份的錯誤信息--reference=參考文件 使用參考文件的所屬組,而非指定值-R, --recursive 遞歸處理所有的文件及子目錄-v, --verbose 為處理的所有文件顯示診斷信息--help 顯示此幫助信息并退出--version 顯示版本信息并退出04. 參考示例
4.1 修改文件所屬者和所屬組為tom
[root@itcast test]# ls -l file -rwxr-x--x 1 deng deng 0 8月 6 20:06 file [root@itcast test]# chown tom:tom file [root@itcast test]# ls -l file -rwxr-x--x 1 tom tom 0 8月 6 20:06 file [root@itcast test]#4.2 修改文件所屬者為deng用戶
[root@itcast test]# chown deng file [root@itcast test]# ls -l file -rwxr-x--x 1 deng tom 0 8月 6 20:06 file [root@itcast test]#4.3 修改文件所屬者為deng用戶和所屬組為itcast組
[root@itcast test]# chown deng:itcast file [root@itcast test]# ls -l file -rwxr-x--x 1 deng itcast 0 8月 6 20:06 file [root@itcast test]#4.4 修改文件所屬組為tom組
[root@itcast test]# chown :tom file [root@itcast test]# ls -l file -rwxr-x--x 1 deng tom 0 8月 6 20:06 file [root@itcast test]#4.5 遞歸修改所有的文件及子目錄所屬者和所屬組
[root@itcast test]# chown -R deng:deng test/4.6 顯示修改動作
[root@itcast test]# chown -c root:root file changed ownership of "file" from deng:tom to root:root [root@itcast test]#或者
[root@itcast test]# chown -v deng:deng file changed ownership of "file" from root:root to deng:deng [root@itcast test]#4.7 修改文件所屬者和所屬組
[root@itcast test]# chown 1002:1003 file [root@itcast test]# ls -l file -rwxr-x--x 1 itcast itcast 0 8月 6 20:06 file [root@itcast test]#注意:1002和1003必須是存在的用戶和用戶組。
4.8 修改文件所屬組
[root@itcast test]# chown .deng file [root@itcast test]# ls -l file -rwxr-x--x 1 itcast deng 0 8月 6 20:06 file [root@itcast test]#注意:組用戶名deng前面有一個點。
05. 總結(jié)
06. 附錄
參考:【Linux】一步一步學(xué)Linux系列教程匯總
總結(jié)
以上是生活随笔為你收集整理的【Linux】一步一步学Linux——chown命令(112)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【IT资讯】TIOBE 7月编程语言排行
- 下一篇: 【Linux】一步一步学Linux——c