Administration FreeBSD Linux Tips and Tricks

Setting files as immutable.

Wouldn’t it be nice if we can set files so that even root cannot modify or delete it ? Both FreeBSD and Linux come with commands that allows us to set files as immutable.

If you have files that you don’t want anyone to modify/delete by mistake, then these commands are quite useful.

 

FreeBSD

In the case of FreeBSD, use the command chflags as below to set the file as immutable.

#chflags schg /root/test.txt

With immutable flags being set, even the root user won’t be allowed to delete/edit the file unless the flags are uncleared.
To clear the immutable flag, run the following command

#chflags noschg /root/test.txt

Linux

In the case of Linux, use the command chattr as below to set the immutable bit.

#chattr +i /root/test.txt

With immutable bit set, even the root user won’t be allowed to deleted/edit the file.

To clear the immutable flag, run the following command

#chattr -i /root/test.txt

 

Related Articles

  • Identifying malicious mail scripts on FreeBSD

    This article will help you identify an possible spam scripts that may be causing unwanted outbound mail which could cause your servers ip address to be blacklisted.There are many different...
  • Users Logged Into Server

    This article explains on how to identify those who you do not know that are on your server. This can definitely eliminate the curiosity that people can have when taking...
  • Disable SELinux

    Security-Enhanced Linux (SELinux) is a mandatory access control (MAC) security mechanism implemented in the Linux kernel. This mechanism adds an extra layer of access security to your files,directories,devices, ports and...
  • How to Display MySQL Storage Engines

    How to Display MySQL Storage Engines From the MySQL command line, issue the following command: SHOW ENGINES; You should receive a result similar to:   Typically the default storage engine...