fuser
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:[1]
- c
- current directory.
- e
- executable being run.
- f
- open file. f is omitted in default display mode.
- F
- open file for writing. F is omitted in default display mode.
- r
- root directory.
- m
- mmap'ed file or shared library.
In order to look up processes using TCP and UDP sockets, the corresponding name space has to be selected with the -n option. By default fuser will look in both IPv6 and IPv4 sockets. To change the default, behavior, use the -4 and -6 options. The socket(s) can be specified by the local and remote port, and the remote address.[1]
Documentation
- man 1 'fuser' [EN]
Parameters
- -k
- Kill processes accessing the file. Unless changed with -signal, SIGKILL is sent. An fuser process never kills itself, but may kill other fuser processes. The effective user ID of the process executing fuser is set to its real user ID before attempting to kill.
Examples
- Show processes using the CDROM drive
fuser '/media/cdrom'
- Kill all processes using the CDROM drive
fuser -k '/media/cdrom'