Lesson 63: fuser Command
In this lesson, you'll learn how to use the fuser command to locate processes using specific files, directories, or sockets in Linux.
fuser is a simple yet powerful command-line utility intended to locate processes based on the files, directories, or sockets a particular process is accessing.
In short, it helps a system user identify processes using files or sockets.
fuser Command Syntax
The conventional syntax for using fuser is as follows:
# fuser [OPTIONS] [FILE|SOCKET]
# fuser [OPTIONS] -SIGNAL [FILE|SOCKET]
# fuser -l
fuser Command Options
| Option | Description |
|---|---|
-v or --verbose |
Enable verbose output showing USER, PID, ACCESS, and COMMAND columns |
-m NAME or --mount NAME |
Name all processes accessing a specific file or filesystem |
-k or --kill |
Kill all processes accessing a file or socket |
-i or --interactive |
Interactively confirm before killing each process |
-l or --list-signals |
List all available signals that can be sent to processes |
-SIGNAL |
Send a specific signal to matching processes |
1. Find Which Process Is Accessing a Directory
Running the fuser command without any option will display the PIDs of processes currently accessing your current working directory.
$ fuser .
Or:
$ fuser /home/ubuntu
/home/ubuntu: 1234 1891 2045
For a more detailed and clear output, enable the -v or --verbose option as follows. In the output, fuser prints out the name of the current directory, then columns of the process owner (USER), process ID (PID), the access type (ACCESS), and command (COMMAND).
$ fuser -v .
USER PID ACCESS COMMAND
/home/ubuntu: ubuntu 1234 ..c.. bash
ubuntu 1891 ..c.. vim
ubuntu 2045 ..c.. python3
Under the ACCESS column, you will see access types signified by the following letters:
c- current directorye- an executable file being runf- open file (however,fis left out in the output)F- open file for writing (Fis also excluded from the output)r- root directorym- mmap'ed file or shared library