Fuser command summary, fuser Summary

Source: Internet
Author: User

Fuser command summary, fuser Summary
Prerequisites

In linux, when you use the umount command to detach a mount point, a message "device is busy" is displayed. Then, fuser can find out who is using this resource; of course, umount-lf [mount point] can also be forcibly detached

Function

Fuser can display which program is using a file, mount point, or network port on the disk, and provide detailed information about the program process.

Fuser outputs only the PID to the standard output, and all others to the standard error output.

Common options

-A displays all files specified in the command line. By default, the files accessed are displayed.
-C, like-m, is used for POSIX compatibility.
-K: Kill the process that accesses the file. If-signal is not specified, a SIGKILL signal is sent. Combined-signal

-Signal uses the specified signal instead of SIGKILL to kill the process. The signal can be expressed by name or number (such as-HUP and-1). This option must be used with-k. Otherwise, it will be ignored.

-L list all known signal names.
-I asked the user before killing the process. If the-k option is not available, it will be ignored.
-M name: Specifies the file or block device (name) mounted to the file system ). In this way, all processes accessing this file or file system will be listed. If a directory is specified, it is automatically converted to "name/" and all the file systems mounted under that directory are used.
-N space specifies a different namespace. Different space files (file names, default), tcp (local tcp port), and udp (local udp port) are supported here ). For a port, you can specify the port number or name. If there is no ambiguity, you can use a simple representation, for example, name/space (such as 80/tcp ).
-S silent mode. At this time,-u and-v will be ignored. -A cannot be used with-s.
-U adds the User Name of the process owner after each PID.
-V verbose mode. Output is like the output of ps commands, including PID, USER, COMMAND, and many other fields. If it is accessed by the kernel, the PID is kernel.

 

Case

Assume that the device cannot be detached is/dev/sdb1.
1) run the following command to check which user and process occupy the device.
Fuser-m-v/dev/sdb1

2) run the following command to kill the process that occupies the device.
Fuser-m-v-k/dev/sdb1
Or fuser-m-v-k-I/dev/sdb1 (each time you kill the process, you will be asked to confirm)
3) umount again

 

Check the tcp port 80 used by those programs:
$ Fuser-n tcp 80
Or $ fuser-v-n tcp 80
Or $ fuser-v 80/tcp
Here, the information displayed in the last two methods is comprehensive, because the-v option is available.

# Fuser-v 111/udp 111/tcp user Process Code permission command 111/udp: rpc 968 F... rpcbind111/tcp: rpc 968 F... rpcbind

In the above example, the permissions for column 4th are alsoAccess type, As follows:

C Indicates the file opened by directory F for write operations. Not Displayed by default.

E. executable m ing files or shared libraries.

F. Not Displayed by default. R root directory.

Other identical commands:

# netstat -lntup|grep 111tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      968/rpcbind         tcp        0      0 :::111                      :::*                        LISTEN      968/rpcbind         udp        0      0 0.0.0.0:111                 0.0.0.0:*                               968/rpcbind         udp        0      0 :::111                      :::*                                    968/rpcbind
# ss  -lntup|grep 111       udp    UNCONN     0      0                      *:111                   *:*      users:(("rpcbind",968,6))udp    UNCONN     0      0                     :::111                  :::*      users:(("rpcbind",968,9))tcp    LISTEN     0      128                   :::111                  :::*      users:(("rpcbind",968,11))tcp    LISTEN     0      128                    *:111                   *:*      users:(("rpcbind",968,8))
# lsof -i :111COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAMErpcbind 968  rpc    6u  IPv4  11275      0t0  UDP *:sunrpc rpcbind 968  rpc    8u  IPv4  11278      0t0  TCP *:sunrpc (LISTEN)rpcbind 968  rpc    9u  IPv6  11280      0t0  UDP *:sunrpc rpcbind 968  rpc   11u  IPv6  11283      0t0  TCP *:sunrpc (LISTEN)

 

Signal list
# fuser -lHUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERMSTKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYSUNUSED# kill -l 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR111) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+338) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+843) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+1348) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-1253) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-758) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-263) SIGRTMAX-1  64) SIGRTMAX
Detailed use of the command man 7 signal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.