fuser - identify processes using a file or file structure
fuser [-[c|f]kqu] files [[-] [-[c|f]kqu] files
fuser outputs the process IDs of the processes that are using the files
specified as arguments. Each process ID is followed by one of these
letter codes, which identify how the process is using the file:
c As its current directory.
r As its root directory, which was set up by the chroot(1M) command.
o As an open file.
t As its text file.
m As a mapped file, requested by mmap(2) or exec(2) in the case of
dynamic shared libraries.
y As its controlling terminal.
a As its trace file located in the /proc directory.
For block special devices with mounted filesystems, processes using any
file on that device are listed (unless the -f flag is specified). If
file has the form hostname:pathname and names a mounted NFS filesystem,
all processes using any file in that system are listed.
If file has the form port/protocol or hostname:port/protocol and names no
file or directory, fuser lists all processes using sockets bound or
connected to the specified port. port may be either an integer constant
or a service name (see services(4)). protocol must be either tcp, udp,
or stp, and hostname (if specified) must be an Internet address or
hostname (see hosts(4)). For all other types of files (text files,
executables, directories, devices, UNIX-domain sockets, and so on) only
the processes using that file are reported.
The following options may be used with fuser:
-c May be used with files that are mount points for filesystems. With
that option the report is for use of the mount point and any files
within that mounted filesystem.
-f When this is used, the report is only for the named file, not for
files within a mounted filesystem or block device. Note that -f and
-c are mutually exclusive.
-u The user login name, in parentheses, also follows the process ID.
-q Quiet mode: fuser prints nothing except process IDs separated by
commas to the standard output. This option is useful in conjunction
with the -p option of ps(1).
-k The SIGKILL signal is sent to each process. Since this option
spawns kills for each process, the kill messages may not show up
immediately (see kill(2)).
- A lone dash cancels the options currently in force.
If more than one group of files are specified, the options may be
respecified for each additional group of files.
If the -q flag is not in effect, the process IDs are printed as a single
line on the standard output, separated by spaces and terminated with a
single new line. All other output is written on standard error.
Any user can use fuser. Only a privileged user can terminate another
fuser -cku /usr
If typed by a user with appropriate privileges, terminates all processes
that are preventing /usr filesystem from being unmounted, listing the
process ID and login name of each as it is killed.
fuser -u /etc/passwd
Lists process IDs and login names of processes that have the password
fuser -cku /usr -u /etc/passwd
Executes both of the above examples in a single command line.
TCP, UDP, and STP ports bound by the kernel (e.g. NFS client endpoints)
cannot be mapped to a process ID and no output will be generated.
TCP, UDP, and STP ports bound by TLI applications (e.g. rpcbind(1M))
cannot be currently mapped to a process ID and no output will be
generated. This will be corrected in a future release.
chroot(1M), mount(1M), ps(1), kill(2), signal(2), proc(4).
PPPPaaaaggggeeee 2222 [ Back ]