xref: /openbsd/usr.bin/fstat/fuser.1 (revision e5dd7070)
1.\"	$OpenBSD: fuser.1,v 1.8 2017/10/17 22:47:58 schwarze Exp $
2.\"
3.\" Copyright (c) 2002 Peter Werner <peterw@ifost.org.au>
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\"
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. The name of the author may not be used to endorse or promote products
13.\"    derived from this software without specific prior written permission.
14.\"
15.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19.\" EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.Dd $Mdocdate: October 17 2017 $
27.Dt FUSER 1
28.Os
29.Sh NAME
30.Nm fuser
31.Nd identify process IDs holding specific files open
32.Sh SYNOPSIS
33.Nm
34.Op Fl cfku
35.Op Fl M Ar core
36.Op Fl N Ar system
37.Op Fl s Ar signal
38.Ar
39.Sh DESCRIPTION
40The
41.Nm
42utility writes to standard output the process IDs of processes running
43on the local system that have one or more of the named files open.
44If
45.Ar file
46is a mounted block device, the output will show all processes having
47files opened on that file system.
48.Pp
49The options are as follows:
50.Bl -tag -width Ds
51.It Fl c
52The file is treated as a mount point and
53.Nm
54will report on any files open in the file system.
55.It Fl f
56Report only for the named file(s).
57.It Fl k
58Send the SIGKILL signal to each process.
59.It Fl M Ar core
60Extract values associated with the name list from the specified core
61instead of the running kernel.
62.It Fl N Ar system
63Extract the name list from the specified system instead of the running kernel.
64.It Fl s Ar signal
65Send the specified
66.Ar signal
67to each process.
68The
69.Ar signal
70may be specified as a signal number or as a symbolic name either with
71or without the
72.Dq SIG
73prefix.
74Signal names are not case sensitive.
75For example, the following signal arguments are equivalent:
76.Dq 9 ,
77.Dq kill ,
78.Dq SIGKILL .
79.It Fl u
80The username of the process using the file will be printed in brackets
81to standard error.
82If the username is unable to be determined, the real user ID will be printed
83instead.
84.El
85.Pp
86The
87.Fl c
88and
89.Fl f
90options are mutually exclusive.
91.Pp
92The name of the file followed by a colon
93.Pq Sq \&:
94is printed to standard error.
95The following characters may be printed to standard error after the process ID
96if the described conditions are true:
97.Pp
98.Bl -tag -width Ds -offset indent -compact
99.It c
100The file is the process's current working directory.
101.It r
102The file is the process's root directory.
103.It t
104The file is the process's executable text.
105.El
106.Sh EXIT STATUS
107.Ex -std fuser
108.Sh EXAMPLES
109Print the process IDs of any processes holding files open under the
110.Ar /mnt
111filesystem:
112.Pp
113.Dl $ fuser -c /mnt
114.Pp
115Send SIGTERM to any process holding a file open under the
116.Ar /mnt
117filesystem:
118.Pp
119.Dl # fuser -c -s term /mnt
120.Pp
121Report on all files opened under the filesystem on which
122.Ar /dev/wd0a
123is mounted:
124.Pp
125.Dl $ fuser /dev/wd0a
126.Pp
127Report on all processes currently holding
128.Ar /dev/wd0a
129open:
130.Pp
131.Dl $ fuser -f /dev/wd0a
132.Sh SEE ALSO
133.Xr fstat 1 ,
134.Xr kill 1 ,
135.Xr signal 3 ,
136.Xr mount 8
137.Sh STANDARDS
138The
139.Nm
140utility is compliant with the
141X/Open System Interfaces option of the
142.St -p1003.1-2008
143specification.
144.Pp
145The flags
146.Op Fl kMNs
147are extensions to that specification.
148.Sh HISTORY
149The
150.Nm
151utility has been available since
152.Ox 4.7 .
153