Sticky bits Permission in Linux systems: How To

For windows we are using creator-owner permissions same we are using here with Linux kernel. Sticky bits is the important for the Linux kernels as you are going to share the folder for all the users. If you share single directory for all the users then the problem with that is, any user can view the contents of other user’s file and can modify it easily or he/she can also delete the shared folder or contents of other users.
linux_sb
To overcome that problem we are going to use sticky bit. Sticky bit is just the giving edit/delete permissions to specific users on shared folder. As we are going to apply it on Linux kernel you should very handy over the terminal.

First we need to add the users as bellow.
# useradd Alice
# passwd Alice
# su Alice
# ls  -all
: Permission denied
# su – Alice
# ls -all
:Permission granted
We are sated the new user Alice and also gave password for that user.

Now add another user Bob as above.
Here Alice and Bob can create files on their own folder ”/home/Alice” or   ”/home/Bob” only.
Now make directory which is open for all the users named /OpenData (Open for all the users).
# mkdir /OpenData
Now next step is to give permissions to that directory.
# chmod o+w /OpenData
Here ‘+’ denotes Adding Permission
-‘ denotes Removing Permission
‘o+w’ means giving write permissions to others.

Now Alice and Bob can create files in OpenData directory.

Now one more concept is inherited attribute comes into the picture as we are giving write permission it allows all the users in folder to access file and modify file. Even Bob have -r file permission he can modify it.
now to apply edit/delete permissions to specific users on shared folder we use Sticky bit support.
# chmod +t /OpenData
By means of it users who have created the file can only modify/delete the file and no others are allowed to modify or delete the file.
File or directory which are created by Alice under the OpenData are not accessible to Bob and Viceversa.

Enjoy the Linux Kernel configurations !

Leave a Comment