Jump to Navigation

222 - Manage file attributes

A file attribute is metadata that describes or is associated with a computer file.

1. chattr - change file attributes on a Linux second extended file syst

chattr [ -RV ] [ -v version ] [ mode ] files...

# chattr -a myfile

-----a------- myfile

# chattr +i myfile

2. lsattr - list file attributes on a Linux second extended file system

lsattr [ -RVadv ] [ files... ]

# lsattr foo
  -----a-A----- myfile

A file with the `a' attribute set can only be open in append mode for writing. Only the superuser or a process pessessing
the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

When a file with the 'A' attribute set is accessed, its atime record is not modified. This avoids a certain amount of disk I/O for laptop systems.

A file with the `i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.
Only the superuser or a process pessessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

 

Linux:


Main menu 2

Story | by Dr. Radut