4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / share / man / man8 / sticky.8
CommitLineData
7b766c04
KB
1.\" Copyright (c) 1980, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3c389526 3.\"
b42074ab 4.\" %sccs.include.redist.man%
3c389526 5.\"
7b766c04 6.\" @(#)sticky.8 8.1 (Berkeley) %G%
b42074ab
CL
7.\"
8.Dd
9.Dt STICKY 8
10.Os BSD 4
11.Sh NAME
12.Nm sticky
13.Nd sticky text and append-only directories
14.Sh DESCRIPTION
15A special file mode, called the
16.Em sticky bit
17(mode S_ISVTX),
87150da0 18is used to indicate special treatment
b42074ab
CL
19for shareable executable files and directories.
20See
21.Xr chmod 2
22or
23the file
24.Pa /usr/include/sys/stat.h
25for an explanation of file modes.
26.Sh STICKY TEXT EXECUTABLE FILES
27An executable shareable file whose sticky bit is set
28will not be immediately discarded from swap space after execution.
29The kernel will hoard the text segment of the file for future
30reuse and avoid having to reload the program.
7cb6b840
MK
31Shareable text segments are normally placed
32in a least-frequently-used cache after use,
33and thus the `sticky bit' has little effect on commonly-used text images.
b42074ab
CL
34.Pp
35Sharable executable files are created with the
36.Fl n
3c389526 37and
b42074ab 38.Fl z
3c389526 39options of
b42074ab
CL
40the loader
41.Xr ld 1 .
42.Pp
87150da0
DS
43Only the super-user can set the sticky bit
44on a sharable executable file.
b42074ab 45.Sh STICKY DIRECTORIES
87150da0
DS
46A directory whose `sticky bit' is set
47becomes an append-only directory, or, more accurately,
48a directory in which the deletion of files is restricted.
49A file in a sticky directory may only be removed or renamed
50by a user if the user has write permission for the directory and
51the user is the owner of the file, the owner of the directory,
52or the super-user.
b42074ab
CL
53This feature is usefully applied to directories such as
54.Pa /tmp
87150da0
DS
55which must be publicly writable but
56should deny users the license to arbitrarily
57delete or rename each others' files.
b42074ab 58.Pp
87150da0
DS
59Any user may create a sticky directory.
60See
b42074ab 61.Xr chmod 1
87150da0 62for details about modifying file modes.
b42074ab 63.Sh BUGS
87150da0
DS
64Since the text areas of sticky text executables are stashed in the swap area,
65abuse of the feature can cause a system to run out of swap.
b42074ab 66.Pp
87150da0 67Neither
b42074ab 68.Xr open 2
87150da0 69nor
b42074ab 70.Xr mkdir 2
87150da0 71will create a file with the sticky bit set.
b42074ab
CL
72.Sh HISTORY
73A
74.Nm
75command appeared in Version 32V AT&T UNIX.