How to Use ‘fuser’ to Match User and Process – POFTUT

How to Use ‘fuser’ to Match User and Process

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 fuser command.

View Processes Using A Directory

The processes using specified directory can be see with -v argument like below.

  • 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 Processes Using A Directory

View Processes Using A Directory

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.

View Process Using Root Directory

View Process Using Root Directory

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 -kill option.

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 --interactive or -i option like below.

How to Use ‘fuser’ to Match User and Process Infographic

How to Use 'fuser' to Match User and Process Infographic

How to Use ‘fuser’ to Match User and Process Infographic

LEARN MORE  Pgrep and Pkill Command Tutorial With Examples For Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)