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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2.15 更改所有者和所属组chown

發布時間:2024/1/17 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2.15 更改所有者和所属组chown 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

chown命令

chown介紹和例子

  • chown等于change owner 更改文件的所有者和所屬組
[root@hf-01 ~]# ls /tmp aminglinux amning mysql.sock yum.log [root@hf-01 ~]# ls -l /tmp/yum.log 會看到yum.log的所有者是root -rw-r--r--. 1 root root 0 10月 26 07:48 /tmp/yum.log [root@hf-01 ~]# chown aming /tmp/yum.log chown: 無效的用戶: "aming" 這是因為在/etc/passwd中沒有aming這個用戶,需要useradd aming即可 [root@hf-01 ~]# chown hanfeng /tmp/yum.log 這時會看到所有者發生了變化,yum.log文件的所有者變化成hanfeng了 [root@hf-01 ~]# !ls ls -l /tmp/yum.log -rw-r--r--. 1 hanfeng root 0 10月 26 07:48 /tmp/yum.log

chown的用法

  • chown -R username:group filename
  • chown 【-R】用戶名 文件名 /更改所屬主
  • chown 【-R】 用戶名:組名 文件名 /更改所屬主和所屬組
[root@hf-01 ~]# !ls ls -l /tmp/yum.log -rw-r--r--. 1 hanfeng user1 0 10月 26 07:48 /tmp/yum.log [root@hf-01 ~]# chown user1:hanfeng /tmp/yum.log [root@hf-01 ~]# !ls 這里會看到所屬主和所屬組發生了改變,用戶和組中間用:隔開 ls -l /tmp/yum.log -rw-r--r--. 1 user1 hanfeng 0 10月 26 07:48 /tmp/yum.log [root@hf-01 ~]# chown -R hanfeng:user1 /tmp/aminglinux/ [root@hf-01 ~]# ls -l /tmp/aminglinux/ 總用量 0 drwxr-xr-x. 2 hanfeng user1 18 10月 24 07:21 2 drwxr-xr-x. 4 hanfeng user1 31 10月 25 06:55 aming2 [root@hf-01 ~]# ls -l /tmp/aminglinux/ 總用量 0 drwxr-xr-x. 2 hanfeng user1 18 10月 24 07:21 2 drwxr-xr-x. 4 hanfeng user1 31 10月 25 06:55 aming2 [root@hf-01 ~]# ls -ld /tmp/aminglinux/ drwxr-xr-x. 4 hanfeng user1 27 10月 25 07:29 /tmp/aminglinux/ [root@hf-01 ~]# touch /tmp/aminglinux/3.txt [root@hf-01 ~]# chown -R user1:hanfeng /tmp/aminglinux/ [root@hf-01 ~]# ls -l /tmp/aminglinux/ 總用量 0 drwxr-xr-x. 2 user1 hanfeng 18 10月 24 07:21 2 -rw-r--r--. 1 user1 hanfeng 0 10月 26 08:23 3.txt drwxr-xr-x. 4 user1 hanfeng 31 10月 25 06:55 aming2 [root@hf-01 ~]# ls -ld /tmp/aminglinux/ drwxr-xr-x. 4 user1 hanfeng 39 10月 26 08:23 /tmp/aminglinux/
  • chown 【-R】 :組名 文件名 / 只更改所屬組
[root@hf-01 ~]# chown :root /tmp/yum.log [root@hf-01 ~]# !ls 這里只更改了它的所屬組 ls -l /tmp/yum.log -rw-r--r--. 1 user1 root 0 10月 26 07:48 /tmp/yum.log

-R 只用于目錄,作用是級聯更改子目錄以及子文件。

chgrp

  • chgrp等于change group 更改文件所屬的用戶組
[root@hf-01 ~]# chgrp user1 /tmp/yum.log [root@hf-01 ~]# !ls 在之前的所屬組是root,現在所屬組是user1 ls -l /tmp/yum.log -rw-r--r--. 1 hanfeng user1 0 10月 26 07:48 /tmp/yum.log
  • chgrp 【-R】 組名 文件名

-R 只用于目錄,作用是級聯更改子目錄以及子文件。

轉載于:https://my.oschina.net/u/3707314/blog/1556064

總結

以上是生活随笔為你收集整理的2.15 更改所有者和所属组chown的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。