The fuser command is useful to determine which files are using system resources. One of the more common uses of this command is to determine which user is active in a filesystem, which prevents the system administrator from unmounting the filesystem:
[root@localhost ~]# umount /boot umount: /boot: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
[root@localhost ~]# fuser -v /boot USER PID ACCESS COMMAND /boot: root kernel mount /boot student 29306 ..c.. bash
fuser output will include following symbols:
c current directory. e executable being run. f open file. f is omitted in default display mode. F open file for writing. F is omitted in default display mode. r root directory. m mmap'ed file or shared library.
The following table describes common options for the fuser command:
Option | Description |
---|---|
-k or –kill | Kill the process that is using the filesystem or resource. |
-i or –interactive | Prompt before killing the process (you must also use the -k option). |
-v or –verbose | Verbose; produce additional useful information. |
fuser Command Examples
1. To get the process using root file system:
# fuser /
2. To show all files specified on the command line:
# fuser -a /
3. To kill the processes accessing the files:
# fuser -k /tmp
4. To ask the user before kill the process:
# fuser -ki /tmp
5. To list all the known signal:
# fuser -l
6. To list all processes of the mount point in which the given file is residing:
# fuser -m /tmp/file.txt
7. For silent operation:
# fuser -s /tmp
8. To specify the signal instead of SIGKILL:
# fuser -signal 15 /tmp
9. To get the user name of the process owner:
# fuser -u /tmp
10. To set the verbose mode:
# fuser -v
11. To display the version information:
# fuser -V
12. To search for only IPv4 sockets:
# fuser -4 /tmp
13. To search for only IPv6 sockets:
# fuser -6 /tmp
14. To reset the all the signal options:
# fuser -
Final Thoughts
fuser command identifies and outputs the process IDs of processes that are using the files or local filesystems. Each process ID is followed by a letter code: c if process is using file as the current directory; e if executable; f if an open file; F if open file for writing; m if a shared library; and r if the root directory. Any user with permission to read /dev/kmem and /dev/mem can use fuser, but only a privileged user can terminate another user’s process. fuser does not work on remote (NFS) files.