Browse Docs

๐Ÿšฉ Files

Find a process blocking a file

  • with fuser:
 1fuser  -m  </dir or /files>  # Find process blocking/using this directory or files. 
 2fuser -cu  </dir or /files>  # Same as above but add the user  
 3fuser -kcu </dir or /files>  # Kill process      
 4fuser -v  -k -HUP -i ./      # Send HUP signal to process
 5			
 6# Output will send you <PID + letter>, here is the meaning:
 7#   c  current directory.
 8#   e  executable being run.
 9#   f  open file.  (omitted in default display mode).
10#   F  open file for writing. (omitted in default display mode).
11#   r  root directory.
12#   m  mmap'ed file or shared library.
  • with lsof ( = list open file):
1lsof +D /var/log          # Find all files blocked with the process and user.
2lsof -a +L1 <mountpoint>  # Process blocking a FS.
3lsof -c ssh -c init       # Find files open by thoses processes.
4lsof -p 1753              # Find files open by PID process.
5lsof -u root              # Find files open by user.
6lsof -u ^user             # Find files open by user except this one.
7kill -9 `lsof -t -u toto` # kill user's processes.  (option -t output only PID).
  • MacGyver method:
1#When you have no fuser or lsof: 
2find /proc/*/fd -type f -links 0 -exec ls -lrt {} \;

AIX specifics (fuser)

1fuser -d /tmp                 # see the processes using the /tmp directory (AIX)
2fuser -c /your_FS             # all processes with an open file in the filesystem (AIX)
3fuser -cu /dev/vg01/lvol5     # also search with a filesystem or an LV
  • -c == -m ; -u also shows the process user.
  • to kill the processes: fuser -kcu.

File deleted but space still held

For detecting deleted-but-still-open files (lsof +L1) and freeing the held space, see the Disk Cleanup page.

Sunday, October 4, 2026 Sunday, August 27, 2023