濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > Linux文件/目錄的權(quán)限及歸屬管理使用

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

熱門標(biāo)簽:外呼線路隨意切換嗎 艾澤拉斯地圖標(biāo)注 申請(qǐng)400電話收費(fèi)標(biāo) 福州語(yǔ)音電銷機(jī)器人招商 北海智能電銷機(jī)器人公司 淘寶辦理400電話是多少 滴滴急救中心地圖標(biāo)注 菏澤自動(dòng)電銷機(jī)器人公司 網(wǎng)絡(luò)電話外呼系統(tǒng)開(kāi)發(fā)

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

1、訪問(wèn)權(quán)限

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

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

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

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

屬主:擁有該文件或目錄的用戶賬號(hào);

屬組:擁有該文件或目錄的組賬號(hào);

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

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

chmod命令的基本語(yǔ)法格式如下:

應(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)限,其他用戶添加寫(xiě)入權(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命令的基本語(yǔ)法格式如下:

應(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、訪問(wèn)權(quán)限

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

屬主:擁有該目錄的用戶賬號(hào);

屬組:擁有該目錄的組賬號(hào);

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

chmod命令設(shè)置目錄權(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è)置目錄歸屬的基本格式如下:

應(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)限,默認(rè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  <!--驗(yàn)證是否設(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

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

標(biāo)簽:滄州 延安 亳州 三沙 賀州 混顯 資陽(yáng) 丹東

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux文件/目錄的權(quán)限及歸屬管理使用》,本文關(guān)鍵詞  Linux,文件,目錄,的,權(quán)限,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Linux文件/目錄的權(quán)限及歸屬管理使用》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于Linux文件/目錄的權(quán)限及歸屬管理使用的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    杭州市| 阳西县| 诏安县| 贵德县| 襄城县| 中山市| 庆城县| 肃宁县| 玉林市| 婺源县| 百色市| 胶南市| 云安县| 高密市| 仁怀市| 武穴市| 桃园市| 南丰县| 玉山县| 青冈县| 孟津县| 蓝山县| 永兴县| 互助| 昆山市| 塔河县| 石河子市| 东丰县| 黄石市| 安福县| 五华县| 什邡市| 定日县| 会同县| 三穗县| 衡山县| 武鸣县| 阿图什市| 阳泉市| 上虞市| 石首市|