fuser — Identify processes using files or ports
Linux / Service and process management / fuser.html
Shows which processes hold a given file, directory or socket.
Basic Information
| Command Name | fuser |
|---|---|
| One-line Introduction | Shows which processes hold a given file, directory or socket. |
| Provided by | psmisc package |
| Official Documentation | https://man7.org/linux/man-pages/man1/fuser.1.html |
| Supported Operating Systems | Linux |
| Installation Status | Package required (apt install psmisc) |
| Category | Linux service and process management (tags: Process and resource management (tags: process, file, port, mount)) |
What is this command?
fuser reports the PIDs holding a file or directory open.
It is commonly used to find what blocks an unmount or which process owns a port.
What problems does it solve?
- Find the cause when umount reports busy.
- Identify the process holding a port.
- Clean up processes locking a file.
- Check whether a mount is in use.
Key features
Processes using a file
Pass a path to print the PIDs that have it open.
- When to use: Diagnosing a failed unmount
- What you get: PID list with access modes
- Limitations: Some entries are hidden without privileges
Port ownership
With -n and a tcp/udp spec it finds processes using a port.
- When to use: Resolving address-in-use errors
- What you get: The PID holding the port
- Limitations: Results depend on the network namespace
Combined signaling
The -k option sends a signal to those processes.
- When to use: When releasing a lock and cleaning up at once
- What you get: The target processes terminated
- Limitations: Risk of killing unintended processes
Installation and usage
Check whether it is installed
fuser -V
apt install psmisc # Debian/Ubuntu dnf install psmisc # Fedora/RHEL
Real-world examples
Who uses a file
Find processes using a mount point.
# Find processes using this mount point
fuser -vm /mnt/data
Port owner
Find what holds 8080/tcp.
# Identify the process on port 8080
fuser -n tcp 8080
Inspect then kill
Review targets, then signal them.
# Review, then terminate the holders
fuser -vm /mnt/data
fuser -km /mnt/data