Linux权限列中加号及点的含义
发布时间:2018-11-01一、综述Linux中,ls -l命令可谓是最常用不过了。命令显示结果中的第一列也是我们比较关注的地方,一般说法是表示权限的字符占10个位置。可是,我们也经常看到在这一列中第十一个位置也有内容显示,最常见的非那个点(.)莫属了,还有加号(+)也会出现在这个位置,这到底是怎么回事呢?让我们亲手来实践一下吧?
二、关于权限列内的点(.)2.1 让我们来看一下根目录。
[root@DCGH ~]# ls -lZ /
lrwxrwxrwx. root root system_u:object_r:bin_t:s0 bin -> usr/bin
dr-xr-xr-x. root root system_u:object_r:boot_t:s0 boot
drwxr-xr-x. root root system_u:object_r:device_t:s0 dev
drwxr-xr-x. root root system_u:object_r:etc_t:s0 etc
drwxr-xr-x. root root system_u:object_r:home_root_t:s0 home
lrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib -> usr/lib
lrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib64 -> usr/lib64
drwxr-xr-x. root root system_u:object_r:mnt_t:s0 media
drwxr-xr-x. root root system_u:object_r:mnt_t:s0 mnt
drwxr-xr-x. root root system_u:object_r:usr_t:s0 opt
dr-xr-xr-x. root root system_u:object_r:proc_t:s0 proc
dr-xr-x---. root root system_u:object_r:admin_home_t:s0 root
drwxr-xr-x. root root system_u:object_r:var_run_t:s0 run
lrwxrwxrwx. root root system_u:object_r:bin_t:s0 sbin -> usr/sbin
drwxr-xr-x. root root system_u:object_r:var_t:s0 srv
dr-xr-xr-x. root root system_u:object_r:sysfs_t:s0 sys
drwxrwxrwt. root root system_u:object_r:tmp_t:s0 tmp
drwxr-xr-x. root root system_u:object_r:usr_t:s0 usr
drwxr-xr-x. root root system_u:object_r:var_t:s0 var
2.2 在HOME目录分别创建一个文件和目录,观察权限了第十一个位置的详细情况。
[root@DCGH ~]# touch DCGH
[root@DCGH ~]# mkdir DCGH-DIR
[root@DCGH ~]# ls -l
总用量 0
-rw-r--r--. 1 root root 0 3月 28 10:23 DCGH
drwxr-xr-x. 2 root root 6 3月 28 10:24 DCGH-DIR
2.3 查看本机SELinux状态,并列举本目录下文件和目录关于SELinux的基本情况。
[root@DCGH ~]# getenforce
Enforcing
[root@DCGH ~]# ls -lZ
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 DCGH
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR
3.4 关闭SELinux,再创建实验文件和目录,再次列举本目录及根下文件和目录关于SELinux的基本情况。
[root@DCGH ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
[root@DCGH ~]# reboot
[root@DCGH ~]# getenforce
Disabled
[root@DCGH ~]# ls -lZ
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 DCGH
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR
[root@DCGH ~]# touch DCGH-later
[root@DCGH ~]# mkdir DCGH-later-dir
[root@DCGH ~]# ls -lZ
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 DCGH
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR
-rw-r--r-- root root ? DCGH-later
drwxr-xr-x root root ? DCGH-later-dir
[root@DCGH ~]# ls -lZ /lrwxrwxrwx. root root system_u:object_r:bin_t:s0 bin -> usr/bin
dr-xr-xr-x. root root system_u:object_r:boot_t:s0 boot
drwxr-xr-x root root ? dev
drwxr-xr-x. root root system_u:object_r:etc_t:s0 etc
drwxr-xr-x. root root system_u:object_r:home_root_t:s0 home
lrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib -> usr/lib
lrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib64 -> usr/lib64
drwxr-xr-x. root root system_u:object_r:mnt_t:s0 media
drwxr-xr-x. root root system_u:object_r:mnt_t:s0 mnt
drwxr-xr-x. root root system_u:object_r:usr_t:s0 opt
dr-xr-xr-x root root ? proc
dr-xr-x---. root root system_u:object_r:admin_home_t:s0 root
drwxr-xr-x root root ? run
lrwxrwxrwx. root root system_u:object_r:bin_t:s0 sbin -> usr/sbin
drwxr-xr-x. root root system_u:object_r:var_t:s0 srv
dr-xr-xr-x root root ? sys
drwxrwxrwt. root root system_u:object_r:tmp_t:s0 tmp
drwxr-xr-x. root root system_u:object_r:usr_t:s0 usr
drwxr-xr-x. root root system_u:object_r:var_t:s0 var
通过上面的例子,我们可以看出来,这个点(.)不是没有用的,而是作用巨大,我们平时没怎么注意而已。开启SELinux后创建的文件和目录都会在权限列显示这个点的,关闭SELinux后创建的文件和目录在权限列是不会显示这个点的,之前创建的文件或目录保持不变。