fuser

Format:

fuser options file 

Options:

-k kill all processes on file or file system
-u show all processes on file or file system

The fuser command is used to show processes that are running on a file system or files that are being accessed. Some systems use -u and -m interchangeably. You can use the if command statement with the fuser command.

To list processes active on the device /dev/hda5:

					$ fuser -m /dev/hda5 
/dev/hda5: 1 1r 1c 1e 37 37r 37c 37e 144 
   144r 144c 144e 158 158r 158c 158e 167r 167c 
167e 178 17 8r 178c 178e 189 189r 189c
				

To kill all processes on the device /dev/hda5:

					$ fuser -k /dev/hda5
				

To see if the file doc_part is open and what processes are running on it:

					r$ fuser -m /root/doc_part /root/dt: 1 1r 1c 1e 37 37r 37c ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.