xref: /openbsd/share/man/man8/sticky.8 (revision a6445c1d)
1.\"	$OpenBSD: sticky.8,v 1.10 2014/02/14 17:27:58 schwarze Exp $
2.\"	$NetBSD: sticky.8,v 1.3 1994/11/30 19:36:27 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)sticky.8	8.1 (Berkeley) 6/5/93
32.\"
33.Dd $Mdocdate: February 14 2014 $
34.Dt STICKY 8
35.Os
36.Sh NAME
37.Nm sticky
38.Nd sticky text and append-only directories
39.Sh DESCRIPTION
40A special file mode, called the
41.Em sticky bit
42(mode S_ISVTX),
43is used to indicate special treatment for files and directories.
44See
45.Xr chmod 2
46or
47the file
48.Pa /usr/include/sys/stat.h
49for an explanation of file modes.
50.Sh STICKY FILES
51Historically, an executable shareable file which had the sticky bit set
52was not immediately discarded from swap space after execution.
53The kernel hoarded the text segment of the file for future reuse,
54thus avoiding having to reload the program.
55This is no longer true on modern systems;
56the current virtual memory system keeps track of recently used executables,
57making the sticky bit for files redundant.
58The sticky bit can still be set on files, but without any effect.
59.Pp
60Only the superuser can set the sticky bit on a file,
61though the owner of the file may clear the sticky bit.
62.Sh STICKY DIRECTORIES
63A directory with the
64.Sq sticky bit
65set places restrictions on file deletion:
66a file in a sticky directory may only be removed or renamed
67by a user if the user has write permission for the directory and
68the user is the owner of the file, the owner of the directory,
69or the superuser.
70This feature is usefully applied to directories such as
71.Pa /tmp
72which must be publicly writable but
73should deny users the license to arbitrarily
74delete or rename each others' files.
75.Pp
76Any user may create a sticky directory.
77See
78.Xr chmod 1
79for details about modifying file modes.
80.Sh HISTORY
81A
82.Nm
83command appeared in
84.At 32v .
85.Sh BUGS
86Neither
87.Xr open 2
88nor
89.Xr mkdir 2
90will create a file with the sticky bit set.
91