linux chattr command

chattr

Change file attributes. This is analogous to chmod above, but with different options and a different invocation syntax, and it works only on ext2/ext3 filesystems.

One particularly interesting chattr option is i. A chattr +i filename marks the file as immutable. The file cannot be modified, linked to, or deleted, not even by root. This file attribute can be set or removed only by root. In a similar fashion, the a option marks the file as append only.

 

root# chattr +i file1.txtroot# rm file1.txtrm: remove write-protected regular file `file1.txt'? y rm: cannot remove `file1.txt': Operation not permitted

 

If a file has the s (secure) attribute set, then when it is deleted its block is overwritten with binary zeroes. [2]

If a file has the u (undelete) attribute set, then when it is deleted, its contents can still be retrieved (undeleted).

If a file has the c (compress) attribute set, then it will automatically be compressed on writes to disk, and uncompressed on reads.

 

Note

The file attributes set with chattr do not show in a file listing (ls -l).

标签: commandchattrlinux
------分隔线----------------------------
· 首页 · 注册

百鸣[Baiming.org]欢迎您 百鸣[Baiming.org]欢迎您~