1*47468Scael.\" Copyright (c) 1980, 1991 Regents of the University of California. 2*47468Scael.\" All rights reserved. 318926Smckusick.\" 4*47468Scael.\" %sccs.include.redist.man% 518926Smckusick.\" 6*47468Scael.\" @(#)sticky.8 6.4 (Berkeley) 03/16/91 7*47468Scael.\" 8*47468Scael.Dd 9*47468Scael.Dt STICKY 8 10*47468Scael.Os BSD 4 11*47468Scael.Sh NAME 12*47468Scael.Nm sticky 13*47468Scael.Nd sticky text and append-only directories 14*47468Scael.Sh DESCRIPTION 15*47468ScaelA special file mode, called the 16*47468Scael.Em sticky bit 17*47468Scael(mode S_ISVTX), 1826027Sdonnis used to indicate special treatment 19*47468Scaelfor shareable executable files and directories. 20*47468ScaelSee 21*47468Scael.Xr chmod 2 22*47468Scaelor 23*47468Scaelthe file 24*47468Scael.Pa /usr/include/sys/stat.h 25*47468Scaelfor an explanation of file modes. 26*47468Scael.Sh STICKY TEXT EXECUTABLE FILES 27*47468ScaelAn executable shareable file whose sticky bit is set 28*47468Scaelwill not be immediately discarded from swap space after execution. 29*47468ScaelThe kernel will hoard the text segment of the file for future 30*47468Scaelreuse and avoid having to reload the program. 3128795SkarelsShareable text segments are normally placed 3228795Skarelsin a least-frequently-used cache after use, 3328795Skarelsand thus the `sticky bit' has little effect on commonly-used text images. 34*47468Scael.Pp 35*47468ScaelSharable executable files are created with the 36*47468Scael.Fl n 3718926Smckusickand 38*47468Scael.Fl z 3918926Smckusickoptions of 40*47468Scaelthe loader 41*47468Scael.Xr ld 1 . 42*47468Scael.Pp 4326027SdonnOnly the super-user can set the sticky bit 4426027Sdonnon a sharable executable file. 45*47468Scael.Sh STICKY DIRECTORIES 4626027SdonnA directory whose `sticky bit' is set 4726027Sdonnbecomes an append-only directory, or, more accurately, 4826027Sdonna directory in which the deletion of files is restricted. 4926027SdonnA file in a sticky directory may only be removed or renamed 5026027Sdonnby a user if the user has write permission for the directory and 5126027Sdonnthe user is the owner of the file, the owner of the directory, 5226027Sdonnor the super-user. 53*47468ScaelThis feature is usefully applied to directories such as 54*47468Scael.Pa /tmp 5526027Sdonnwhich must be publicly writable but 5626027Sdonnshould deny users the license to arbitrarily 5726027Sdonndelete or rename each others' files. 58*47468Scael.Pp 5926027SdonnAny user may create a sticky directory. 6026027SdonnSee 61*47468Scael.Xr chmod 1 6226027Sdonnfor details about modifying file modes. 63*47468Scael.Sh BUGS 6426027SdonnSince the text areas of sticky text executables are stashed in the swap area, 6526027Sdonnabuse of the feature can cause a system to run out of swap. 66*47468Scael.Pp 6726027SdonnNeither 68*47468Scael.Xr open 2 6926027Sdonnnor 70*47468Scael.Xr mkdir 2 7126027Sdonnwill create a file with the sticky bit set. 72*47468Scael.Sh HISTORY 73*47468ScaelA 74*47468Scael.Nm 75*47468Scaelcommand appeared in Version 32V AT&T UNIX. 76