fuser - List process IDs of processes with open files

Format

fuser [-cfku] file ...

Description

The fuser command writes to standard output the process IDs of all processes running on the local system that have one or more named files open. file is the path name of the file for which information is to be reported, or, if the -c option is used, the path name of a file on the file system for which information is to be reported. It also writes additional information to standard error, such as the user name of the process and a character indicating how the process is using the file.

fuser only reports on local processes, not remote ones.It only reports information for processes that the user has appropriate privileges to access. Only a superuser can access information for processes that belong to another user.

Options

-c
Reports on all open files within the file system that the specified file is a member of.
-f
Reports on only the named files. This is the default.
-k
Sends the SIGKILL signal to each local process (with the exception of the fuser process and parent processes of fuser). Only a superuser can terminate a process that belongs to another user. This option is a z/OS extension.
-u
Writes to standard error the user name associated with each process ID written to standard output.

Usage notes

fuser writes the process ID for each process to standard output. fuser also writes the following to standard error:
  • The path name of each file specified on the command line.
  • An indicator of how the process is using this file (written after the process ID):
    -c
    The process is using the file as its current directory.
    -r
    The process is using the file as its root directory.
    If no character follows the PID, this means that the process has the file open.
  • When the -u option is specified, fuser writes the user name corresponding to the real user ID of the process.

Examples

  1. To list the process numbers of local processes using the /etc/magic file, enter:
    fuser /etc/magic
    which will give you the following output:
    /etc/magic:  67109274 144
  2. To display the user names associated with the processes accessing the file /etc/magic:
    fuser -u /etc/magic
    Your output would be:
    /etc/magic:  67109274(Steve) 144(Fred)
  3. To terminate all of the processes using a given file system, enter either the mount point name or the name of a file in that file system:
    fuser -ku /u/home
    or
    fuser -kuc /u/home/code
    Your output would look like:
    /u/home/code:  111111c(Steve) 222222r(Erin) 333333(Garth)
    444444c(Steve) 555555r(Renata) 66666c(Angie)
    This command lists the process number and user name, and then sends a kill signal to each process that is using the /u/home file system. Only a superuser can terminate processes that belong to another user. You might want to use this command if you are trying to unmount the /u/home file system and a process that is accessing the file system prevents this.

Exit values

0
Successful completion.
1
An error occurred.

Related information

kill, ps