Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Detailed explanation for using chattr,lsattr command

Shulou Source: shulou.com Published: 2022-06-01 04:08:17 09月30日 Update

Chattr

Chattr

-: means to subtract a permission

+: means to increase a permission

=:

Options:

I: when used for a file, it means that the file cannot be deleted, cannot be modified, and can only be viewed

When used in a directory, it means that you cannot create or delete any files or directories under this directory. You can only modify existing files.

A: when used for a file, it means that the file cannot be deleted, can be viewed, and data can be added, but it cannot be modified by vim. It is often used to automatically append content in the log.

When used in a directory, it means that no files or directories can be deleted in this directory, only new files or directories can be created, files can be modified but deletion is not allowed.

How to use it:

Chattr + I |-I FILE

Chattr + a |-a FILE

Lsattr

-a: show all files and directories

-d: if the target is a directory, only the attributes of the directory itself are listed, not those of the subfiles

Tags: Files directories permissions usage contents properties data methods methods logs targets commands Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Linux Shulou Tech Info Docker