6) 10月 21 表示文件内容最近一次被修改的时间。
7) 最后一列为文件名。
如给文件file1的用户组增加执行权限:
[root@centos7 temp]# chmod g+x file1 [root@centos7 temp]# ls -l file1 -rw-r-xr-- 1 root root 0 10月 21 20:34 file1
这里g+x表示给group增加执行x的权限。
如给文件file1的其他人减少读权限:
[root@centos7 temp]# chmod o-r file1 [root@centos7 temp]# ls -l file1 -rw-r-x--- 1 root root 0 10月 21 20:34 file1
这里o-r表示给others减少读r权限。
如给文件file1的任何用户都设置成rw-权限:
[root@centos7 temp]# chmod a=rw file1 [root@centos7 temp]# ls -l file1 -rw-rw-rw- 1 root root 0 10月 21 20:34 file1
这里a=rw表示给所有人all设置成rw-权限。
或者用十进制表示法直接指定文件的权限:
[root@centos7 temp]# chmod 644 file1 [root@centos7 temp]# ls -l file1 -rw-r--r-- 1 root root 0 10月 21 20:34 file1
如给目录dir1和目录内的所有目录和文件权限都设置成777:
[root@centos7 temp]# chmod 777 -R dir1 [root@centos7 temp]# ls -l 总用量 0 drwxrwxrwx 3 root root 29 10月 21 20:34 dir1 drwxr-xr-x 2 root root 6 10月 21 20:33 dir2 -rw-r--r-- 1 root root 0 10月 21 20:34 file1
选项-R作用是递归地改变目标权限。
另外如目录/tmp的权限:
[root@centos7 tmp]# ls -l / .... drwxrwxrwt. 7 root root 88 10月 22 21:14 tmp ....
我们看到权限最后一位是t,这里代表粘滞位(sticky),它的作用是给目录特殊的权限:使用户不能删除该目录下不属于此用户的文件。
t后面的.表示该文件被selinux的安全上下文保护。
如可执行文件/bin/su的权限:
[root@centos7 bin]# ls -l /bin/su -rwsr-xr-x. 1 root root 32072 11月 20 2015 /bin/su
所有者的权限rws,这里的s代表suid,如果在用户组位置的话代表sgid,作用是给文件特殊的权限:当用户执行此文件的时候,把他当成是文件的所有者来执行。
这些特殊用途的的权限对普通用户来说知道即可。
12、lsattr 列出隐藏权限
lsattr [option] [files...]
如:
[root@centos7 temp]# lsattr ---------------- ./dir1 ---------------- ./dir2 ---------------- ./file1
列出了文件的隐藏权限位,共有16位(由于隐藏权限是文件系统相关的,不同的文件系统对于文件的隐藏权限的设定不一定相同)。
13、chattr 给文件设置隐藏权限
chattr [+-=] [mode] files...
如给文件file1增加隐藏权限a:
[root@centos7 temp]# chattr +a file1 [root@centos7 temp]# lsattr file1 -----a---------- file1
这里的a权限表示:这个文件将只能添加数据,而不能删除也不能修改数据,只有root才能配置这个属性。










