Skip to main content

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/
drwxrwxrwt 2 indresh indresh 4096 Jan 12 12:34 accessibleByAll/

Comments

Popular posts from this blog

Calculating CPU utilisation of a process inside C program?

The top program provides a dynamic real-time view of a running system.  It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. Mostly "top" command is used for checking CPU utilisation of processes, which helps user to check which processes are CPU intensive. By default " top " command refreshes output in interval of 3 seconds. So the percentage of CPU utilisation shown is the average CPU utilisation of a process in last 3 seconds. Check the below pictures, these are the pictures captured in 3 second interval in which top refreshes its output. Note that the time is marked in red and percentage CPU utilisation field is marked in green. top output at 15:52:22 shows percentage of CPU utilisation of processes between 15:52:19 to 15:52:22. Output refreshes after 3 seconds Suppose that user wants to see percentage CPU utilization of processes in 5 min then it can run top command...

File permissions in linux

  In Linux, there are three different types of permissions that can be assigned to files and directories: read, write, and execute. These permissions can be assigned to three different classes of users: the owner of the file or directory, the group that the file or directory belongs to, and all other users. The following are the different types of file permissions in Linux: Read (r): The read permission allows a user to view the contents of a file or directory. For directories, the read permission allows a user to list the files and directories inside it. Write (w): The write permission allows a user to modify the contents of a file or directory. For directories, the write permission allows a user to create, delete, and rename files and directories inside it. Execute (x): The execute permission allows a user to execute a file or access the contents of a directory. For directories, the execute permission allows a user to access files and directories inside it. These permissions are ...