1*61619Sbostic.\" Copyright (c) 1980, 1991, 1993 2*61619Sbostic.\" The Regents of the University of California. All rights reserved. 318926Smckusick.\" 447468Scael.\" %sccs.include.redist.man% 518926Smckusick.\" 6*61619Sbostic.\" @(#)sticky.8 8.1 (Berkeley) 06/05/93 747468Scael.\" 847468Scael.Dd 947468Scael.Dt STICKY 8 1047468Scael.Os BSD 4 1147468Scael.Sh NAME 1247468Scael.Nm sticky 1347468Scael.Nd sticky text and append-only directories 1447468Scael.Sh DESCRIPTION 1547468ScaelA special file mode, called the 1647468Scael.Em sticky bit 1747468Scael(mode S_ISVTX), 1826027Sdonnis used to indicate special treatment 1947468Scaelfor shareable executable files and directories. 2047468ScaelSee 2147468Scael.Xr chmod 2 2247468Scaelor 2347468Scaelthe file 2447468Scael.Pa /usr/include/sys/stat.h 2547468Scaelfor an explanation of file modes. 2647468Scael.Sh STICKY TEXT EXECUTABLE FILES 2747468ScaelAn executable shareable file whose sticky bit is set 2847468Scaelwill not be immediately discarded from swap space after execution. 2947468ScaelThe kernel will hoard the text segment of the file for future 3047468Scaelreuse 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. 3447468Scael.Pp 3547468ScaelSharable executable files are created with the 3647468Scael.Fl n 3718926Smckusickand 3847468Scael.Fl z 3918926Smckusickoptions of 4047468Scaelthe loader 4147468Scael.Xr ld 1 . 4247468Scael.Pp 4326027SdonnOnly the super-user can set the sticky bit 4426027Sdonnon a sharable executable file. 4547468Scael.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. 5347468ScaelThis feature is usefully applied to directories such as 5447468Scael.Pa /tmp 5526027Sdonnwhich must be publicly writable but 5626027Sdonnshould deny users the license to arbitrarily 5726027Sdonndelete or rename each others' files. 5847468Scael.Pp 5926027SdonnAny user may create a sticky directory. 6026027SdonnSee 6147468Scael.Xr chmod 1 6226027Sdonnfor details about modifying file modes. 6347468Scael.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. 6647468Scael.Pp 6726027SdonnNeither 6847468Scael.Xr open 2 6926027Sdonnnor 7047468Scael.Xr mkdir 2 7126027Sdonnwill create a file with the sticky bit set. 7247468Scael.Sh HISTORY 7347468ScaelA 7447468Scael.Nm 7547468Scaelcommand appeared in Version 32V AT&T UNIX. 76