In the ext2 and ext3 filesystems there are a number of additional file attributes available that are beyond the standard bits accessible by chmod. Here is an example of a neat one:
sh-3.00$ cat test.txt; ls -l test.txt; id
x86
-rw-r--r-- 1 tmp users 4 2005-09-19 00:33 test.txt
uid=1000(tmp) gid=100(users) groups=100(users),11(floppy),17(audio),18(video),19(cdrom)
sh-3.00$ rm -f test.txt
rm: cannot remove `test.txt': Operation not permitted
Seems strange. It's a typical text file. My UID is the owner of this file, but I can't delete it. Alright, let's try with root:
root@tmp:/home/tmp# id ; rm -f test.txt
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy)
rm: cannot remove `test.txt': Operation not permitted
The problem is that this file is 'immutable'. For those of you who aren't familiar with this you should check out the man page on
lsattr and
chattr. All we need to do is get rid of the immutable attribute and we're off to the races:
root@tmp:/home/tmp# lsattr test.txt
----i-------- test.txt
root@tmp:/home/tmp# chattr -i test.txt
root@tmp:/home/tmp# rm test.txt
While this flag is set any attempts to unlink, overwrite, rename, or append to the file will fail.