Posts

Showing posts with the label chattr

"Immutable" ( chattr setting ) - When You Can't Change a File in GNU/Linux

Image
So today I learned about a little thing in the GNU/Linux filesystem called "chattr" and making files "immutable". Basically you can have a plain text file that you think you have full permissions over and then not be able to modify it, rename it, delete it, etc. This nifty (and possibly maddening) trick can be setup with the "chattr" command. See my examples below... Create a simple text file shannon@ubuntu-star:~$ echo Linux Rocks > testfile Check the permissions of the file you just created: shannon@ubuntu-star:~$ ls -l testfile -rw-r--r-- 1 shannon users 12 2011-08-10 23:47 testfile Note that in the above state, I can write to the file, `mv` the file to a different name, `rm` it, etc. Now, for the magic (Or "basic commands" for a "novice" type stuff, according to http://tldp.org/LDP/abs/html/basic.html ) Use chattr to set the "immutable" attribute to the file. shannon@ubuntu-star:~$ sudo chattr +i testfile...