Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux-fuser command

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

[root@localhost test ~] $fuser

No process specification given

Usage: fuser [- a |-s |-c] [- n SPACE] [- SIGNAL] [- kimuv] NAME...

[-] [- n SPACE] [- SIGNAL] [- kimuv] NAME...

Fuser-l

Fuser-V

Show which processes use the named files, sockets, or filesystems.

-a display unused files too

-c mounted FS

-f silently ignored (for POSIX compatibility)

-i ask before killing (ignored without-k)

-k kill processes accessing the named file

-l list available signal names

-m show all processes using the named filesystems

-n SPACE search in this name space (file, udp, or tcp)

-s silent operation

-SIGNAL send this signal instead of SIGKILL

-u display user IDs

-v verbose output

-V display version information

-4 search IPv4 sockets only

-6 search IPv6 sockets only

-reset options

Udp/tcp names: [local_port] [, [rmt_host] [, [rmt_port]

[oracle@acctdb01 ~] $

The fuser command is used to report the files and network sockets used by the process. The fuser command lists the process number of the local process, which uses file, and the local or remote file specified by the parameter. For blocking a special device, this command lists the processes that use any file on that device.

Fuser:identify processes using files or sockets: you can show which program is currently using a file, mount point, or even a network port on disk, and give details of the program process

Common parameters and instructions: please refer to the man fuser page for more details.

-u: list the owner of the process in addition to the PID of the process

-v: list more information

-m: the file name that follows will actively mention the top level of the file system, which is very helpful to the failure of umount

Example:

1. Query the processes in the current directory

[root@localhost test] # fuser-uv.

USER PID ACCESS COMMAND

.: root 3784.. c.. (root) bash

Root 3815.. c.. (root) bash

Root 9998.. c.. (root) bash

Root 28673.. c.. (root) vi

ACCES column description:

C: this program is in the current directory

E: executable at run time

F: open the file, ignored by default

F: open a file waiting to be written, like f, ignored by default

R:root directory, root directory

M: may be a shared library

two。 Query the process information of the file in use

[root@rhel6164 ~] # fuser-uv file name

[clef@rhel6164 ~] $fuser-uv / home/clef/log.txt # cannot view the process in use with log.txt

[clef@rhel6164 ~] $fuser-uv / home/clef/.log.txt.swp # you can view the process in use with .log.txt.swp

USER PID ACCESS COMMAND

/ home/clef/.log.txt.swp:

Clef 32744 F.... (clef) vim

To list the process number of the local process that uses the / etc/passwd file, enter:

Fuser / etc/passwd

To list the process number and user login name of the process that uses the / etc/filesystems file, enter:

Fuser-u / etc/filesystems

-to terminate all processes that use a given file system, enter:

Fuser-k-x-u-c / dev/hd1 or fuser-kxuc / home

To list all processes that are using files that have been deleted from a given file system, enter:

Fuser-d / usr file

3. When umount is not successful, use fuser to query the processes of the occupied file system

[root@localhost test] # df-h / mnt/linux_share/ # / mnt/linux_share is the file system of mount

Filesystem Size Used Avail Use% Mounted on

Xx.xx.xx.xx:linux_share

299G 156G 144G 52% / mnt/linux_share

[root@localhost test] # umount / mnt/linux_share/ # indicates that the device is busy when umount

Umount: / mnt/linux_share: device is busy

Umount: / mnt/linux_share: device is busy

[root@localhost test] # fuser-muv / mnt/linux_share/ # View the processes that are occupying the file system through fuser

USER PID ACCESS COMMAND

/ mnt/linux_share/: root 3815.. c.. (root) bash

-- run the following command to kill the processes that occupy this device

Fuser-m-v-k/mnt/linux_share/

Or fuser-m-v-k-I / mnt/linux_share/ (each time you kill the process will make you confirm)

4. See which programs use port 80 of tcp:

$fuser-n tcp 80

Or $fuser-v-n tcp 80

Or $fuser-v 80/tcp

Here, the last two ways display more complete information, because of the-v option

# fuser-v 111/udp 111/tcp

User process number permission command

111/udp: rpc 968 F.... Rpcbind

111/tcp: rpc 968 F.... Rpcbind

As in the example above, the permissions in column 4 are also of access type, as follows:

C represents the file opened by the current directory F for write operations. It is not displayed by default.

E executable run m mapping file or shared library.

F open file. It is not displayed by default. R root directory.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report