Chinaunix首页 | 论坛 | 博客
  • 博客访问: 241553
  • 博文数量: 88
  • 博客积分: 1429
  • 博客等级:
  • 技术积分: 523
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-18 15:31
文章分类

全部博文(88)

文章存档

2017年(2)

2016年(24)

2013年(1)

2012年(24)

2011年(15)

2010年(22)

我的朋友

分类: LINUX

2012-12-04 20:41:03

安装了个fedora 17,ls -l的时候,发现文件权限后面多了个“.
 
 
Following the file mode bits is a single character that specifies whether an alternate access method such as an access control list applies to the file. When the character following the file mode bits is a space, there is no alternate access method. When it is a printing character, then there is such a method.

GNU ls uses a ‘.’ character to indicate a file with an SELinux security context, but no other alternate access method.

A file with any other combination of alternate access methods is marked with a ‘+’ character.
 

在使用RHEL6的时候,用ls -l命令查看文件的权限的时候,你可能会发现,这个权限的表示内容,已经与以前的版本不一样了,后面多了一个点,这个点是干吗的呢?搜索了很久也没有找到答案,很是郁闷啊!于是乎就只能自己慢慢研究。
首先来看看我是如何找到答案的,这个也是我的思路,和大家分享一下。
1、直接在网上搜索,但都找不到答案。
2、怀疑会不会像域名一样,来用个点来表示结尾呢?
3、怀疑这个可能是和权限有关,想到了ACL和SELinux。
4、怀疑和文件系统有关,因为RHEL6已经用了EXT4。
这些都是我想到的,可能和这个点有关的,猜测是可以的,但绝对不能误导别人,所以我就一一来排除和验证,最终得到结果是:

这个点表示的是存在“SELinux的安全上下文”!
为什么会这样,我们来看如何得出来的结果。
我们用getenforce来查看SELinux的运行模式
[root@yufei ~]# getenforce
Enforcing

这说明SELinux是启动的,OK,我们来创建个文件
[root@yufei ~]# touch testfile
[root@yufei ~]# ls -l testfile
-rw-r–r–. 1 root root 0 Jan 16 23:06 testfile
我们看到这个文件的权限后面是有点的。
下面我们关闭这个SELinux,然后重新启动系统
[root@yufei ~]# vim /etc/sysconfig/selinux

SELINUX=enforcing
改为
SELINUX=disabled
保存退出,重新启动系统。

重新进入系统后,我们再来看一下这个SELinux的运行模式
[root@yufei ~]# getenforce
Disabled
再来创建个文件
[root@yufei ~]# touch testfile1
比较一下这两个文件
[root@yufei ~]# ls -l testfile*
-rw-r–r–. 1 root root 0 Jan 16 23:06 testfile
-rw-r–r– 1 root root 0 Jan 16 23:10 testfile1
发现testfile1这个权限的后面没有了点
再来看看这两个文件的安全上下文是什么样的
[root@yufei ~]# ls -Z testfile*
-rw-r–r–. root root unconfined_u:object_r:admin_home_t:s0 testfile
-rw-r–r– root root ? testfile1
关掉了SELinux,创建的文件就没有了这个安全上下文了,也就没有了这个点了。
我们再看看,把SELinux开启,再重新启动电脑,看看这个testfile1的安全上下文会变成什么样?
[root@yufei ~]# ls -Z testfile*
-rw-r–r–. root root system_u:object_r:admin_home_t:s0 testfile
-rw-r–r–. root root system_u:object_r:admin_home_t:s0 testfile1

重新启动后,这个testfile1文件就自动加上了这个安全上下文,而且权限的后面又多了一个点。
至于testfile这个文件的安全上下文为什么会变,我们后面学习SELinux的时候,慢慢来研究了。

阅读(953) | 评论(0) | 转发(0) |
0

上一篇:SSH log on to linux

下一篇:遇见 setuid(getuid())

给主人留下些什么吧!~~