日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

【Linux】一步一步学Linux——chown命令(112)

發(fā)布時(shí)間:2024/4/21 linux 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Linux】一步一步学Linux——chown命令(112) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

00. 目錄

文章目錄

    • 00. 目錄
    • 01. 命令概述
    • 02. 命令格式
    • 03. 常用選項(xiàng)
    • 04. 參考示例
    • 05. 總結(jié)
    • 06. 附錄

01. 命令概述

chown - 修改文件所有者和所屬組

Linux/Unix 屬于多用戶多任務(wù)操作系統(tǒng),所有的文件皆有擁有者。利用 chown 命令可以將指定文件的擁有者改為指定的用戶或組,用戶可以是用戶名或者用戶ID,組可以是組名或者組ID,文件是以空格分開的要改變權(quán)限的文件列表,支持通配符。 一般來說,這個(gè)指令僅限系統(tǒng)管理者(root)所使用,普通用戶沒有權(quán)限改變文件所屬者及所屬組。

02. 命令格式

用法:chown [選項(xiàng)]... [所有者][:[]] 文件...或:chown [選項(xiàng)]... --reference=參考文件 文件...

03. 常用選項(xiàng)

當(dāng)使用 --referebce 參數(shù)時(shí),將文件的所有者和所屬組更改為與指定參考文件相同。-c, --changes 類似 verbose,但只在有更改時(shí)才顯示結(jié)果--dereference 受影響的是符號鏈接所指示的對象,而非符號鏈接本身-h, --no-dereference 會影響符號鏈接本身,而非符號鏈接所指示的目的地(當(dāng)系統(tǒng)支持更改符號鏈接的所有者時(shí),此選項(xiàng)才有用)--from=當(dāng)前所有者:當(dāng)前所屬組只當(dāng)每個(gè)文件的所有者和組符合選項(xiàng)所指定時(shí)才更改所有者和組。其中一個(gè)可以省略,這時(shí)已省略的屬性就不需要符合原有的屬性。--no-preserve-root 不特殊對待"/"(默認(rèn)值)--preserve-root 不允許在"/"上遞歸操作-f, --silent, --quiet 去除大部份的錯(cuò)誤信息--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前面有一個(gè)點(diǎn)。

05. 總結(jié)

06. 附錄

參考:【Linux】一步一步學(xué)Linux系列教程匯總

總結(jié)

以上是生活随笔為你收集整理的【Linux】一步一步学Linux——chown命令(112)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。