Fuser: Represents a process with a file or a set of interfaces
function: The fuser command uses a file or a socket interface to represent the process.
Usage: fuser [-A |-S |-c] [-4 |-6] [-N space] [-K [-i] [-signal]] [-MUVF] name ...
or fuser-l
or fuser-v
The main options are as follows.
--a: Displays all files specified on the command line and, by default, files that are accessed by at least one process can be displayed.
--c: Same as option-M for compatibility with POSIX.
--F: Ignored for compatibility with POSIX.
I: Ask the user for comments before closing the process.
--k: Ends all processes that are accessing the file.
--l: Lists all known signal names.
--m: Mount the file system.
--n<space>: Select a different namespace, which refers to the file (the default is the file name), UDP, and TCP.
--s: Processing information is not displayed, options-u and-V are ignored in this mode, and option-a cannot be used with this option.
--signal: When you end a process with a specified signal instead of Sigkill, this option is ignored when option-K is not used.
--u PID: Displays the user name.
--V: Displays detailed information about the runtime.
--V: Displays version information.
Examples of applications are as follows.
(1) List all known signal names
# fuser-l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE alrm term
Stkflt chld CONT STOP tstp ttin ttou URG xcpu xfsz vtalrm PROF WINCH IO PWR SYS
UNUSED
(2) Display process
For example, to display all processes related to the/home/cjh/directory, enter at a command prompt:
# fuser-a/HOME/CJH
/home/cjh:19169c 19197c
(3) End all processes that are accessing the file
For example, to end all processes that are accessing directory/home/cjh/tmp/, at a command prompt, enter:
#fuser-K/home/cjh/tmp/
/home/cjh/tmp/: 19169c
(4) Display user name
For example, show all processes that access directory/home/cjh/and display the user name of the process, and at the command prompt, enter:
# fuser-u/home/cjh/
/home/cjh/: 19245c (CJH)
(5) List the process number of the local process using the/etc/passwd file
#fuser/etc/passwd
(6) List all processes that are using files that have been deleted from a given file system
#fuser-d/usr
Fuser: Represents a process with a file or a set of interfaces