correct see also
[unix-history] / usr / src / share / man / man8 / sticky.8
CommitLineData
3c389526
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
87150da0 5.\" @(#)sticky.8 6.2 (Berkeley) %G%
3c389526 6.\"
7db7c2c4 7.TH STICKY 8 ""
3c389526
KM
8.UC 4
9.SH NAME
87150da0 10sticky \- persistent text and append-only directories
3c389526 11.SH DESCRIPTION
87150da0
DS
12The
13.I "sticky bit"
14(file mode bit 01000, see
15.IR chmod (2))
16is used to indicate special treatment
17for certain executable files and directories.
18.SH "STICKY TEXT EXECUTABLE FILES"
19While the `sticky bit'
3c389526
KM
20is set on a sharable executable file,
21the text of that file will not be removed from the system swap area.
22Thus the file does not have to be fetched from the file system
23upon each execution.
24As long as a copy remains in the swap area, the
25original text cannot be overwritten in the file system,
26nor can the file be deleted.
27(Directory entries can be removed so long as one link remains.)
28.PP
87150da0 29Sharable executable files are made by the
3c389526
KM
30.B \-n
31and
32.B \-z
33options of
34.IR ld (1).
35.PP
87150da0
DS
36To replace a sticky text executable file that has been used,
37perform the following steps:
3c389526
KM
38(1) Clear the sticky bit with
39.IR chmod (1).
40(2) Execute the old program to flush the swapped copy.
41This can be done safely even if others are using it.
42(3) Overwrite the sticky file.
43If the file is being executed by any process,
44writing will be prevented; it suffices to simply remove the file
45and then rewrite it, being careful to reset the owner and mode with
46.I chmod
47and
48.IR chown (2).
49(4) Set the sticky bit again.
50.PP
87150da0
DS
51Only the super-user can set the sticky bit
52on a sharable executable file.
53.SH "STICKY DIRECTORIES"
54A directory whose `sticky bit' is set
55becomes an append-only directory, or, more accurately,
56a directory in which the deletion of files is restricted.
57A file in a sticky directory may only be removed or renamed
58by a user if the user has write permission for the directory and
59the user is the owner of the file, the owner of the directory,
60or the super-user.
61This feature is usefully applied to directories such as /tmp
62which must be publicly writable but
63should deny users the license to arbitrarily
64delete or rename each others' files.
3c389526 65.PP
87150da0
DS
66Any user may create a sticky directory.
67See
68.IR chmod (1)
69for details about modifying file modes.
70.SH BUGS
71Sticky text executable files are
72largely unnecessary on the VAX.
73The sticky attribute is useful only for large programs that
74will page heavily to start, since text pages are normally cached in core
3c389526 75as long as possible after all instances of a text image exit.
87150da0
DS
76.PP
77Since the text areas of sticky text executables are stashed in the swap area,
78abuse of the feature can cause a system to run out of swap.
79.PP
80Neither
81.IR open (2)
82nor
83.IR mkdir (2)
84will create a file with the sticky bit set.