10.文件权限

来源:互联网 发布:开淘宝店做代销赚钱吗 编辑:程序博客网 时间:2024/06/04 19:53
  1. 目录权限:
    r (read contents in directory)
    w (modify contents of directory)
    x (access directory)

r+x: ls
w+x: touch/rm/mv/chmod
x: cd

mkdir -m 700 abc
mkdir abc (umask)

  1. 文件隐藏属性
    chattr +A atime不改变
    chattr +S 同步写入磁盘
    chattr +s 删除无法找回
    chattr +c 自动压缩文件,读取时自动解压缩
    chattr +a (append only)只能追加数据,不能删除数据 (root)
    chattr +i (immutable)不能修改,不能删除(root)

lsattr

  1. 特殊权限 SUID/SGID/Sticky Bit
    1).SUID (Set UID)
    SUID 仅用在binary file上, 执行用户暂时拥有文件owner的权限

ls -l /usr/bin/passwd

-rwsr-xr-x 1 root shadow 79336 2007-05-04 19:28 /usr/bin/passwd

2).SGID (Set GID)
文件:设定在 binary file 上面,使用者在执行该程序时, 它的有效群组 (effective group) 将会变成该程序的群组 (group id)
目录:设定在目录上面,则在该目录内所建立的文件或目录的 group,将会是此目录的 group

3). Sticky Bit
只对目录有效,在SBit的目录下,如果用户具有wx权限,在用户创建文件或目录后,只有自己和root有权力删除

SUID/SGID/SBIT权限配置
SUID: 4, u+s
SGID: 2, g+s
SBIT: 1, o+t

chmod 4755 filename

s 与 t 都是取代 x 这个参数的
x位未设置,s、t都用大写表示S、T

2013-6-24 16:52:29
获取档案属性, 例如/etc/bin/passwd
1. 传统权限 ls -al
2. 文件类型 file
3. 隐藏属性 lsattr

Linux中,具有SUID的文件
find / -perm +4000 -print

/etc下,50k~60k的文件列表
find /etc -size +50k -a -size -60k -exec ls -l {} \;

/etc下,非root用户,大于50k的文件列表
find /etc -size +50k -a ! -user root -exec ls -l {} \;

文件属性和权限控制
chgrp [-R] new_group FILE
chown [-R] new_owner FILE
chown [-R] new_owner:new_group FILE
chmod [-R] u=rwx,g=rx,o=r FILE

0 0
原创粉丝点击