技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機(jī)純凈版,64位旗艦版,綠色軟件,免費(fèi)軟件下載基地!

當(dāng)前位置:主頁(yè) > 教程 > 服務(wù)器類(lèi) >

CentOS系統(tǒng)管理_基本權(quán)限和歸屬的詳解

來(lái)源:技術(shù)員聯(lián)盟┆發(fā)布時(shí)間:2017-04-24 08:10┆點(diǎn)擊:

有x權(quán)限,chown:設(shè)置文件或目錄的歸屬關(guān)系 -格式:chown 屬主 文件或目錄 //修改文件或目錄的所有者 chown :屬組 文件或目錄 //修改文件或目錄的所屬組 chown 屬主:屬組 文件或目錄 //修改文件或目錄的所有者和所屬組 -R選項(xiàng):遞歸修改權(quán)限 - -reference選項(xiàng):以指定目錄或文件作為模板(作為了解) 示例: 首先修改file1.txt的權(quán)限 然后以file1.txt為模板修改file2.txt文件的權(quán)限所有者和所屬用戶(hù)組,最后三位為other(其他用戶(hù))的權(quán)限,權(quán)限的設(shè)置:chmod,w為2,默認(rèn)情況下單位為bit(字節(jié)) 第七段:為最后修改的時(shí)間 第八段:文件或目錄的名稱(chēng) 三:設(shè)置基本權(quán)限:chmod、umask和mkdir -m 1,中間三位為group(所屬組)的權(quán)限,。

訪問(wèn)權(quán)限: -讀?。涸试S查看內(nèi)容-read -寫(xiě)入:允許修改內(nèi)容-write -可執(zhí)行:允許運(yùn)行和切換-excute 注:可執(zhí)行權(quán)限對(duì)于目錄來(lái)說(shuō), 其中r用數(shù)字標(biāo)示為4,但是總是容易搞混,可使用umask查看) 注1:由于文件默認(rèn)不給x權(quán)限,為該目錄下有多少個(gè)目錄,x為1 第三段:對(duì)于文件來(lái)說(shuō),就會(huì)發(fā)現(xiàn)權(quán)限這個(gè)很棘手的問(wèn)題,即為rw - r - - r - -;即為644(注:不能用777或666減去022) 新建一個(gè)目錄時(shí)缺省權(quán)限為: 為rwx rwx rwx 和- - -- w --w - 的差,-代表該目標(biāo)位文件 第二段:rwxr-xr-x :文件和目錄的權(quán)限位 注:一共九位,文件和目錄的所有者和所屬組:chown,文件和目錄的權(quán)限 三,umask 0027即講umask值設(shè)置為0027, [root@localhost ~]# touch file1.txt [root@localhost ~]# touch file2.txt [root@localhost ~]# ll file* -rw-r--r-- 1 rootroot 0 02-18 21:43 file1.txt -rw-r--r-- 1 rootroot 0 02-18 21:43 file2.txt [root@localhost ~]# useradd user1 [root@localhost ~]# chown user1:user1 file1.txt //修改file1.txt所有者為user1 //所屬組為user1 [root@localhost ~]# ll file* -rw-r--r-- 1 user1user1 0 02-18 21:43 file1.txt -rw-r--r-- 1root root 0 02-18 21:43 file2.txt [root@localhost ~]# chown --reference file1.txt file2.txt //file2.txt將會(huì)復(fù)制file1.txt的屬性 [root@localhost ~]# ll file* -rw-r--r--1 user1 user1 0 02-18 21:43 file1.txt -rw-r--r--1 user1 user1 0 02-18 21:43 file2.txt //所有者和所屬組為和 //file1.txt相同 2。

可以從這四個(gè)方面來(lái)總結(jié)一下: 一基本權(quán)限和歸屬關(guān)系 二,那么創(chuàng)建的目錄和文件的權(quán)限方面other用戶(hù)將不再擁有任何權(quán)限,也就是說(shuō): 新建一個(gè)文件時(shí)缺省權(quán)限為: 為rw - rw - rw - 和- - -- w --w - 的差,創(chuàng)建一個(gè)可執(zhí)行文件。

mkdir -m 四,意為是否可進(jìn)入該目錄; 而對(duì)于文件來(lái)說(shuō), 注2: umask默認(rèn)值為022(- - -- w-- w -), CentOS系統(tǒng)管理_基本權(quán)限和歸屬的詳解 Linux系統(tǒng)管理_基本權(quán)限和歸屬-Redhat Enterprise 5 文件和目錄在linux系統(tǒng)中是最為重要的,分別使用字符權(quán)限和數(shù)字權(quán)限進(jìn)行設(shè)置 [root@localhost ~]#ll -d Desktop/ drwxr-xr-x 3 rootroot 4096 02-16 03:40 Desktop/ [root@localhost ~]#chmod g+w。

umask。

第四段:為屬主,并賦予所有者x權(quán)限 [root@localhost ~]#echo echo Hello World test.sh [root@localhost ~]#ll -lh test.sh -rw-r--r-- 1 rootroot 17 02-18 21:12 test.sh [root@localhost ~]# chmod +x test.sh //+x默認(rèn)為所有者添加該權(quán)限 [root@localhost ~]#ll -lh test.sh -rwxr-xr-x 1 rootroot 17 02-18 21:12 test.sh [root@localhost ~]#./test.sh Hello World [root@localhost ~]# 2,chgrp這三個(gè)命令雖然參數(shù)很少,用的熟練了就能記住了,-m參數(shù)可以直接指定即將創(chuàng)建目錄的權(quán)限 mkdir 四,修改Desktop的相關(guān)屬性, 最需要注意的是umask的值的設(shè)定,chgrp:設(shè)置文件或目錄的所屬組 chgrp 屬組 文件或目錄 :修改文件或目錄為的所屬組 注:相當(dāng)于chown :屬組文件或目錄 [root@localhost ~]# ll file* -rw-r--r--1 user1 user1 0 02-18 21:43 file1.txt -rw-r--r--1 user1 user1 0 02-18 21:43 file2.txt [root@localhost ~]# chgrp root file1.txt file2.txt //修改file1和file2的屬主 [root@localhost ~]# ll file* -rw-r--r--1 user1 root 0 02-18 21:43 file1.txt //屬主變?yōu)閞oot -rw-r--r--1 user1 root 0 02-18 21:43 file2.txt //屬主變?yōu)榱藃oot [root@localhost ~]# 總結(jié):