Linux 文件系统权限记序用到程序:chmod setfacl getfacl stat chattr lsattr
chmod:设置文件权限
setfacl:设置访问控制列表(access control list)
getfacl:查看访问控制列表
stat:显示inode内容(a|m|c)time内容
chattr:设置第二扩展文件的列表文件属性系统
lsattr:查看第二扩展文件的列表文件属性系统
setuid:使文件拥有和文件属主相同的x权限
setgid:使文件夹拥有和文件属组相同的x权限
sticky:使文件不可册除Test:
- [root@nagios test]# touch setuid setgid sticky
- [root@nagios test]# chown -R nagios.nagios ./
- [root@nagios test]# chmod u+s setuid && chmod g+s setgid && chmod o+t sticky
- [root@nagios test]# ll
- total 0
- -rw-r-Sr-- 1 nagios nagios 0 Mar 2800:41 setgid
- -rwSr--r-- 1 nagios nagios 0 Mar 2800:41 setuid
- -rw-r--r-T 1 nagios nagios 0 Mar 2800:41 sticky
- [root@nagios test]# su hello
- [hello@nagios test]$ pwd
- /root/test
- [hello@nagios test]$ echo hello >> setuid
- bash: setuid: Permission denied
- [hello@nagios test]$ sh setuid
- hello
- [nagios@nagios test]$ exit
- exit
- [root@nagios test]# chmod o+w sticky
- [root@nagios test]# su hello
- [hello@nagios test]$ ll sticky
- -rw-rw-rwT 1 nagios nagios 0 Mar 2800:45 sticky
- [hello@nagios test]$ rm sticky
- rm: cannot remove `sticky": Permission denied
- [hello@nagios test]$ stat sticky
- File: `sticky"
- Size: 0 Blocks: 0IO Block: 4096 regular empty file
- Device: fd00h/64768dInode: 134198Links: 1
- Access: (1666/-rw-rw-rwT)Uid: (500/nagios) Gid: (500/nagios)
- Access: 2013-03-2800:45:37.875928997 +0800
- Modify: 2013-03-2800:45:37.875928997 +0800
- Change: 2013-03-2800:46:28.050580800 +0800
#setfacl and getfacl
user:: user: 属主权限 "::"均为属主 ":" 为特殊用户 group:: group: 组和特殊组 other:: 其它人 mask:: 除了属主和其他人之外的所有人 常用选项: -d : 子目录继承父目录的特殊权限。 -R : 递归权限 |
查看是否支持ACL
- [root@nagios heelo]# tune2fs -l /dev/sda1 | grep option
- Default mount options:user_xattr acl
test:
- [root@nagios test]# touch setfacl
- [root@nagios test]# setfacl -m user::r,user:hello:rw setfacl
- [root@nagios test]# chown nagios.nagios setfacl
- [root@nagios test]# ll setfacl
- -r--rw-r--+ 1 nagios nagios 0 Mar 2800:52 setfacl
- [root@nagios test]# su nagios
- [nagios@nagios test]$ echo hello >> setfacl
- bash: setfacl: Permission denied
- [nagios@nagios test]$ exit
- exit
- [root@nagios test]# su hello
- [hello@nagios test]$ echo hello >> setfacl
- [hello@nagios test]$ cat setfacl
- hello
- [hello@nagios test]$ getfacl setfacl
- # file: setfacl
- # owner: nagios
- # group: nagios
- user::r--
- user:hello:rw-
- group::r--
- mask::rw-
- other::r--
#chattr and lsattr
Chattr +-=[acdeijstuADST]. A:Atime,告诉系统不要修改对这个文件的最后访问时间。 S:Sync,一旦应用程序对这个文件执行了写操作,使系统立刻把修改的结果写到磁盘。 a:Append Only,系统只允许在这个文件之后追加数据,不允许任何进程覆盖或截断这个文件。如果目录具有这个属性,系统将只允许在这个目录下建立和修改文件,而不允许删除任何文件。 i:Immutable,系统不允许对这个文件进行任何的修改。如果目录具有这个属性,那么任何的进程只能修改目录之下的文件,不允许建立和删除文件。 D:检查压缩文件中的错误。 d:No dump,在进行文件系统备份时,dump程序将忽略这个文件。 C:Compress,系统以透明的方式压缩这个文件。从这个文件读取时,返回的是解压之后的数据;而向这个文件中写入数据时,数据首先被压缩之后才写入磁盘。 s:Secure Delete,让系统在删除这个文件时,使用0填充文件所在的区域。 u:Undelete,当一个应用程序请求删除这个文件,系统会保留其数据块以便以后能够恢复删除这个文件。 |
test:
- [root@nagios test]# mkdir chattr
- [root@nagios test]# chattr +i chattr/
- [root@nagios test]# touch chattr/hello
- touch: cannot touch `chattr/hello": Permission denied
- [root@nagios test]# chattr -i +a chattr/
- [root@nagios test]# touch chattr/hello && echo hello >>chattr/hello && cat chattr/hello
- hello
- [root@nagios test]# rm chattr/hello
- rm: remove regular file `chattr/hello"? y
- rm: cannot remove `chattr/hello": Operation not permitted
《完》HP450安装Ubuntu 12.10黑屏的解决方法在Ubuntu下安装lispbox-0.7的一个error相关资讯 Linux文件系统
- Linux文件系统简介及其系统管理工 (今 13:21)
- 哪个文件系统最适合你的 Linux 系 (01月19日)
- Linux文件系统管理 (12/15/2015 20:58:29)
| - Linux虚拟文件系统VFS (04月04日)
- Linux磁盘及文件系统概念 (12/22/2015 15:02:55)
- Linux 文件系统(inode和block) (12/02/2015 19:34:16)
|
本文评论 查看全部评论 (0)