- 目錄權限:
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)
- 文件隱藏屬性
chattr +A atime不改變
chattr +S 同步寫入磁盤
chattr +s 刪除無法找回
chattr +c 自動壓縮文件,讀取時自動解壓縮
chattr +a (append only)只能追加數據,不能刪除數據 (root)
chattr +i (immutable)不能修改,不能刪除(root)
lsattr
- 特殊權限 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