Server Monkey is looking for tutorial writers to join our staff. Interested applicants can send a quick introduction of themselves to apply@server-monkey.com

Chattr, a more indepth look

posted by Thor Erik

Chatter is a utility you’d find on most Linux systems, it’s sole purpose is to change file attributes.

when you use Chattr you’ll probably use it in symbolic mode, this means you will be using +, – and =(plus, minus and equals) plus either of the attributes: A, S, a, c, D, d, I, i, j, s, T, t, u.

Symbols

+ adds a attribute

- removes a attribute

= causes the attribute to be the only

Attributes

a (small A) is append only, this only allows someone to add to a file.

c (small C) is compressed

d (small D) is no dump

i (small I) is immutable, meaning no delete for anyone, not even root

j (small J) is journaling

s (small S) is secure deletion, incase you want to remove a file completely with no way of recovery(except IBAS)

t (small T) is no tailing

u (small U) is undeleteable

A (capital A) is no atime updates

D (capital D) is synchronousdirectory updates

S (capital S) is synchronous updates

T (capital T) is top of directory hierarchy, useful for important files

Options

As with most commands you got options as well

chattr got most of the common ones:

-R, recursive

-V, verbose

-f, suppress most errors

-v, version

options go first of course

Common use

most of the time you won’t use all of these options, but some you will run into quite often would be

chattr +i/chattr =i to protect files from accidental deletion

chattr +T to make a important file top of the file listings

chattr +d to prevent dumping of a file

and in some rare cases
chattr +ad to only allowing appending and prevent backup using

dump

, this could be useful for log files etc. that you only want to be appended to and not backed up

Source: man chattr

Categories: Linux ,Shell


Leave a Reply

You must be logged in to post a comment.