xref: /freebsd/usr.bin/fstat/fuser.1 (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
1.\" Copyright (c) 2005-2011 Stanislav Sedov <stas@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd June 18, 2020
28.Dt FUSER 1
29.Os
30.Sh NAME
31.Nm fuser
32.Nd list IDs of all processes that have one or more files open
33.Sh SYNOPSIS
34.Nm
35.Op Fl cfkmu
36.Op Fl M Ar core
37.Op Fl N Ar system
38.Op Fl s Ar signal
39.Ar
40.Sh DESCRIPTION
41The
42.Nm
43utility writes to stdout the PIDs of processes that have one or
44more named files open.
45For block and character special devices, all processes using files
46on that device are listed.
47A file is considered open by a process if it was explicitly opened,
48is the working directory, root directory, jail root directory,
49active executable text, kernel trace file or the controlling terminal
50of the process.
51If
52.Fl m
53option is specified, the
54.Nm
55utility will also look through mmapped files.
56.Pp
57The following options are available:
58.Bl -tag -width indent
59.It Fl c
60Treat files as mount points and report on any files open in the file system.
61.It Fl f
62The report must be only for named files.
63.It Fl k
64Send signal to reported processes
65.Pq Dv SIGKILL No by default .
66.It Fl M Ar core
67Extract values associated with the name list from the specified core
68instead of the default
69.Pa /dev/kmem .
70.It Fl m
71Search through mmapped files too.
72.It Fl N Ar system
73Extract the name list from the specified system instead of the default,
74which is the kernel image the system has booted from.
75.It Fl s Ar signal
76Use given signal name instead of default
77.Dv SIGKILL .
78.It Fl u
79Write the user name associated with each process to stderr.
80.El
81.Pp
82The following symbols, written to stderr will indicate how files are used:
83.Pp
84.Bl -tag -width indent -compact
85.It Sy a
86The file is open as append only
87.Pq Dv O_APPEND No was specified .
88.It Sy c
89The file is the current workdir directory of the process.
90.It Sy d
91The process bypasses fs cache while writing to this file
92.Pq Dv O_DIRECT No was specified .
93.It Sy e
94Exclusive lock is hold.
95.It Sy j
96The file is the jail root of the process.
97.It Sy m
98The file is mmapped.
99.It Sy r
100The file is the root directory of the process.
101.It Sy s
102Shared lock is hold.
103.It Sy t
104The file is the kernel tracing file for the process.
105.It Sy w
106The file is open for writing.
107.It Sy x
108The file is executable text of the process.
109.It Sy y
110The process uses this file as its controlling tty.
111.El
112.Sh EXIT STATUS
113.Ex -std
114.Sh EXAMPLES
115The command
116.Ql "fuser -fu \&."
117writes to standard output the process IDs of processes that are using the
118current directory and writes to stderr an indication of how those processes are
119using the directory and user names associated with the processes that are using
120this directory.
121.Sh SEE ALSO
122.Xr fstat 1 ,
123.Xr ps 1 ,
124.Xr systat 1 ,
125.Xr iostat 8 ,
126.Xr pstat 8 ,
127.Xr vmstat 8
128.Sh STANDARDS
129The
130.Nm
131utility is expected to conform to
132.St -p1003.1-2004 .
133.Sh HISTORY
134The
135.Nm
136utility appeared in
137.Fx 9.0 .
138.Sh AUTHORS
139The
140.Nm
141utility and this manual page was written by
142.An Stanislav Sedov Aq Mt stas@FreeBSD.org .
143.Sh BUGS
144Since
145.Nm
146takes a snapshot of the system, it is only correct for a very short period
147of time.
148When working via
149.Xr kvm 3
150interface the report will be limited to filesystems the
151.Nm
152utility knows about (currently only cd9660, devfs, nfs, ntfs, nwfs, udf,
153ufs and zfs).
154