一、檔案的權限和歸屬概述
1、通路權限
讀取r:允許檢視檔案内容、顯示目錄清單;
寫入w:允許修改檔案内容,允許在目錄中建立、移動、删除檔案或子目錄;
可執行x:允許運作程式、切換目錄
2、歸屬(所有權)
屬主:擁有該檔案或目錄的使用者賬号;
屬組:擁有該檔案或目錄的組賬号;
3、檢視檔案的權限和歸屬
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiInBnauETMycTNzETMwIDMwIDMy8CXyADMyAjMvwlaj9CXzRWYvxGc19CXt92YuczcplmL3d3dvw1LcpDc0RHaiojIsJye.jpg)
4、chmod設定檔案權限
chmod指令的基本文法格式如下:
應用舉例:
[[email protected] ~]# touch 1.txt
[[email protected] ~]# 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
[[email protected] ~]# chmod u+x ./1.txt
[[email protected] ~]# 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
[[email protected] ~]# chmod u-x,g+x,o+w 1.txt
[[email protected] ~]# 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
[[email protected] ~]# chmod 755 1.txt
[[email protected] ~]# 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設定檔案的歸屬
chown指令的基本文法格式如下:
應用舉例:
[[email protected] ~]# chown bob 1.txt
[[email protected] ~]# 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
[[email protected] ~]# chown :benet 1.txt
[[email protected] ~]# 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
[[email protected] ~]# chown bob:benet 1.txt
[[email protected] ~]# 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
二、目錄的權限和歸屬
1、通路權限