站長資訊網(wǎng)
最全最豐富的資訊網(wǎng)站

Linux文件/目錄的權(quán)限及歸屬管理詳述

一、文件的權(quán)限和歸屬概述

1、訪問權(quán)限

  • 讀取r:允許查看文件內(nèi)容、顯示目錄列表;

  • 寫入w:允許修改文件內(nèi)容,允許在目錄中新建、移動、刪除文件或子目錄;

  • 可執(zhí)行x:允許運行程序、切換目錄

2、歸屬(所有權(quán))

  • 屬主:擁有該文件或目錄的用戶賬號;

  • 屬組:擁有該文件或目錄的組賬號;

3、查看文件的權(quán)限和歸屬

Linux文件/目錄的權(quán)限及歸屬管理詳述

4、chmod設(shè)置文件權(quán)限

chmod命令的基本語法格式如下:
Linux文件/目錄的權(quán)限及歸屬管理詳述

應(yīng)用舉例:

[root@CentOS01 ~]# touch 1.txt     <!--創(chuàng)建1.txt文件-->  [root@centos01 ~]# ll   總用量 8  -rw-r--r--  1 root root    0 1月  11 22:27 1.txt  -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg  [root@centos01 ~]# chmod u+x ./1.txt  <!--屬主用戶添加執(zhí)行權(quán)限-->  [root@centos01 ~]# ll  總用量 8  -rwxr--r--  1 root root    0 1月  11 22:27 1.txt  -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg  [root@centos01 ~]# chmod u-x,g+x,o+w 1.txt     <!--屬主用戶取消執(zhí)行權(quán)限,組添加執(zhí)行權(quán)限,其他用戶添加寫入權(quán)限-->  [root@centos01 ~]# ll  總用量 8  -rw-r-xrw-  1 root root    0 1月  11 22:27 1.txt  -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg  [root@centos01 ~]# chmod 755 1.txt  <!--添加755權(quán)限(rwxr-xr-x)-->  [root@centos01 ~]# ll  總用量 8  -rwxr-xr-x  1 root root    0 1月  17 02:36 1.txt  -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

5、chown設(shè)置文件的歸屬

chown命令的基本語法格式如下:
Linux文件/目錄的權(quán)限及歸屬管理詳述

應(yīng)用舉例:

[root@centos01 ~]# chown bob 1.txt  <!--1.txt設(shè)置屬主-->  [root@centos01 ~]# ll  總用量 8  -rwxr-xr-x  1 bob  root    0 1月  17 02:36 1.txt  -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg  [root@centos01 ~]# chown :benet 1.txt  <!--1.txt設(shè)置屬組-->  [root@centos01 ~]# ll  總用量 8  -rwxr-xr-x  1 bob  benet    0 1月  17 02:36 1.txt  -rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg  [root@centos01 ~]# chown bob:benet 1.txt  <!--1.txt設(shè)置屬主和屬組-->  [root@centos01 ~]# ll  總用量 8  -rwxr-xr-x  1 bob  benet    0 1月  17 02:36 1.txt  -rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg  <!---->

二、目錄的權(quán)限和歸屬

1、訪問權(quán)限

Linux文件/目錄的權(quán)限及歸屬管理詳述

2、歸屬(所有權(quán))

  • 屬主:擁有該目錄的用戶賬號;

  • 屬組:擁有該目錄的組賬號;

3、chmod設(shè)置目錄權(quán)限

chmod命令設(shè)置目錄權(quán)限的基本格式如下:
Linux文件/目錄的權(quán)限及歸屬管理詳述

應(yīng)用舉例:

[root@centos01 ~]# chmod -R 755 benet/               <!--循環(huán)設(shè)置benet目錄下的文件或者目錄權(quán)限為755-->  [root@centos01 ~]# ll  總用量 8  -rw-r-xrw-  1 root root    0 1月  11 22:27 1.txt  -rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg  drwxr-xr-x  3 root root   18 1月  11 22:39 benet  -rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

4、chown設(shè)置目錄的歸屬

chown命令設(shè)置目錄歸屬的基本格式如下:
Linux文件/目錄的權(quán)限及歸屬管理詳述

應(yīng)用舉例:

[root@centos01 ~]# chown -R bob:benet benet/        <!--循環(huán)設(shè)置benet目錄中所屬用戶為bob,所屬組為benet-->  [root@centos01 ~]# ll  總用量 8  -rw-r-xrw-  1 root root     0 1月  11 22:27 1.txt  -rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg  drwxr-xr-x  3 bob  benet   18 1月  11 22:39 benet  -rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg

三、權(quán)限掩碼umask

1、umask的作用

控制新建的文件或目錄的權(quán)限,默認權(quán)限去除umask的權(quán)限就是新建的文件或者目錄的權(quán)限。

2、設(shè)置umask

umask 022

3、查看umask

umask

4、應(yīng)用舉例:

[root@centos01 ~]# umask  <!--查看umask-->  0022  [root@centos01 ~]# umask 000  <!--設(shè)置umask為000-->  [root@centos01 ~]# umask   <!--驗證是否設(shè)置成功-->  0000  [root@centos01 ~]# touch 2.txt   <!--創(chuàng)建新文件-->  [root@centos01 ~]# ll  總用量 8  -rwxr-xr-x  1 bob  benet    0 1月  17 03:48 1.txt  -rw-rw-rw-  1 root root     0 1月  17 03:48 2.txt    <!--查看權(quán)限-->  -rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg  [root@centos01 ~]# umask 022       <!--設(shè)置umask為022-->  [root@centos01 ~]# umask           <!--查看umask-->  0022  [root@centos01 ~]# touch 3.txt        <!--再次創(chuàng)建新文件-->  [root@centos01 ~]# ll  總用量 8  -rwxr-xr-x  1 bob  benet    0 1月  17 03:48 1.txt  -rw-rw-rw-  1 root root     0 1月  17 03:48 2.txt  -rw-r--r--  1 root root     0 1月  17 03:49 3.txt <!--查看權(quán)限,明顯不一樣-->  -rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg  -rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg
贊(0)
分享到: 更多 (0)
網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號
亚洲精品无码日韩国产不卡?V| 国产精品jlzz视频| 成人区精品一区二区不卡亚洲| 69精品人人人人| 亚洲国产精品一区二区第四页| 国产精品成人va在线观看| 亚洲精品在线观看视频| 亚洲AV无码乱码精品国产| 精品国产日韩亚洲一区| 精品丝袜人妻久久久久久| 久久久久国产精品免费网站| 78成人精品电影在线播放日韩精品电影一区亚洲 | 久久精品国产免费| 国产成人精品午夜二三区波多野| 亚洲精品国产高清不卡在线| 日韩午夜伦y4480私人影院| 精品亚洲AV无码一区二区| 国产精品女同一区二区久久 | 国产乱人伦精品一区二区在线观看| 2021国产精品自在拍在线播放| 热re99久久6国产精品免费| 亚洲综合一区二区国产精品| 国产亚洲精品美女久久久| 中文字幕久久精品| 日本精品啪啪一区二区三区| 二区久久国产乱子伦免费精品| 国产精品免费视频播放器| 99re视频热这里只有精品7| 久久精品国产99精品国产2021| 天美传媒精品1区2区3区| 久久精品国产一区二区电影| 国产精品一区二区AV麻豆| 精品丝袜人妻久久久久久| 精品久久久久久中文字幕一区| 精品国产福利在线观看一区| 少妇人妻精品一区二区| 久久精品国产72国产精| 少妇人妻偷人精品视频| 小辣椒福利视频精品导航| 亚洲国产综合91精品麻豆| 久久亚洲中文字幕精品有坂深雪|