I wrote about this before, but its important enough to write twice
How to revoke write permissions to a directory
How to revoke your own user permissions
$ chmod u-w dirname
How to delete all permissions from anyone on your system
$ chmod a-w dirname
removing write access on a file does not stop it from being removed,
you must remove write access to the directory to protect the file from deletion – Ice Bear
How to test this
To test this, simple change the permissions and try to $ rm any_file_name
. You can even rmdir dirname
and it will protect the directory from deletion