Skip to content

Linux fuser command

The Linux fuser command is used to identify processes that are using specific files or directories. By displaying the process IDs (PIDs) of the processes that are accessing the file, it provides valuable information for troubleshooting and managing system resources efficiently. The fuser command can help in situations where you need to know which processes are preventing a file from being unmounted or deleted. It is a powerful tool for system administrators to track and manage processes on a Linux system.

fuser Syntax:

Terminal window
fuser [options] [filename]

Options:

OptionDescription
-kKill the processes using the specified file.
-mInterpret named files as a mounted filesystem.
-MSpecify a list of filesystem types to ignore.
-nRestrict the selection of processes using the file to those accessing it in the specified mode.
-sSilent mode; suppress most error messages.
-vVerbose mode; detailed information about processes is provided.

Parameters:

ParameterDescription
filenameThe name of the file for which processes are to be listed.

fuser Usage:

List Process IDs of Open Files

Terminal window
fuser -v /path/to/file

Lists the process IDs of the processes currently accessing the specified file.

Terminate Processes Using a File

Terminal window
fuser -k /path/to/file

Terminates the processes that are currently using the specified file.

List Process IDs of Open Sockets

Terminal window
fuser -v -u /path/to/socket

Lists the process IDs of the processes currently accessing the specified socket and the user names associated with those processes.

Forcefully Unmount a Filesystem

Terminal window
fuser -km /mnt/usb

Forcefully unmounts the filesystem mounted on the specified mount point by killing the processes using it.

How do I use fuser in Linux?

To use the fuser command in Linux, execute the following command:

Terminal window
fuser /path/to/file

What options can I use with fuser in Linux?

You can use various options with the fuser command in Linux, such as:

Terminal window
fuser -v /path/to/file

How do I show PIDs along with the processes using fuser in Linux?

To display PIDs along with the processes using the fuser command in Linux, use the following command:

Terminal window
fuser -u /path/to/directory

How can I kill processes using fuser in Linux?

You can send signals to kill processes using the fuser command in Linux by using the following command:

Terminal window
fuser -k /path/to/file

How do I specify a signal when killing processes with fuser in Linux?

To specify a particular signal when killing processes using the fuser command in Linux, use the following command:

Terminal window
fuser -k -INT /path/to/directory

To include processes using symbolic links when using the fuser command in Linux, execute the following command:

Terminal window
fuser -s /path/to/file

How do I list processes accessing a specific file system on Linux with fuser?

To list processes accessing a specific file system using the fuser command in Linux, use the following command:

Terminal window
fuser -m /mount/point

Applications of the fuser command

  • Find out which processes are using a specific file
  • Terminate processes that are accessing a file
  • Identify the users and process IDs using a file
  • Troubleshoot file access issues