Skip to main content

Posts

Showing posts from October, 2020

Sticky bits in linux

Consider a scenario where you create a Linux directory that can be used by all the users of the Linux system for creating files. Users can create, delete or rename files according to their need in this directory. If you think why would such a directory be created? There exists, for example, /tmp directory in the Linux system that can be used by different Linux users to create temporary files. Now, what if a user accidentally or deliberately deletes (or rename) a file created by some other user in this directory? So to avoid these kind of issues, the sticky bit concept is used. A Sticky bit is a permission bit that is set on a file or a directory that lets only the owner of the file/directory or the root user to delete or rename the file. No other user is given privileges to delete the file created by some other user. Given below is the command to set sticky bit on on a file or folder: bash-4.2$ chmod +t accessibleByAll/ bash-4.2$ ls -ld accessibleByAll/ drwxrwxrw t 2 indresh indresh ...