• <em id="6vhwh"><rt id="6vhwh"></rt></em>

    <style id="6vhwh"></style>

    <style id="6vhwh"></style>
    1. <style id="6vhwh"></style>
        <sub id="6vhwh"><p id="6vhwh"></p></sub>
        <p id="6vhwh"></p>
          1. 国产亚洲欧洲av综合一区二区三区 ,色爱综合另类图片av,亚洲av免费成人在线,久久热在线视频精品视频,成在人线av无码免费,国产精品一区二区久久毛片,亚洲精品成人片在线观看精品字幕 ,久久亚洲精品成人av秋霞

            chown(chown

            更新時間:2023-03-02 07:09:26 閱讀: 評論:0

            命令簡介

            chown是linux最基礎的命令之一,也是最常用的命令之一。可以通過chown修改文件、文件夾、符號鏈接的所有者信息。

            示例

            chown需要root權限執行。root權限需要root用戶登錄,或者sudo權限。

            1 使用chown修改文件的所有者

            更改文件的所有者,是chown命令的簡單應用。參數需要一個新的用戶名,以及一個文件名。用戶名必須為系統中可用賬戶。命令格式:

            $ sudo chown new_owner file_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ ls -ltotal 4-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown test1 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ ls -l friutes.txt-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txt2 使用chown更改文件所在組

            Chown命令用于修改文件所屬組。在新組名前必須使用冒號。否則,它將被視為新owner。命令格式:

            $ sudo chown :new_group file_name

            命令示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown :yunzhong friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 4-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txt3 chown命令使用用戶ID修改文件的所有者

            chown也可以通過用戶ID來更改文件的所有者。但這里有個問題:系統怎么知道傳入的參數是用戶ID,還是用戶名?其實系統也無法區分,如果有一個用戶的名字和用戶ID相同,系統則認為傳入的為用戶名。可以使用id命令查看用戶ID。

            id -u ur_name

            命令格式,和通過用戶名更改所有者是一樣的。示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ id -u yunzhong1000yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown 1000 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 4-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txt

            如果有一個用戶名為:1000,那么所有者就改成了1000.

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo uradd 1000yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown 1000 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 4-rw-r--r-- 1 1000 yunzhong 77 Nov 11 13:47 friutes.txt4 使用group ID 更改文件所在組

            和修改所有者類似,group也可以通過id來修改。查看group ID的命令:

            id -g group_name

            命令格式:

            $ sudo chown :group_id file_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 4-rw-r--r-- 1 test1 test1 77 Nov 11 13:47 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ id -g yunzhong1000yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown :1000 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 4-rw-r--r-- 1 test1 1000 77 Nov 11 13:47 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ id -g 10001006yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ id -g test11002yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown :1002 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 4-rw-r--r-- 1 test1 test1 77 Nov 11 13:47 friutes.txt

            和上一節同理,如果group ID和另外一個group名字重復,則認為參數是group名字。

            5 chown修改多個文件的所有者

            當需要修改多個文件為一個所有者時,chown只需要執行一次就可以做到。chown支持一次傳入多個文件名,通過空格分割。

            $ sudo chown new_owner file_name1 file_name2 file_name3

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 test1 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 test1 test1 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 test1 test1 77 Nov 14 08:32 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown yunzhong:yunzhong friutes.txt friutes.txt.1 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 08:32 friutes.txt.2

            如上面的示例,文件名有相同的前綴,我們可以用更簡單的方式批量修改所有者:*通配符。

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 08:32 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown test1 friutes.txt*yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.26 chown命令支持同時修改所有者和所在組

            chown支持同時輸入所有者和所在組,一次修改文件屬性。命令格式:

            $ sudo chown new_owner:new_group file_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown yunzhong:test1 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong test1 77 Nov 11 13:47 friutes.txt7 使用chown命令將一個文件的所有者、所在組同步到另外一個文件

            命令格式:

            $ sudo chown --reference=souce_file destination_file

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong test1 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown --reference = friutes.txt friutes.txt.1chown: failed to get attributes of '=': No such file or directoryyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown --reference=friutes.txt friutes.txt.1yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong test1 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 yunzhong test1 77 Nov 14 08:32 friutes.txt.1

            注意一點,參數--reference = 之后不能有空格,如果有空格,則認為參數錯誤,如上示例。

            8 打印chown 命令的變更記錄

            chown可以打印文件被自己操作的記錄。如果參數不傳入文件,則什么都不打印。命令格式:

            $ sudo chown -v

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong test1 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 yunzhong test1 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown -v test1 friutes.txtchanged ownership of 'friutes.txt' from yunzhong to test1yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown -v test1 friutes.txtownership of 'friutes.txt' retained as test19 chown只有在文件所有者、所在組發生變化的時候才打印信息

            和上面的-v參數不同,-c命令只有在所有者、所在組發生變化的時候才會打印。命令格式:

            $ sudo chown -c

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 test1 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 yunzhong test1 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 test1 yunzhong 77 Nov 14 08:32 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown -c test1:test1 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown -c yunzhong:yunzhong friutes.txtchanged ownership of 'friutes.txt' from test1:test1 to yunzhong:yunzhongyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$10 chown命令修改一個目錄的所有者、所在組

            和修改文件的操作類似,只要傳輸的改成目錄名就可以。命令格式:

            # 修改文件夾的所有者$ sudo chown new_owner directory_name# 修改文件夾的所在組$ sudo chown :new_group directory_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp$ lldrwxr-xr-x 2 yunzhong yunzhong 4096 Nov 14 08:32 chowntestyunzhong@DESKTOP-9VB7LN7:/tmp$ sudo chown test1:test1 chowntest/yunzhong@DESKTOP-9VB7LN7:/tmp$ lldrwxr-xr-x 2 test1 test1 4096 Nov 14 08:32 chowntest11 只有所有者和指定參數匹配,才修改所有者

            通過設定參數--from,可以校驗文件當前的所有者是否匹配。只有在匹配的情況下才會更改。命令格式:

            $ sudo chown --from=current_owner new_owner file_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown --from yunzhong test1 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown --from yunzhong 1000 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txt12 只有所在組和指定參數匹配,才修改所在組

            其實,用戶可以通過參數單獨校驗所有者,所在組,也可以同時校驗兩者。命令格式:

            $ sudo chown --from=:current_group :new_group file_name或者$ sudo chown --from current_owner:current_group new_owner:new_group file_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown --from yunzhong:yunzhong yunzhong:test1 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 test1 yunzhong 77 Nov 11 13:47 friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown --from test1:yunzhong yunzhong:yunzhong friutes.txtyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 12-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txt13 更改一個文件夾下所有內容的所有者或所在組

            使用-R參數,可以遞歸修改文件夾下所有的子文件、子文件夾。當修改大量文件的時候,這個參數可以幫助我們一次調用實現修改。

            命令格式:

            sudo chown -R new_owner:new_group directory_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp$ ll -R chowntest/chowntest/:total 16-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 08:32 friutes.txt.2drwxr-xr-x 2 yunzhong yunzhong 4096 Nov 14 10:50 subdirchowntest/subdir:total 12-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 10:50 friutes.txt-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 10:50 friutes.txt.1-rw-r--r-- 1 yunzhong yunzhong 77 Nov 14 10:50 friutes.txt.2yunzhong@DESKTOP-9VB7LN7:/tmp$ sudo chown -R test1:test1 chowntest/yunzhong@DESKTOP-9VB7LN7:/tmp$ ll -R chowntest/chowntest/:total 16-rw-r--r-- 1 test1 test1 77 Nov 11 13:47 friutes.txt-rw-r--r-- 1 test1 test1 77 Nov 14 08:32 friutes.txt.1-rw-r--r-- 1 test1 test1 77 Nov 14 08:32 friutes.txt.2drwxr-xr-x 2 test1 test1 4096 Nov 14 10:50 subdirchowntest/subdir:total 12-rw-r--r-- 1 test1 test1 77 Nov 14 10:50 friutes.txt-rw-r--r-- 1 test1 test1 77 Nov 14 10:50 friutes.txt.1-rw-r--r-- 1 test1 test1 77 Nov 14 10:50 friutes.txt.214 修改符號鏈接的所有者、所在組

            默認情況下,chown修改的是符號鏈接源文件的所有者、所在組。可以使用-h修改符號鏈接文件的信息。命令格式:

            $ sudo -h new_owner:new_group sym_file

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 16-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txtdrwxr-xr-x 2 yunzhong yunzhong 4096 Nov 14 10:50 subdiryunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ ln -s friutes.txt friutes.txt.lnyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 16-rw-r--r-- 1 yunzhong yunzhong 77 Nov 11 13:47 friutes.txtlrwxrwxrwx 1 yunzhong yunzhong 11 Nov 14 10:59 friutes.txt.ln -> friutes.txtdrwxr-xr-x 2 yunzhong yunzhong 4096 Nov 14 10:50 subdiryunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown test1:test1 friutes.txt.lnyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 16-rw-r--r-- 1 test1 test1 77 Nov 11 13:47 friutes.txtlrwxrwxrwx 1 yunzhong yunzhong 11 Nov 14 10:59 friutes.txt.ln -> friutes.txtdrwxr-xr-x 2 yunzhong yunzhong 4096 Nov 14 10:50 subdiryunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown -h test1:test1 friutes.txt.lnyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ lltotal 16-rw-r--r-- 1 test1 test1 77 Nov 11 13:47 friutes.txtlrwxrwxrwx 1 test1 test1 11 Nov 14 10:59 friutes.txt.ln -> friutes.txtdrwxr-xr-x 2 yunzhong yunzhong 4096 Nov 14 10:50 subdir屏蔽錯誤信息

            默認情況下,chown執行錯誤信息會打印到終端。可以使用-f參數,屏蔽錯誤信息。命令格式:

            $ sudo chown -f new_owner file_name

            示例:

            yunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown yunzhong not_found_filechown: cannot access 'not_found_file': No such file or directoryyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ sudo chown -f yunzhong not_found_fileyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ chown yunzhong friutes.txtchown: changing ownership of 'friutes.txt': Operation not permittedyunzhong@DESKTOP-9VB7LN7:/tmp/chowntest$ chown -f yunzhong friutes.txt

            本文發布于:2023-02-28 20:58:00,感謝您對本站的認可!

            本文鏈接:http://m.newhan.cn/zhishi/a/167771216595141.html

            版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。

            本文word下載地址:chown(chown.doc

            本文 PDF 下載地址:chown(chown.pdf

            標簽:chown
            相關文章
            留言與評論(共有 0 條評論)
               
            驗證碼:
            Copyright ?2019-2022 Comsenz Inc.Powered by ? 實用文體寫作網旗下知識大全大全欄目是一個全百科類寶庫! 優秀范文|法律文書|專利查詢|
            主站蜘蛛池模板: 波多野结衣中文字幕久久| 老鸭窝在线视频| 亚洲一区二区乱码精品| av乱色熟女一区二区三区| 国产亚洲精品第一综合| 国产mv在线天堂mv免费观看| A男人的天堂久久A毛片| 国产精品无码成人午夜电影| 激情综合网激情五月激情| 亚洲春色在线视频| 精品国产肉丝袜在线拍国语| 亚洲精品v欧美精品动漫精品| 超碰伊人久久大香线蕉综合| 国产精品久久久国产盗摄| 麻豆亚洲自偷拍精品日韩另| 成人午夜大片免费看爽爽爽| 欧美日韩高清在线观看| 人人妻人人揉人人模人人模| 乱女乱妇熟女熟妇综合网| 亚洲国产精品一二三区| 亚洲精品午夜国产VA久久成人| 影视先锋av资源噜噜| 国产精品成熟老妇女| 久久综合九色综合久桃花| 久久久久香蕉国产线看观看伊| 欧美日韩高清在线观看| 欧美日韩一区二区三区在线视频| 韩国午夜福利片在线观看| 四虎成人精品永久网站| 精品国际久久久久999波多野| gogogo免费高清在线| 制服丝袜亚洲欧美中文字幕| 在线看片免费人成视频久网| 最新日韩精品中文字幕| 婷婷综合缴情亚洲| 日韩欧美在线综合网另类| 久久精品国产成人午夜福利| 久久综合狠狠综合久久| 国产精品免费电影| 最新亚洲人成无码网站欣赏网| 国产精品国产精品国产专区|