List process IDs of all processes that have one or more files open.
Syntax fuser [ -cfu ] file ... Options: -c The file is treated as a mount point and the utility shall report on any files open in the file system. -f The report shall be only for the named files. -u The user name, in parentheses, associated with each process ID written to standard output shall be written to standard error. file A pathname on which the file or file system is to be reported.
The fuser utility writes to standard output the process IDs of processes running on the local system that have one or more named files open. For block special devices, all processes using any file on that device are listed.
The fuser utility writes to standard error additional information about the named files indicating how the file is being used. Any output for processes running on remote systems that have a named file open is unspecified.
A user may need appropriate privilege to invoke fuser.
writes to standard output the process IDs of processes that are using the current directory and writes to standard error an indication of how those processes are using the directory and the user names associated with the processes that are using the current directory.:
$ fuser -fu .
List the process (or processes) that are locking a file, preventing the trash from being emptied:
$ fuser -f drag_file_here_from_finder
"A bank is a place where they lend you an umbrella in fair weather and ask for it back when it begins to rain" ~ Robert Frost
Related macOS commands:
fs_usage - Filesystem usage (process/pathname).
ps - List running processes (returns PID).
kill - Stop a process from running.
killall - Kill processes by name.
lsof - List open files.
top - display Linux tasks.
w - Show who is logged on and what they are doing.
Equivalent Windows command: OPENFILES - List or disconnect open files.