Linux sticky bit and stickybit

Source: Internet
Author: User

Linux sticky bit and stickybit

Only the root or owner can delete or rename the file when setting the stick position.

 

Example:

The default apple group is fruit.

[Root @ titan ~] # Id apple

Uid = 1001 (apple) gid = 1001 (fruit) group = 1001 (fruit)

 

Step 1 shows the water Folder Information, which is not currently set with a sticking bit.

[Root @ titan/] # ls-l | grep water

Drwxr-xrwx. 4 root 4096 August 10 21:02 water

 

Step 2 shows the water subfolders.

[Root @ titan/] # ls-l water

Total usage 8

Drwxr-xr-x. 2 root 4096 August 10 21:02 mineral

Drwxr-xr-x. 2 root 4096 August 10 21:02 pure

 

Step 3 Delete the mineral folder.

[Apple @ titan water] $ rm-r mineral/

Rm: Do you want to delete the write-protected directory 'Mineral /'? Y

 

Step 4: display the water subfolders.

[Apple @ titan water] $ ls-l

Total usage 4

Drwxr-xr-x. 2 root 4096 August 10 21:02 pure

 

Step 5 set the adhesion bit for the water folder.

[Root @ titan/] # chmod o + t water

[Root @ titan/] # ls-l | grep water

Drwxr-xrwt. 3 root 4096 August 10 21:08 water

 

Step 6 Delete the pure folder as an apple user.

[Apple @ titan water] $ rm-r pure

Rm: Do you want to delete the write-protected directory 'pure '? Y

Rm: Unable to delete 'pure ': Operation not permitted

 

Step 7 delete the pure folder as the root user.

[Root @ titan water] # rm-r pure/

Rm: Do you want to delete the 'ure/'directory /'? Y

 

Step 8 shows the water subfolders.

[Root @ titan water] # ls-l

Total usage 0

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.