Skip to main content

Sticky Bit with example

Sticky Bit is used on folders in to avoid deletion of its content by users who are in same group with the owner of the file.

Before understanding the sticky bit, I recommend reading SGID post which explains its disadvantage.


From SGID we understood that the user E1 can delete the file of E2 and vice versa.

So to avoid this, we use sticky bit.

Command

To set:
chmod o+t <dir>

To unset:
chmod o-t <dir>

eg:
# chmod o+t /project/
# ls -ld /project/
drwxrws--T. 2 root teamA 84 Aug 31 09:03 /project/


You will notice T in others permission.

Now the user E1 cannot delete file of E2 and E2 cannot delete of E1.

Below example shows E1 user trying to delete file of E2 but sticky bit didnt allow the file to get deleted.

$ rm e2_file.txt
rm: remove write-protected regular empty file ‘e2_file.txt’? y
rm: cannot remove ‘e2_file.txt’: Operation not permitted

 

Comments

Popular posts from this blog

Ansible script to stop iptables

 Ansible script to stop iptables and disable during boot Step 1. [root@cluster playbooks]# pwd /root/playbooks [root@cluster playbooks]# cat hosts [webservers] 169.254.41.221 169.254.41.222 Step2. [root@cluster playbooks]# cat iptables.yml --- - name: stop ipatbles and disable   hosts: webservers   tasks:   - name: stop iptables     service: name=iptables state=stopped   - name: disbale on iptable on boot     service: name=iptables enabled=no Step3: [root@cluster playbooks]# ansible-playbook iptables.yml PLAY [stop ipatbles and disable] *********************************************** TASK [setup] ******************************************************************* ok: [169.254.41.222] ok: [169.254.41.221] ok: [localhost] TASK [stop iptables] *********************************************************** changed: [localhost] ok: [169.254.41.221] ok: [169.254.41.222] TASK [disbale on iptable on boot] *********************************...

Understanding TCP & UDP

 TCP (Transmission Control Protocol) is stateful. This means it maintains a connection state between the communicating parties throughout the communication session. Stateful Nature of TCP Connection Establishment : TCP requires a connection to be established between the sender and receiver before data transmission can begin. This is done through a process called the three-way handshake. Three-Way Handshake : This process involves the exchange of three messages (SYN, SYN-ACK, and ACK) to establish a reliable connection. Maintaining State : During the connection, TCP keeps track of various parameters to ensure reliable and ordered data delivery. Sequence Numbers : TCP assigns sequence numbers to each byte of data to ensure it is received in the correct order. Acknowledgements (ACKs) : The receiver sends acknowledgements for the received data packets. If an ACK is not received, the sender retransmits the data. Flow Control : TCP uses a window mechanism to control the rate of data tran...

Get information about remote hosts using Ansible

Get information about remote hosts using Ansible setup command Below command gives all the information of client hosts which includes memory, server architecture, IP adresses etc. [root@ansible mywork]# ansible all -i hosts -m setup If you need just memory information of remote node then for the above command need to add filter as shown below [root@ansible mywork]# ansible all -i hosts -m setup -a "filter=ansible_*_mb" node01 | SUCCESS => {     "ansible_facts": {         "ansible_memfree_mb": 873,         "ansible_memory_mb": {             "nocache": {                 "free": 919,                 "used": 77             },             "real": {                 "free": 873,           ...