You can protect your most important files from accidental deletion by giving them a “sticky bit” attribute: chmod +t filename
You can protect your most important files from accidental deletion by giving them a “sticky bit” attribute: chmod +t filename
That will protect files not owned by you (only from being renamed or deleted), another way to do it that would protect any file (from rename / delete / modification) is:
chattr +i
I think this is specific to ext2/3/4
Actually, sticky bit only works like that on directories, from the man-page:
RESTRICTED DELETION FLAG OR STICKY BIT
The restricted deletion flag or sticky bit is a single bit, whose interpretation depends on the file type. For directories, it prevents unprivileged users from
removing or renaming a file in the directory unless they own the file or the directory; this is called the restricted deletion flag for the directory, and is com?
monly found on world-writable directories like /tmp. For regular files on some older systems, the bit saves the program’s text image on the swap device so it will
load more quickly when run; this is called the sticky bit.
Or you can do this:
sudo chmod 1755 file_or_folder_name, normally we just type:
sudo chmod 755 file_or_folder_name, but the presence of 1 makes it the same as chmod +t filename as stated above.
Then apply it recursively to the contents of a folder, so finally
sudo chmod -R 1755 file_or_folder_name
chattr +i filename worked perfectly. Thanks!