Occasionally, it’s necessary or desirable to make files immutable. For instance, your /etc/resolv.conf file might be being overwritten by your provider’s DHCP settings and you wish to use DNS servers other than those that are being set by your provider.
To determine if your /etc/resolv.conf file is immutable or not, use the following command:
ls -lo /etc/resolv.conf
The result will look like this if the file is mutable:
-rw-r--r-- 1 root wheel - 38 Mar 25 13:58 /etc/resolv.conf
Or, the result will look like this is the file is immutable (notice the schg):
-rw-r--r-- 1 root wheel schg 38 Mar 25 13:58 /etc/resolv.conf
To add the immutable flag to a file, use the following command:
chflags schg /path/to/your/file
To remove the immutable flag to a file, use the following command:
chflags noschg /path/to/your/file
chflags does not work inside a jail. All flags must be set from the host server.