I am the single user on this Linux machine. I tried the following procedure to protect files, but it does not work as I expected. Could someone explain why?
$ touch file
$ sudo chown root:root file
$ sudo chmod a-w file
$ ls -l file
-r--r--r-- 1 root root 0 2012-02-29 01:06 file
$ rm file
rm: remove write-protected regular empty file `file'? yes
$ ls -l file
ls: cannot access file: No such file or directory
"File" is read-only and owned by root. Why was my regular user able to delete it?
It is an odd behavior of linux permissions, but permissions to delete files are granted by the permissions on the directory, not the file.
Try this:
See http://www.tuxfiles.org/linuxhelp/filepermissions.html
To allow (RW) access to file, but prevent deletion or renaming, set the sticky bit on the directory.
http://www.techcuriosity.com/resources/linux/advanced_file_permissions_in_linux.php