Linux 基本命令(五)

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  可以任意组合

[user01@localhost ~]$ touch test1.py
[user01@localhost ~]$ ls
test1.py
[user01@localhost ~]$ ll
total 0
-rw-rw-r--. 1 user01 user01 0 Oct  2 00:07 test1.py
[user01@localhost ~]$ chmod 777 test1.py 
[user01@localhost ~]$ ll
total 0
-rwxrwxrwx. 1 user01 user01 0 Oct  2 00:07 test1.py
[user01@localhost ~]$ 

chmod:

[root@localhost /]# 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
[root@localhost /]# chown user01 test01.py 
[root@localhost /]# 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:

[root@localhost /]# chgrp user01 test01.py 
[root@localhost /]# 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

猜你喜欢

转载自blog.csdn.net/dalianmao66/article/details/82931143