Commit | Line | Data |
---|---|---|
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 | |
15 | A special file mode, called the | |
16 | .Em sticky bit | |
17 | (mode S_ISVTX), | |
87150da0 | 18 | is used to indicate special treatment |
b42074ab CL |
19 | for shareable executable files and directories. |
20 | See | |
21 | .Xr chmod 2 | |
22 | or | |
23 | the file | |
24 | .Pa /usr/include/sys/stat.h | |
25 | for an explanation of file modes. | |
26 | .Sh STICKY TEXT EXECUTABLE FILES | |
27 | An executable shareable file whose sticky bit is set | |
28 | will not be immediately discarded from swap space after execution. | |
29 | The kernel will hoard the text segment of the file for future | |
30 | reuse and avoid having to reload the program. | |
7cb6b840 MK |
31 | Shareable text segments are normally placed |
32 | in a least-frequently-used cache after use, | |
33 | and thus the `sticky bit' has little effect on commonly-used text images. | |
b42074ab CL |
34 | .Pp |
35 | Sharable executable files are created with the | |
36 | .Fl n | |
3c389526 | 37 | and |
b42074ab | 38 | .Fl z |
3c389526 | 39 | options of |
b42074ab CL |
40 | the loader |
41 | .Xr ld 1 . | |
42 | .Pp | |
87150da0 DS |
43 | Only the super-user can set the sticky bit |
44 | on a sharable executable file. | |
b42074ab | 45 | .Sh STICKY DIRECTORIES |
87150da0 DS |
46 | A directory whose `sticky bit' is set |
47 | becomes an append-only directory, or, more accurately, | |
48 | a directory in which the deletion of files is restricted. | |
49 | A file in a sticky directory may only be removed or renamed | |
50 | by a user if the user has write permission for the directory and | |
51 | the user is the owner of the file, the owner of the directory, | |
52 | or the super-user. | |
b42074ab CL |
53 | This feature is usefully applied to directories such as |
54 | .Pa /tmp | |
87150da0 DS |
55 | which must be publicly writable but |
56 | should deny users the license to arbitrarily | |
57 | delete or rename each others' files. | |
b42074ab | 58 | .Pp |
87150da0 DS |
59 | Any user may create a sticky directory. |
60 | See | |
b42074ab | 61 | .Xr chmod 1 |
87150da0 | 62 | for details about modifying file modes. |
b42074ab | 63 | .Sh BUGS |
87150da0 DS |
64 | Since the text areas of sticky text executables are stashed in the swap area, |
65 | abuse of the feature can cause a system to run out of swap. | |
b42074ab | 66 | .Pp |
87150da0 | 67 | Neither |
b42074ab | 68 | .Xr open 2 |
87150da0 | 69 | nor |
b42074ab | 70 | .Xr mkdir 2 |
87150da0 | 71 | will create a file with the sticky bit set. |
b42074ab CL |
72 | .Sh HISTORY |
73 | A | |
74 | .Nm | |
75 | command appeared in Version 32V AT&T UNIX. |