Home·Terminal commands

fuser

Processes and system

Usage

fuser <file> | fuser <port>/tcp

Finds, and if you ask kills, whatever is using a file, a mount point or a port; `-k` sends SIGKILL with no chance to clean up, and it exists only on Linux (psmisc) since the macOS version has just `-cfu`.

Common flags

FlagMeaning
3000/tcpPIDs using that TCP port (Linux).
-kKill those processes. Sends SIGKILL, so no cleanup. Linux only; macOS fuser has no -k.
-iAsk before each kill, and only useful together with -k.
-vA readable table with user, PID and access type.
-m <mount>Every process using anything on that filesystem, before you unmount it.
-c / -f / -uThe only options POSIX guarantees, and all that macOS supports.

Examples

fuser 3000/tcp

Which PID is holding the port (Linux).

fuser -k -i 3000/tcp

Kill the holder, asking first (Linux).

fuser -vm /mnt/data

Find out why the filesystem says "device is busy".

What is running and what is eating the machine. Identifying it comes before killing it.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does fuser do?

Finds, and if you ask kills, whatever is using a file, a mount point or a port; `-k` sends SIGKILL with no chance to clean up, and it exists only on Linux (psmisc) since the macOS version has just `-cfu`.

Q. How do I type it?

fuser <file> | fuser <port>/tcp — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

6 are listed here; the full set is in man fuser. This command sits under Processes and system.

Related commands

man page: man fuser