Tuesday, September 6, 2016

fuser

Identifying Processes Using Files 

fuser

In addition to listing open files, you may also need to identify processes running on your Linux system that are using a particular file in the file system. The fuser command displays the PIDs of processes using the specified files or file systems. By default, each filename is followed by a letter indicating the following:

c  Current directory
e   Executable being run
f   An open file
F   A file that is open for writing
r  The root directory
m    Memory mapped file or shared library


Options you can use with this command include the following:

–a Show all files specified. By default, only files that are accessed by at least one process are shown.

–k   Kill processes accessing the file

–i   Ask the user for confirmation before killing a process.

–u   Append the user name of the process owner to each process ID number (PID).

In the following example, you can see that the tux user is running the /usr/bin/top executable and that the process using the file has a PID of 9823:


openSUSE:/sbin # fuser -u /usr/bin/top
/usr/bin/top:         9823e(tux)

fuser -k ~/MyFile.txt

fuser -k -i ~/MyFile.txt

fuser -a /etc/*.conf


No comments:

Post a Comment