Fuser (Unix)

The Unix command   is used to show which processes are using a specified computer file, file system, or Unix socket.

Example
For example, to check process IDs and users accessing a USB drive:

The command displays the process identifiers (PIDs) of processes using the specified files or file systems. In the default display mode, each PID is followed by a letter denoting the type of access:


 * c : current directory.
 * e : executable being run.
 * f : open file.
 * F : open file for writing.
 * r : root directory.
 * m : mmap'ed file or shared library

Only the PIDs are written to standard output. Additional information is written to standard error. This makes it easier to process the output with computer programs.

The command can also be used to check what processes are using a network port:

The command returns a non-zero code if none of the files are accessed or in case of a fatal error. If at least one access has succeeded, fuser returns zero. The output of "fuser" may be useful in diagnosing "resource busy" messages arising when attempting to unmount filesystems.

Options
POSIX defines the following options:
 * -c : Treat the file as a mount point.
 * -f : Only report processes accessing the named files.
 * -u : Append user names in parentheses to each PID.

psmisc adds the following options, among others:
 * -k, --kill : Kill all processes accessing a file by sending a SIGKILL. Use e.g. -HUP or -1 to send a different signal.
 * -l, --list-signals : List all supported signal names.
 * -i, --interactive : Prompt before killing a process.
 * -v, --verbose : verbose mode
 * -a, --all : Display all files. Without this option, only files accessed by at least one process are shown.
 * -m, --mount : Same as -c . Treat all following path names as files on a mounted file system or block device. All processes accessing files on that file system are listed.

Related commands

 * The list of all open files and the processes that have them open can be obtained through the lsof command.
 * The equivalent command on BSD operating systems is fstat(1).