Linux 基本命令(五)
阿新 • • 發佈:2018-11-03
1、 許可權
檢視命令:# ls -la 或者 #ll
eg:
drwxr-xr-x. 2 dalianmao dalianmao 4096 Jul 11 08:01 Desktop
檔案型別d
第一組(rwx):檔案擁有者許可權
第二組(r-x):檔案擁有組許可權位
第三組(r-x):其他所有人
第一個dalianmao:代表擁有者
第二個dalianmao:代表擁有組
2、目錄和檔案許可權
讀 r(4)
讀取檔案內容
檢查目錄內容
寫 w(2)
修改檔案內容
改變目錄內容
執行x(1)
執行檔案
進入目錄
3、修改許可權命令:chmod chown chgrp
rwx : 4+2+1=7 可以任意組合
[[email protected] ~]$ touch test1.py
[[email protected] ~]$ ls
test1.py
[[email protected] ~]$ ll
total 0
-rw-rw-r--. 1 user01 user01 0 Oct 2 00:07 test1.py
[ [email protected] ~]$ chmod 777 test1.py
[[email protected] ~]$ ll
total 0
-rwxrwxrwx. 1 user01 user01 0 Oct 2 00:07 test1.py
[[email protected] ~]$
chmod:
[[email protected] /]# ll
total 1702
dr-xr-xr-x. 2 root root 4096 Jul 13 06:41 bin
dr-xr-xr-x. 5 root root 1024 Jul 13 05:57 boot
drwxr-xr-x. 19 root root 3760 Sep 30 22:50 dev
drwxr-xr-x. 104 root root 12288 Oct 1 22:23 etc
-rw-r--r--. 1 root root 1642329 Apr 24 06:15 get-pip.py
drwxr-xr-x. 5 root root 4096 Oct 1 21:32 home
dr-xr-xr-x. 10 root root 4096 Jul 11 09:38 lib
dr-xr-xr-x. 9 root root 12288 Jul 13 06:41 lib64
drwx------. 2 root root 16384 Jul 11 07:40 lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x. 3 root root 4096 Jul 11 07:53 mnt
drwxr-xr-x. 3 root root 4096 Jul 11 07:56 opt
dr-xr-xr-x. 146 root root 0 Sep 30 22:49 proc
dr-xr-x---. 4 root root 4096 Jul 11 12:14 root
dr-xr-xr-x. 2 root root 12288 Jul 13 06:41 sbin
drwxr-xr-x. 7 root root 0 Sep 30 22:49 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x 13 root root 0 Sep 30 22:49 sys
-rw-r--r--. 1 root root 0 Oct 2 00:12 test01.py
drwxrwxrwt. 13 root root 4096 Oct 1 21:41 tmp
drwxr-xr-x. 13 root root 4096 Jul 11 07:41 usr
drwxr-xr-x. 21 root root 4096 Jul 11 07:48 var
[ [email protected] /]# chown user01 test01.py
[[email protected] /]# ll
total 1702
dr-xr-xr-x. 2 root root 4096 Jul 13 06:41 bin
dr-xr-xr-x. 5 root root 1024 Jul 13 05:57 boot
drwxr-xr-x. 19 root root 3760 Sep 30 22:50 dev
drwxr-xr-x. 104 root root 12288 Oct 1 22:23 etc
-rw-r--r--. 1 root root 1642329 Apr 24 06:15 get-pip.py
drwxr-xr-x. 5 root root 4096 Oct 1 21:32 home
dr-xr-xr-x. 10 root root 4096 Jul 11 09:38 lib
dr-xr-xr-x. 9 root root 12288 Jul 13 06:41 lib64
drwx------. 2 root root 16384 Jul 11 07:40 lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x. 3 root root 4096 Jul 11 07:53 mnt
drwxr-xr-x. 3 root root 4096 Jul 11 07:56 opt
dr-xr-xr-x. 146 root root 0 Sep 30 22:49 proc
dr-xr-x---. 4 root root 4096 Jul 11 12:14 root
dr-xr-xr-x. 2 root root 12288 Jul 13 06:41 sbin
drwxr-xr-x. 7 root root 0 Sep 30 22:49 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x 13 root root 0 Sep 30 22:49 sys
-rw-r--r--. 1 user01 root 0 Oct 2 00:12 test01.py
drwxrwxrwt. 13 root root 4096 Oct 1 21:41 tmp
drwxr-xr-x. 13 root root 4096 Jul 11 07:41 usr
drwxr-xr-x. 21 root root 4096 Jul 11 07:48 var
chgrp:
[[email protected] /]# chgrp user01 test01.py
[[email protected] /]# ll
total 1702
dr-xr-xr-x. 2 root root 4096 Jul 13 06:41 bin
dr-xr-xr-x. 5 root root 1024 Jul 13 05:57 boot
drwxr-xr-x. 19 root root 3760 Sep 30 22:50 dev
drwxr-xr-x. 104 root root 12288 Oct 1 22:23 etc
-rw-r--r--. 1 root root 1642329 Apr 24 06:15 get-pip.py
drwxr-xr-x. 5 root root 4096 Oct 1 21:32 home
dr-xr-xr-x. 10 root root 4096 Jul 11 09:38 lib
dr-xr-xr-x. 9 root root 12288 Jul 13 06:41 lib64
drwx------. 2 root root 16384 Jul 11 07:40 lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x. 3 root root 4096 Jul 11 07:53 mnt
drwxr-xr-x. 3 root root 4096 Jul 11 07:56 opt
dr-xr-xr-x. 146 root root 0 Sep 30 22:49 proc
dr-xr-x---. 4 root root 4096 Jul 11 12:14 root
dr-xr-xr-x. 2 root root 12288 Jul 13 06:41 sbin
drwxr-xr-x. 7 root root 0 Sep 30 22:49 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x 13 root root 0 Sep 30 22:49 sys
-rw-r--r--. 1 user01 user01 0 Oct 2 00:12 test01.py
drwxrwxrwt. 13 root root 4096 Oct 1 21:41 tmp
drwxr-xr-x. 13 root root 4096 Jul 11 07:41 usr
drwxr-xr-x. 21 root root 4096 Jul 11 07:48 var