• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

fuser Command Examples in Linux

by admin

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.

Filed Under: Linux

Some more articles you might also be interested in …

  1. nc: command not found
  2. bat Command Examples in Linux
  3. CentOS / RHEL : How to prevent disabled repositories from being downloaded into the yum cache
  4. Nohup Command Examples – Runs a Command that Keeps Running after You Log Out
  5. How to use strace and ltrace commands in Linux
  6. foreman Command Examples in Linux
  7. CentOS / RHEL : How to disable ssh for non-root users (allowing ssh only for root user)
  8. cryptsetup: command not found
  9. LVM error “WARNING: Inconsistent metadata found” – How to resolve in CentOS / RHEL
  10. ps Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright