fuser Command

Identify processes that are using files, directories, or network sockets to help with system administration, troubleshooting, and resource management.

Syntax

fuser [options] [file|directory|socket] fuser -n namespace [options] [name] fuser -s signal [options] [file|directory|socket]

The fuser command identifies processes that are using files, directories, or network sockets, helping you understand which processes are accessing specific resources.

Basic Usage

Find processes using a file

# Find processes using a specific file fuser /var/log/syslog fuser /home/user/document.txt # Find processes using a directory fuser /home/user/ fuser /var/log/

Identify which processes are currently accessing specific files or directories

Find processes using network ports

# Find processes using TCP port 80 fuser -n tcp 80 # Find processes using UDP port 53 fuser -n udp 53 # Find processes using specific port ranges fuser -n tcp 22,80,443

Identify processes using specific network ports or protocols

Verbose output

# Show detailed information fuser -v /var/log/syslog # Show process details with names fuser -v -n tcp 80 # Show mount points fuser -v -m /home

Get detailed information about processes and their usage patterns

Common Options

Output format options

# Verbose output fuser -v filename # Show process names fuser -v -n tcp port # Show mount points fuser -m directory # Show kernel access fuser -k filename

Control the amount and type of information displayed

Namespace options

# TCP namespace fuser -n tcp port # UDP namespace fuser -n udp port # Unix domain socket fuser -n unix socket # Network namespace fuser -n net port

Specify the type of resource to search for processes

Signal and kill options

# Send signal to processes fuser -s SIGTERM filename # Kill processes using file fuser -k filename # Interactive kill fuser -i -k filename # Send specific signal fuser -s 9 filename

Send signals or kill processes that are using specific resources

Practical Examples

System administration tasks

# Check what's using a log file fuser -v /var/log/syslog # Find processes using home directory fuser -v /home # Check network port usage fuser -v -n tcp 22 fuser -v -n tcp 80 # Find processes using mount point fuser -v -m /mnt/usb

Common administrative tasks using fuser

Troubleshooting scenarios

# Why can't I unmount a filesystem? fuser -v -m /mnt/usb # What's using my network port? fuser -v -n tcp 8080 # Why can't I delete a file? fuser -v /path/to/file # Check for file locks fuser -v /var/lock/file.lock

Use fuser to diagnose common system issues

Process management

# Kill all processes using a file fuser -k filename # Gracefully terminate processes fuser -s SIGTERM filename # Interactive process termination fuser -i -k filename # Force kill processes fuser -s SIGKILL filename

Manage processes that are using specific resources

Best Practices

fuser Best Practices
  • Use verbose mode (-v) for detailed information
  • Check processes before killing them
  • Use appropriate signals for process termination
  • Combine with other commands for comprehensive analysis
  • Use for troubleshooting mount and file access issues
  • Check network port usage before service configuration
Common Pitfalls
  • Killing processes - Be careful with -k option as it can terminate important processes
  • Permission issues - Some operations may require root privileges
  • Network scanning - Scanning network ports may trigger security alerts
  • File locks - Some files may be locked by the kernel, not user processes
  • Timing issues - Process usage can change between commands

See also