When Firefox starts, it creates two files in the user settings directory: places.sqlite-shm and places.sqlite-wal and deletes them upon exit.
Just for the experiment, I set the permissions of those files so that only root can read/write them. But when I closed Firefox, those files got deleted! How is that possible? Firefox is not running with root permissions...
Don't ask me why I'm doing this, I'm just curious
A user with write permission on a directory can delete any file within that directory, unless the directory has the "sticky" bit set (as is commonly set on
/tmp
).In addition, the owner of a directory can delete any file within that directory, regardless of sticky bit or other permissions.
The "sticky" bit when set on a directory is sometimes referred to as the "restricted deletion flag".
If you'd like to prevent your user from being able to delete those files, set the parent directory's sticky bit:
After that, you'll also need to change ownership on the directory (you'll need to do this as root):
You'll want to ensure that your user can still write to that directory, if losing ownership left your user without write access, you can either grant write access to "other":
Or you can ensure your group has access:
(Group ownership is not enough to give you the ability to delete the root-owned files.)
Good luck in your adventures, whatever they may be.
To delete a file you only need write and execute permission to the folder that holds the file. The permissions of the file itself don't matter.
Because you can delete files within directories based on the permissions of the directory.
http://www.tuxfiles.org/linuxhelp/filepermissions.html