chattr
is used to change file attributes on linux file system.
So, when you use chattr +a
it only affects the base
directory itself and the subdirectories and files directly under it.
Why?
The term directory is used in a computer software context to refer to what appears to the user to be a container or folder that can hold files and other directories.
In Linux and other Unix-like operating system, everything on the
system is treated as being a file, and a directory is thus considered
to be just a special type of file that contains a list of file names
and the corresponding inodes for each file and directory that it
appears to contain. An inode is a data structure on a filesystem that
stores all the information about a file except its name and its actual
data.
Therefore, it can be useful to think of the word directory as being an
abbreviation for the term directory file. Although perhaps technically
redundant, it is convenient and common to use expressions such as
files and directories when referring to the contents of a directory;
an alternative is filesystem objects.
Ref: http://www.linfo.org/directory.html
When you use rm -r base
, it runs recursively (-r option) and tries to remove all the files and subdirectories and their contents but it fails to remove the base directory and the directories and files directly under it. But it successfully removes the files under the subdirectories.
As for the a
(append) attribute, you can add directories and files under it without any problem, but you can not delete or rename them. For me, it behaves perfectly as a file with it subdirectories and files directly under it.
What you wanted to achieve, to protect the directory and all the subdirctories and files under it, you should have used the -R
option to set or add the attribute Recursively
to each and all.
As documentd here:http://linux.die.net/man/1/chattr