Knowledge

Sticky bit

Source 📝

307:
If the sticky bit, S_ISVTX, is set on a file that is a dynamic loader for an ELF executable, then when the executable is exec'ed the old process's read only address spaces will be made available to the dynamic loader in the new process. This can improve program start up time considerably. The setting
59:
For files, particularly executables, superuser could tag these as to be retained in main memory, even when their need ends, to minimize swapping that would occur when another need arises, and the file now has to be reloaded from relatively slow secondary memory. This function has become obsolete due
347:
Historically, an executable shareable file which had the sticky bit set was not immediately discarded from swap space after execution. The kernel hoarded the text segment of the file for future reuse, thus avoiding having to reload the program. This is no longer true on modern systems; the current
328:
A directory whose "sticky bit" is set becomes a directory in which the deletion of files is restricted. A file in a sticky directory may only be removed or renamed by a user if the user has write permission for the directory and the user is the owner of the file, the owner of the directory, or the
388:
executable file has the sticky bit (mode bit 01000) set, the operating system will not delete the program text from the swap area when the last user process terminates. If a 0413 a.out or ELF executable file has the sticky bit set, the operating system will not delete the program text from memory
340:
A directory with the "sticky bit" set places restrictions on file deletion: a file in a sticky directory may only be removed or renamed by a user if the user has write permission for the directory and the user is the owner of the file, the owner of the directory, or the superuser. This feature is
251:
If a directory is writable and has S_ISVTX (the sticky bit) set, files within that directory can be removed or renamed only if one or more of the following is true (see unlink(2) and rename(2)): the user owns the file, the user owns the directory, the file is writable by the user, the user is a
115:
exited. This speeds up subsequent executions by allowing the kernel to make a single operation of moving the program from swap to real memory. Thus, frequently-used programs like editors would load noticeably faster. One notable problem with "stickied" programs was replacing the executable (for
316:
A directory whose 'sticky bit' is set becomes an append-only directory in which the deletion of files is restricted. A file in a sticky directory may only be removed or renamed by a user if the user has write permission for the directory and the user is the owner of the file, the owner of the
267:
prevents the system from abandoning the swap-space image of the program-text portion of the file when its last user terminates. Then, when the next user of the file executes it, the text need not be read from the file system but can simply be swapped in, thus saving time.
317:
directory, or the super-user. This feature is usefully applied to directories such as /tmp which must be publicly writable but should deny users the license to arbitrarily delete or rename each other's files. Any user may create a sticky directory.
303:
If set on a directory, then any files created in that directory will take on the group ID of the directory rather than the group ID of the calling process. mount(1M) may be used to enable this feature regardless of the mode of the directory.
255:
If a regular file is not executable and has S_ISVTX set, the file is assumed to be a swap file. In this case, the system's page cache will not be used to hold the file's data. If set on any other file, the results are unspecified.
389:
when the last user process terminates. In either case, if the sticky bit is set the text will already be available (either in a swap area or in memory) when the next user of the file executes it, thus making execution faster.
78:
The modern function of the sticky bit refers to directories, and protects directories and their content from being hijacked by non-owners; this is found in most modern Unix-like systems. Files in a shared directory such as
171:
can rename or delete the file. Without the sticky bit set, any user with write and execute permissions for the directory can rename or delete contained files, regardless of the file's owner. Typically, this is set on the
67:
can rename or delete the file. Without the sticky bit set, any user with write and execute permissions for the directory can rename or delete contained files, regardless of the file's owner. Typically this is set on the
276:
When set on a directory, files in that directory may only be unlinked or renamed by root or the directory owner or the file owner. The fs.protected_fifos, fs.protected_regular, and fs.protected_symlinks
329:
super-user. This feature is usefully applied to directories such as /tmp which must be publicly writable but should deny users the license to arbitrarily delete or rename each other's files.
120:); to do so required removing the sticky bit from the executable, executing the program and exiting to flush the cache, replacing the binary executable, and then restoring the sticky bit. 151:
has ever supported this traditional behavior; Linux performs caching of executable files in the same way as all files, so re-executing the program to flush the cache is not necessary.
167:
operating systems. When a directory's sticky bit is set, the filesystem treats the files in such directories in a special way so only the file's owner, the directory's owner, or
63:
For directories, when a directory's sticky bit is set, the filesystem treats the files in such directories in a special way so only the file's owner, the directory's owner, or
348:
virtual memory system keeps track of recently used executables, making the sticky bit for files redundant. The sticky bit can still be set on files, but without any effect.
179:
to prevent ordinary users from deleting or moving other users' files. This feature was introduced in 4.3BSD in 1986, and today it is found in most modern Unix-like systems.
320:
The sticky bit has no effect on executable files. All optimisation on whether text images remain resident in memory is handled by the kernel's virtual memory system.
341:
usefully applied to directories such as /tmp which must be publicly writable but should deny users the license to arbitrarily delete or rename each other's files.
671: 281:
further restrict the creation of FIFOs, creation of regular files, and the following of symlinks respectively within directories with the sticky bit set.
603: 649: 451: 855: 769: 363:, is set on the directory, a process may remove or rename files within that directory only if one or more of the following is true: 332:
NetBSD does not currently treat regular files that have the sticky bit set specially, but this behavior might change in the future.
587: 871: 706: 198:
to prevent access on the file from flushing more important data from the system cache. It is also used occasionally for
876: 628: 182:
In addition, Solaris (as of Solaris 2.5) defines special behavior when the sticky bit is set on non-executable
136: 607: 292:
If set on a directory, an unprivileged user may not delete or rename files of other users in that directory.
350:
Only the superuser can set the sticky bit on a file, though the owner of the file may clear the sticky bit.
195: 20: 132: 264:
If set on a directory, an unprivileged user cannot delete or rename others' files in that directory.
191: 19:
This article is about the filesystem concept. For the technique in floating-point arithmetic, see
35: 748: 343:
Any user may create a sticky directory. See chmod(1) for details about modifying file modes.
199: 160: 46: 206: 8: 369:
the effective user ID of the process is the same as that of the owner ID of the directory
112: 727: 488:
If the sticky-bit is set on a file or directory without the execution bit set for the
83:
belong to individual owners, and non-owners may not delete, overwrite or rename them.
832: 665: 583: 240:
indicates that only file owners can link or unlink files in the specified directory.
117: 685: 366:
the effective user ID of the process is the same as that of the owner ID of the file
173: 100: 69: 295:
The FreeBSD VM system totally ignores the sticky bit (S_ISVTX) for executables.
139:
retained the old sticky bit behavior, but it has been subsequently dropped from
108: 492:
category (non-user-owner and non-group-owner), it is indicated with a capital
865: 561:
Zintz, Walter (February 1984). "The Unix Connection: What is a sticky bit?".
96: 92: 42: 462:
in the final character-place depending on whether the execution bit for the
209:
to indicate that a file has not been mounted yet. This allows programs like
104: 858:, 2010, by Wayne Pollock, archived from the original on February 3, 2012 466:
category is set or unset, respectively. For instance, on Solaris 8, the
187: 75:
to prevent ordinary users from deleting or moving other users' files.
168: 164: 64: 50: 38: 27: 811: 563: 218: 128: 404:
command and can be set using its octal mode 1000 or by its symbol
790: 144: 140: 135:
appears to have abandoned this in 2005. The 4.4-Lite release of
542: 413: 278: 56:
There are two definitions: one for files, one for directories.
537: 526:-rw-r--r-T 1 root anygroup 0 Nov 10 12:57 test 512:-rw-r--r-- 1 root anygroup 0 Nov 10 12:57 test 401: 385: 148: 124: 483:
drwxrwxrwt 4 root sys 485 Nov 10 06:01 /tmp
221:
about the sticky bit's effect on directories and files
91:
The sticky bit was introduced in the Fifth Edition of
454:, the sticky bit is represented either by the letter 123:
Subsequently, this behavior became operative only in
416:bit). For example, to add the bit on the directory 308:of the sticky bit on any other file has no effect. 284:the Linux kernel ignores the sticky bit on files. 652:. Archived from the original on November 20, 2007 474:execute bit and the sticky-bit set, shows up as: 863: 670:: CS1 maint: bot: original URL status unknown ( 604:"Archived copy of chmod man page under AIX 5.2" 424:. Or, to make sure that directory has standard 359:If a directory is writable and the sticky bit, 629:"Synopsis - man pages section 2: System Calls" 580:Computer Simulation in Physics and Engineering 21:Floating point § Addition and subtraction 372:the process has write permission for the file 159:The most common use of the sticky bit is on 577: 186:: those files, when accessed, will not be 470:directory, which by default has both the 452:symbolic file system permission notation 95:(in 1974) for use with pure executable 864: 560: 147:(as of release 2.2.1). No version of 447:directory to standard permissions). 400:The sticky bit can be set using the 856:Unix File and Directory Permissions 578:Steinhauser, Martin Oliver (2012). 496:(replacing what would otherwise be 13: 213:to ignore unmounted remote files. 205:The sticky bit is also set by the 14: 888: 849: 428:permissions, one could also type 791:"sticky.7 - NetBSD Manual Pages" 443:(the latter will also reset the 163:residing within filesystems for 825: 804: 783: 762: 835:. Uw714doc.sco.com. 2004-04-25 741: 720: 699: 686:"chmod(1) - Linux manual page" 678: 642: 621: 596: 571: 554: 243:sets the save-text attribute. 99:. When set, it instructed the 1: 707:"proc(5) - Linux manual page" 631:. Docs.oracle.com. 2011-11-01 548: 7: 872:Unix file system technology 793:. Netbsd.gw.com. 2021-05-16 531: 395: 16:UNIX file system permission 10: 893: 86: 60:to swapping optimization. 18: 814:. Openbsd.org. 2014-02-14 441:chmod 0777 /usr/local/tmp 430:chmod 1777 /usr/local/tmp 194:. This is usually set on 749:"chmod - IRIX/standard/" 730:. Nixdoc.net. 1993-06-04 502: 476: 154: 143:(as of release 3.7) and 41:that can be assigned to 877:File system permissions 770:"Mac Developer Library" 650:"HPUX chmod[2]" 437:chmod -t /usr/local/tmp 422:chmod +t /usr/local/tmp 412:is already used by the 812:"Manual Pages: sticky" 772:. Developer.apple.com 375:the process has the 34:is a user ownership 313:Mac OS X (Leopard) 222: 216: 107:of the program in 728:"chmod - FreeBSD" 589:978-3-1102-5590-4 435:To clear it, use 420:, one would type 393: 392: 252:privileged user. 226:Operating System 116:instance, during 884: 844: 843: 841: 840: 829: 823: 822: 820: 819: 808: 802: 801: 799: 798: 787: 781: 780: 778: 777: 766: 760: 759: 757: 756: 745: 739: 738: 736: 735: 724: 718: 717: 715: 714: 703: 697: 696: 694: 693: 682: 676: 675: 669: 661: 659: 657: 646: 640: 639: 637: 636: 625: 619: 618: 616: 615: 606:. Archived from 600: 594: 593: 575: 569: 568: 558: 527: 524: 520: 516: 513: 510: 506: 484: 480: 469: 446: 427: 419: 223: 215: 176: 101:operating system 82: 72: 892: 891: 887: 886: 885: 883: 882: 881: 862: 861: 852: 847: 838: 836: 831: 830: 826: 817: 815: 810: 809: 805: 796: 794: 789: 788: 784: 775: 773: 768: 767: 763: 754: 752: 747: 746: 742: 733: 731: 726: 725: 721: 712: 710: 705: 704: 700: 691: 689: 684: 683: 679: 663: 662: 655: 653: 648: 647: 643: 634: 632: 627: 626: 622: 613: 611: 602: 601: 597: 590: 576: 572: 559: 555: 551: 534: 529: 528: 525: 522: 518: 514: 511: 508: 504: 486: 485: 482: 478: 467: 444: 442: 438: 431: 425: 423: 417: 398: 174: 157: 89: 80: 70: 24: 17: 12: 11: 5: 890: 880: 879: 874: 860: 859: 851: 850:External links 848: 846: 845: 824: 803: 782: 761: 740: 719: 698: 677: 641: 620: 595: 588: 582:. De Gruyter. 570: 567:. p. 130. 552: 550: 547: 546: 545: 540: 533: 530: 503: 477: 440: 436: 429: 421: 418:/usr/local/tmp 397: 394: 391: 390: 382: 381: 380: 373: 370: 367: 357: 353: 352: 345: 338: 334: 333: 330: 326: 322: 321: 318: 314: 310: 309: 305: 301: 297: 296: 293: 290: 286: 285: 282: 274: 270: 269: 265: 262: 258: 257: 253: 249: 245: 244: 241: 238: 234: 233: 230: 227: 217:Excerpts from 156: 153: 103:to retain the 88: 85: 15: 9: 6: 4: 3: 2: 889: 878: 875: 873: 870: 869: 867: 857: 854: 853: 834: 828: 813: 807: 792: 786: 771: 765: 750: 744: 729: 723: 708: 702: 687: 681: 673: 667: 651: 645: 630: 624: 610:on 2005-01-18 609: 605: 599: 591: 585: 581: 574: 566: 565: 557: 553: 544: 541: 539: 536: 535: 501: 499: 495: 491: 475: 473: 465: 461: 457: 453: 448: 433: 415: 411: 407: 403: 387: 383: 378: 374: 371: 368: 365: 364: 362: 358: 356:SCO UnixWare 355: 354: 351: 346: 344: 339: 336: 335: 331: 327: 324: 323: 319: 315: 312: 311: 306: 302: 299: 298: 294: 291: 288: 287: 283: 280: 275: 272: 271: 266: 263: 260: 259: 254: 250: 247: 246: 242: 239: 236: 235: 231: 228: 225: 224: 220: 214: 212: 208: 203: 201: 197: 193: 189: 185: 180: 178: 170: 166: 162: 152: 150: 146: 142: 138: 134: 130: 126: 121: 119: 114: 110: 106: 102: 98: 94: 84: 76: 74: 66: 61: 57: 54: 52: 48: 44: 40: 37: 33: 29: 22: 837:. Retrieved 827: 816:. Retrieved 806: 795:. Retrieved 785: 774:. Retrieved 764: 753:. Retrieved 751:. Nixdoc.net 743: 732:. Retrieved 722: 711:. Retrieved 701: 690:. Retrieved 680: 656:February 29, 654:. Retrieved 644: 633:. Retrieved 623: 612:. Retrieved 608:the original 598: 579: 573: 562: 556: 497: 493: 489: 487: 471: 463: 459: 455: 449: 434: 409: 405: 399: 376: 360: 349: 342: 229:Directories 210: 204: 200:benchmarking 183: 181: 158: 122: 105:text segment 90: 77: 62: 58: 55: 36:access right 31: 25: 517:chmod+ttest 248:Solaris 11 207:automounter 161:directories 47:directories 866:Categories 839:2014-04-10 833:"chmod(2)" 818:2018-02-04 797:2021-05-16 776:2014-04-10 755:2014-04-10 734:2014-04-10 713:2022-03-04 709:. Man7.org 692:2014-04-10 688:. Man7.org 635:2014-04-10 614:2009-01-19 549:References 481:ls-ld/tmp 384:If a 0410 196:swap files 111:after the 109:swap space 32:sticky bit 379:privilege 219:man pages 177:directory 165:Unix-like 73:directory 65:root user 53:systems. 51:Unix-like 28:computing 666:cite web 564:HARDCOPY 532:See also 450:In Unix 396:Examples 337:OpenBSD 289:FreeBSD 237:AIX 5.2 129:UnixWare 118:patching 377:P_OWNER 361:S_ISVTX 325:NetBSD 279:sysctls 202:tests. 190:by the 145:FreeBSD 141:OpenBSD 133:Solaris 113:process 87:History 586:  543:setuid 490:others 472:others 464:others 414:setuid 273:Linux 261:HP-UX 232:Files 192:kernel 188:cached 30:, the 538:chmod 402:chmod 386:a.out 300:IRIX 184:files 155:Usage 149:Linux 125:HP-UX 97:files 43:files 672:link 658:2008 584:ISBN 523:test 521:ls-l 509:test 507:ls-l 468:/tmp 175:/tmp 169:root 127:and 93:Unix 81:/tmp 71:/tmp 45:and 39:flag 500:): 479:$ 458:or 445:tmp 439:or 426:tmp 137:BSD 49:on 26:In 868:: 668:}} 664:{{ 515:# 505:# 432:. 211:ls 131:. 842:. 821:. 800:. 779:. 758:. 737:. 716:. 695:. 674:) 660:. 638:. 617:. 592:. 519:; 498:- 494:T 460:T 456:t 410:s 408:( 406:t 23:.

Index

Floating point § Addition and subtraction
computing
access right
flag
files
directories
Unix-like
root user
/tmp directory
Unix
files
operating system
text segment
swap space
process
patching
HP-UX
UnixWare
Solaris
BSD
OpenBSD
FreeBSD
Linux
directories
Unix-like
root
/tmp directory
cached
kernel
swap files

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.