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.
Sometime it happens that you need 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 convenience in this directory.
Now, what if an user accidentally or deliberately deletes (or rename) a file created by some other user in this directory?
Well, to avoid these kind of issues, the concept of sticky bit is used. Since /tmp is used for this purpose. So to avoid the above scenario, /tmp use sticky bit.
chmod 777 demo
I also created two file with different user in this folder having permission 777.
ls -ld demo
drwxrwxrwx 2 guru guru 4096 Mar 11 18:17 demo
ls -l demo
-rwxrwxrwx 1 abhi abhi 0 Mar 11 17:11 file1
-rwxrwxrwx 1 anshu anshu 0 Mar 11 18:15 file2
Now turn on the sticky bit on this
chmod +t demo/
ls -ld demo
drwxrwxrwt 2 guru guru 4096 Mar 11 18:17 demo
Now what happens if one user(abhi) want to rename the 2nd user(anshu)
mv /home/guru/demo/file2 /home/guru/demo/file3
mv: cannot move '/home/guru/demo/file2' to '/home/guru/demo/file3': Operation not permitted
The origin of the sticky bit
On Linux, the sticky bit only has the use described above, on directories. Historically, it was used for something completely different on regular files, and this is where the name comes from.
When a program is executed, it takes time to load the program into memory before the user can actually start using it. If a program, for example an editor is used frequently by users the the start-up time delay was an overhead back then.
To improve this time delay, the sticky bit was introduced. The OS checked that if sticky bit on an executable is ON, then the text segment of the executable was kept in the swap space. This made it easy to load back the executable into RAM when the program was run again thus minimizing the time delay.
Modern systems such as Linux manage their cache of executables and other files automatically and don't need the sticky bit for that.
Source: “Linux Sticky Bit Concept Explained with Examples” at The Geek Stuff