summaryrefslogtreecommitdiffstats
path: root/doc/fuser.1
blob: 9f150da86f8e1a8ad32ce95c8115f7a78e3a61d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
.\"
.\" Copyright 1993-2005 Werner Almesberger
.\"           2005-2015 Craig Small
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.TH FUSER 1 "2015-01-26" "psmisc" "User Commands"
.SH NAME
fuser \- identify processes using files or sockets
.SH SYNOPSIS
.ad l
.B fuser
.RB [ \-fuv ]
.RB [ \-a | \-s ]
.RB [ \-4 | \-6 ]
.RB [ \-c | \-m | \-n
.IR space ]
.RB [ \ \-k
.RB [ \-i ]
.RB [ \-M ]
.RB [ \-w ]
.RB [ \- \fISIGNAL\fR]
]
.IR name " ..."
.br
.B fuser
.RB \-l
.br
.B fuser
.RB \-V
.ad b
.SH DESCRIPTION
.B fuser
displays the PIDs of processes using the specified files or file
systems.  In the default display mode, each file name is followed by a
letter denoting the type of access:
.PP
.RS
.PD 0
.TP
.B c
current directory.
.TP
.B e
executable being run.
.TP
.B f
open file.
.B f
is omitted in default display mode.
.TP
.B F
open file for writing.
.B F
is omitted in default display mode.
.TP
.B r
root directory.
.TP
.B m
mmap'ed file or shared library.
.PD
.RE
.LP
.B fuser
returns a non-zero return code if none of the specified files is
accessed or in case of a fatal error.  If at least one access has been
found,
.B fuser
returns zero.
.PP
In order to look up processes using TCP and UDP sockets, the
corresponding name space has to be selected with the
.B \-n
option. By default
.B fuser
will look in both IPv6 and IPv4 sockets.  To change the default,
behavior, use the
.B \-4
and
.B \-6
options.  The socket(s) can be specified by the local and remote port,
and the remote address.  All fields are optional, but commas in front
of missing fields must be present:
.PP
\fB[\fR\fIlcl_port\fR\fB][\fR,\fB[\fR\fIrmt_host\fR\fB][\fR,\fB[\fIrmt_port\fR\fB]]]
.PP
Either symbolic or numeric values can be used for IP addresses and port
numbers.
.PP
.B fuser
outputs only the PIDs to stdout, everything else is sent to stderr.
.SH OPTIONS
.TP
\fB\-a\fR, \fB\-\-all\fR
Show all files specified on the command line.  By default, only files
that are accessed by at least one process are shown.
.TP
\fB\-c\fR
Same as \-m option, used for POSIX compatibility.
.TP
\fB\-f\fR
Silently ignored, used for POSIX compatibility.
.TP
\fB\-k\fR, \fB\-\-kill\fR
Kill processes accessing the file.  Unless changed with
\fB\-\fR\fISIGNAL\fR, SIGKILL is sent.  An
.B fuser
process never kills itself, but may kill other
.B fuser
processes.  The effective user ID of the process executing
.B fuser
is set to its real user ID before attempting to kill.
.TP
\fB\-i\fR, \fB\-\-interactive\fR
Ask the user for confirmation before killing a process. This option is
silently ignored if
.B \-k
is not present too.
.TP
\fB\-I\fR, \fB\-\-inode\fR
For the name space
.B file
let all comparisions be based on the inodes of the specified file(s)
and never on the file names even on network based file systems.
.TP
\fB\-l\fR, \fB\-\-list\-signals\fR
List all known signal names.
.TP
\fB\-m\fR \fINAME\fR, \fB\-\-mount\fR \fINAME\fR
.I NAME
specifies a file on a mounted file system or a block device that is
mounted.  All processes accessing files on that file system are listed.
If a directory file is specified, it is automatically changed to
.IR NAME /.
to use any file system that might be mounted on that directory.
.TP
\fB\-M\fR, \fB\-\-ismountpoint\fR
Request will be fulfilled only if
.I NAME
specifies a mountpoint.  This is an invaluable seatbelt which prevents
you from killing the machine if
.I NAME
happens to not be a filesystem.
.TP
\fB\-w\fP
Kill only processes which have write access.  This option is silently
ignored if
.B \-k
is not present too.
.TP
\fB\-n \fISPACE\fR, \fB\-\-namespace\fR \fISPACE\fR
Select a different name space.  The name spaces
.B file
(file names, the default),
.B udp
(local UDP ports), and
.B tcp
(local TCP ports) are supported.  For ports, either the port number or
the symbolic name can be specified.  If there is no ambiguity, the
shortcut notation \fIname\fB/\fIspace\fR (e.g. \fI80\fB/\fItcp\fR)
can be used.
.TP
\fB\-s\fR, \fB\-\-silent\fR
Silent operation.
.B  \-u
and
.B \-v
are ignored in this mode.
.B \-a
must not be used with
.BR \-s .
.TP
\fB\-\fISIGNAL\fR
Use the specified signal instead of SIGKILL when killing processes.
Signals can be specified either by name (e.g.
.BR \-HUP ) or by
number (e.g.
.BR \-1 ).
This option is silently ignored if the
.B \-k
option is not used.
.TP
\fB\-u\fR, \fB\-\-user\fR
Append the user name of the process owner to each PID.
.TP
\fB\-v\fR, \fB\-\-verbose\fR

Verbose mode.  Processes are shown in a
.BR  ps -like
style.  The fields PID, USER and COMMAND are similar to
.BR ps .
ACCESS shows how the process accesses the file.  Verbose mode will also
show when a particular file is being access as a mount point, knfs
export or swap file.  In this case
.B kernel
is shown instead of the PID.
.TP
\fB\-V\fR, \fB\-\-version\fR
Display version information.
.TP
\fB\-4\fR, \fB\-\-ipv4\fR
Search only for IPv4 sockets.  This option must not be used with the
.B \-6
option and only has an effect with the tcp and udp namespaces.
.TP
\fB\-6\fR, \fB\-\-ipv6\fR
Search only for IPv6 sockets.  This option must not be used with the
.B \-4
option and only has an effect with the tcp and udp namespaces.
.IP \fB\-\fR
Reset all options and set the signal back to SIGKILL.
.SH FILES
.TP
/proc
location of the proc file system
.SH EXAMPLES
.TP
.B fuser \-km /home
kills all processes accessing the file system /home in any way.
.TP
\fBif fuser \-s /dev/ttyS1; then :; else \fIsomething\fB; fi\fR
invokes
.I something
if no other process is using /dev/ttyS1.
.TP
.B fuser telnet/tcp
shows all processes at the (local) TELNET port.
.SH RESTRICTIONS
Processes accessing the same file or file system several times in the
same way are only shown once.
.PP
If the same object is specified several times on the command line, some
of those entries may be ignored.
.PP
.B fuser
may only be able to gather partial information unless run with
privileges.  As a consequence, files opened by processes belonging to
other users may not be listed and executables may be classified as
mapped only.
.PP
Installing
.B fuser
SUID root will avoid problems associated with partial information, but
may be undesirable for security and privacy reasons.
.PP
.B udp
and
.B tcp
name spaces, and UNIX domain sockets can't be searched with kernels
older than 1.3.78.
.PP
Accesses by the kernel are only shown with the
.B \-v
option.
.PP
The
.B \-k
option only works on processes.  If the user is the kernel,
.B fuser
will print an advice, but take no action beyond that.
.SH BUGS
.PP
fuser \-m /dev/sgX will show (or kill with the \-k flag) all processes,
even if you don't have that device configured.  There may be other
devices it does this for too.
.PP
.B fuser
cannot report on any processes that it doesn't have permission to look
at the file descriptor table for.  The most common time this problem
occurs is when looking for TCP or UDP sockets when running
.B fuser
as a non-root user.  In this case
.B fuser
will report no access
.PP
The mount \-m option will match any file within the same device as the
specified file, use the \-M option as well if you mean to specify only
the mount point.
.SH "SEE ALSO"
.BR kill (1),
.BR killall (1),
.BR lsof (8),
.BR pkill (1),
.BR ps (1),
.BR kill (2).
.\{{{}}}