![Forrest logo](/images/logo.png)
chattr:tldr:07868
chattr: Make a file or directory immutable to changes and deletion, even by superuser.
$ chattr +i ${filename_or_directory}
try on your machine
The command "chattr +i ${filename_or_directory}" is used to modify file or directory attributes on a Unix-like operating system. Specifically, it sets the "immutable" attribute on the specified file or directory.
Here's a breakdown of the command:
- "chattr": It is the command used to change file attributes.
- "+i": This is an option provided to the chattr command. The plus sign (+) indicates that the attribute is being added, and "i" represents the "immutable" attribute.
- "${filename_or_directory}": This is a placeholder representing the actual name of the file or directory on which you want to set the immutable attribute. Replace it with the desired file or directory path.
When the "immutable" attribute (+i) is set on a file or directory, it prevents any modifications, deletions, or renaming of the file or directory, even by the root user or superuser. This attribute provides an extra layer of protection to important files or directories, ensuring they remain unchanged.
Note that setting the immutable attribute is a special operation reserved for the root user or a user with appropriate privileges.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.