How to Make a File or Directory Immutable

This article provides a guide for how to make a file or directory immutable.

Background

Setting the immutable flag on a file or folder will prevent any changes to it. For folders, this means that no files or folders may be added to or removed from the immutable folder. However, files and folders in the immutable folder can be modified.

How to Make a File or Directory Immutable

To make a file or a directory immutable, use the "chattr" command with the "+i" flag.

chattr +i /path/to/file

How to Make a File or Directory No Longer Immutable

To make a file or directory no longer immutable, use the following command:

chattr -i /path/to/file

Conclusion

You now know how to make a file or directory immutable.

  • immutable, file permissions
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...

Set Server Time Zones with Timedatectl

This article provides a guide to setting the server time and server time zone settings using...

htaccess RewriteRule Examples

Here are some useful mod_rewrite RewriteRule redirect examples that you can use in your .htaccess...

Using htaccess File to Block IPs

If your webserver is Apache, you may block access to your website from specific IP addresses...