Fuser (Unix)

fuser
Operating systemUnix and Unix-like
PlatformCross-platform
TypeCommand

The Unix command fuser is used to show which processes are using a specified computer file, file system, or Unix socket.

Example

For example, to check process IDs and users accessing a USB drive:

$ fuser -m -u /mnt/usb1
/mnt/usb1:   1347c(root)  1348c(guido)  1349c(guido)

The command displays the process identifiers (PIDs) of processes using the specified files or file systems. In the default display mode, each PID is followed by a letter denoting the type of access:

c
current directory.
e
executable being run.
f
open file.
F
open file for writing.
r
root directory.
m
mmap'ed file or shared library

Only the PIDs are written to standard output. Additional information is written to standard error. This makes it easier to process the output with computer programs.

The command can also be used to check what processes are using a network port:

$ fuser -v -n tcp 80
                     USER        PID ACCESS COMMAND
80/tcp:              root       3067 F.... (root)httpd
                     apache     3096 F.... (apache)httpd
                     apache     3097 F.... (apache)httpd

The command returns a non-zero code if none of the files are accessed or in case of a fatal error. If at least one access has succeeded, fuser returns zero. The output of "fuser" may be useful in diagnosing "resource busy" messages arising when attempting to unmount filesystems.

Options

POSIX defines the following options:[1]

-c
Treat the file as a mount point.
-f
Only report processes accessing the named files.
-u
Append user names in parentheses to each PID.

psmisc adds the following options, among others:[2]

-k, --kill
Kill all processes accessing a file by sending a SIGKILL. Use e.g. -HUP or -1 to send a different signal.
-l, --list-signals
List all supported signal names.
-i, --interactive
Prompt before killing a process.
-v, --verbose
verbose mode
-a, --all
Display all files. Without this option, only files accessed by at least one process are shown.
-m, --mount
Same as -c. Treat all following path names as files on a mounted file system or block device. All processes accessing files on that file system are listed.
  • The list of all open files and the processes that have them open can be obtained through the lsof command.
  • The equivalent command on BSD operating systems is fstat(1).

References

  1. ^ fuser – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group. Retrieved December 4, 2020.
  2. ^ "fuser.1" (troff with man macros). GitLab. September 9, 2020. Archived from the original on April 7, 2022. Retrieved December 4, 2020.

fuser – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group


Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.