Software >> OS >> Unix >> Linux >> How to make files immutable (unchangeable) in Linux

use chattr command

Usage: chattr [-RVf] [-+=AacDdeijsSu] [-v version] files...

check current setting with lsattr command

Usage: lsattr [-RVadlv] [files...]

 

Set immutable flag

# chattr +i important_file.conf

 

Unset immutable flag

# chattr -i important_file.conf

Set append only flag

# chattr +a example.txt

Unset append only flag
# chattr -a example.txt

Set recursively

# chattr -R +i myfolder

Unset recursively

# chattr -R -i myfolder