\section{Extended Attributes}

\begin{frame}
   {lsattr and chattr}

   \begin{itemize}
      \item Extended attributes may be set for files
      \begin{itemize}
         \item \texttt{i}: immutable flag
         \item \texttt{a}: append-only flag
         \item \texttt{d}: no dump flag
         \item \texttt{A}: No atime update flag
      \end{itemize}
      \item Flags are viewed with \textbf{lsattr} command
      \item Flags are set with \textbf{chattr} command
      \item Flags are stored in the file's inode flags
      \item May only be set by root
   \end{itemize}

\end{frame}

\cprotect\note{


   \textbf{Extended Attributes} associate metadata not
   interpreted directly by the filesystem with files.  Four
   \textbf{namespaces} exist: user, trusted, security and
   system.  The system namespace is used for \textbf{access
      control lists} (\textbf{ACL}s) and the security namespace
   is used by \textbf{SELinux}.

   Flag values are stored in the file inode and may be modified
   and set only by the root user.  They are viewed with
   \textbf{lsattr} and set with \textbf{chattr}.
   Flags may be set for files:
   \begin{itemize}

      \item \texttt{i} (\textbf{immutable}):
      Cannot be modified (not even by root), or deleted or
      renamed.  No hard link can be created to it, and no data
      can be written to the file.  Only the superuser can set
      or clear this attribute.

      \item \texttt{a} (\textbf{append-only}):
      Can only be opened in append mode for writing.  Only the
      superuser can set or clear this attribute.

      \item \texttt{d} (\textbf{no-dump}): Is ignored when the
      \textbf{dump} program is run.  This is useful for swap
      and cache files that you do not want to waste time
      backing up.

      \item \texttt{A} (\textbf{No atime update}): The system
      will not modify the file's \textbf{atime} (access time)
      record when the file is accessed but not otherwise
      modified.  This can increase the performance on some
      systems because it reduces the amount of disk I/O.

   \end{itemize}

   Note that there are other flags that can be set; typing
   \texttt{man chattr} will show the whole list.

   The format for \textbf{chattr} is:
   \begin{cmd}
$ chattr [+|-|=mode] filename
   \end{cmd}

   \textbf{lsattr} is used to display  attributes for a file:
   \begin{cmd}
$ lsattr filename
   \end{cmd}

}



