fuser is used to identify processes using files or sockets. There are alternatives for this tool but this tool is simple according to others. In this tutorial we will look usage of the
View Processes Using A Directory
The processes using specified directory can be see with -v argument like below.
$ fuser -v .
- USER as username
- PID specified process id
- ACCESS provides file type where
- c current directory
- e executable being run
- f open file
- F open file for writing
- r root directory
- m shared library
- COMMAND is running command
View Process Using Root Directory
In previous example we have examined the current working directory but we can also specify the directory we want to inspect and list related processes. In this example we will list processes using the
/ root directory.
$ fuser -v -m /
Kill Process Which Access To Given File
fuser power is hidden its ability to kill process which access given file. We will provide the file path and kill process which access read or write for given path. We will use
$ fuser --kill /home/ismail/test.txt
Kill Process Which Access To Given File Interactively
If we are not sure wheter we should kill process and decide to ask before killing we can use
-i option like below.
$ fuser -i --kill /home/ismail/test.txt