• <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://www.newhan.cn/zhishi/a/167771216595141.html

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

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

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

            標簽:chown
            相關文章
            留言與評論(共有 0 條評論)
               
            驗證碼:
            Copyright ?2019-2022 Comsenz Inc.Powered by ? 實用文體寫作網旗下知識大全大全欄目是一個全百科類寶庫! 優秀范文|法律文書|專利查詢|
            主站蜘蛛池模板: 国产欧美日韩高清在线不卡 | 国产jizz中国jizz免费看| 国产午夜福利精品视频| 北岛玲中文字幕人妻系列| 亚洲综合无码明星蕉在线视频| 久久99久国产精品66| 午夜福利看片在线观看| 成人午夜电影福利免费| 久久av无码精品人妻出轨| 国产乱码精品一区二区上| 日韩美少妇大胆一区二区| 久久毛片少妇高潮| 国产中文字幕在线精品| 亚洲日本乱码熟妇色精品| 久久综合国产色美利坚| 国产精品无遮挡在线观看| 国产办公室秘书无码精品99 | 成人年无码av片在线观看| 国产精品老熟女露脸视频| 国产激情视频在线观看首页 | 中文字幕乱码一区二区免费| 搡老熟女老女人一区二区| 激情综合网激情综合网五月| 亚洲成人高清av在线| 少妇太爽了在线观看免费视频| 一级做a爰片久久毛片下载| 东京热一精品无码av| 18禁成年免费无码国产| 欧美日韩中文亚洲另类春色| 国产一精品一av一免费| 你懂的亚洲一区二区三区| 一区二区三区精品不卡| 国产初高中生粉嫩无套第一次| 亚洲色精品VR一区二区三区| 亚洲成人动漫在线| 你拍自拍亚洲一区二区三区| 国产精品 视频一区 二区三区| 无码av不卡免费播放| 亚洲爆乳www无码专区| 2021亚洲爆乳无码专区| 亚洲精品久荜中文字幕|