命令行大全

fuser

瑞兹 发表于 2021-01-18 00:43浏览次数:

在类似Unix的操作系统上,fuser命令标识当前正在使用系统上文件或套接字的进程。

查看英文版

目录:

1 fuser 运行系统环境

2 fuser 描述

3 fuser 语法

4 fuser 例子

fuser 运行系统环境

Unix&Linux

fuser 描述

fuser使用指定的文件或文件系统显示进程的PID。

在默认的显示模式下,每个文件名后都有一个字母,表示访问类型:

C

当前目录。

Ë

可执行文件正在运行。

F

打开文件。在默认显示模式下省略f

F

打开文件进行写入。在默认显示模式下省略F。

r

根目录。

m

mmap文件或共享库。

如果没有访问任何指定的文件或发生致命错误,fuser将返回一个非零的返回码。如果发现至少一个访问,则定影器返回零。

要使用TCP和UDP套接字查找进程,必须使用-n选项选择相应的名称空间默认情况下,fuser将同时在IPv6和IPv4套接字中查找。若要更改默认行为,请使用-4-6选项。可以通过本地和远程端口以及远程地址来指定套接字。所有字段都是可选的,但必须在缺少的字段前加逗号:

[lcl_port] [,[rmt_host] [,[rmt_port]]]

符号或数字值均可用于IP地址和端口号。

fuser 仅将PID输出到stdout,其他所有内容都发送到stderr。


fuser displays the PIDs of processes using the specified files or file systems.

In the default display mode, each file name is followed by a letter denoting the type of access:

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.

fuser returns a non-zero return code if none of the specified files is accessed or in case of a fatal error. If at least one access has been found, fuser returns zero.

To look up processes using TCP and UDP sockets, the corresponding name space has to be selected with the -n option. By default, fuser will look in both IPv6 and IPv4 sockets. To change the default behavior, use the -4 and -6 options. The socket(s) can be specified by the local and remote port, and the remote address. All fields are optional, but commas in front of missing fields must be present:

[lcl_port][,[rmt_host][,[rmt_port]]]

Either symbolic or numeric values can be used for IP addresses and port numbers.

fuser outputs only the PIDs to stdout, everything else is sent to stderr.

查看英文版

查看中文版

fuser 语法

fuser [-fuv] [-a|-s] [-4|-6] [-c|-m|-n space] [ -k [-i] [-M] [-w]
      [-SIGNAL] ] name ...
fuser -l
fuser -V

选件

-a--all

显示在命令行上指定的所有文件。默认情况下,仅显示至少由一个进程访问的文件。

-C

-m选项相同,用于POSIX兼容性。

-F

静默忽略,用于POSIX兼容性。

-k,-- kill

终止访问文件的进程。除非有改变-信号SIGKILL发送。在定影过程中不会导致死亡本身,而是可能会杀死其他定影过程。在尝试终止之前,将执行定影器的进程的有效用户ID设置为其实际用户ID。

-i,-- interactive

在终止进程之前,请用户确认。如果-k也不存在,则忽略该选项。

-l,-- list-signals

列出所有已知的信号名称。

-m NAME,-- mount NAME

NAME在已安装的文件系统或已安装的块设备上指定文件。列出了访问该文件系统上文件的所有进程。如果指定了目录文件,它将自动更改为NAME /。使用可能安装在该目录上的任何文件系统。

-M,-- ismountpoint

仅当NAME指定安装点时,请求才会得到满足。如果NAME恰好不是文件系统,这是非常宝贵的安全带,可以防止您杀死计算机。

-w

仅杀死具有写访问权的进程。如果-k也不存在,则忽略该选项。

-n SPACE,-- namespace SPACE

选择其他名称空间。支持名称空间文件(文件名,默认名称),udp(本地UDP端口)和tcp(本地TCP端口)。对于端口,可以指定端口号或符号名。如果没有歧义,则可以使用快捷方式名称/空格(例如80 / tcp)。

-s,-- silent

静音操作。-u-v在此模式下被忽略。-a不能与-s一起使用。

--SIGNAL

终止进程时,请使用指定的信号而不是SIGKILL。可以通过名称(例如-HUP)或通过数字(例如-1)来指定信号。如果-k选项也不存在,则忽略该选项。

-u--user

将流程所有者的用户名追加到每个PID。

-v,-- verbose

详细模式。进程以类似ps的样式显示。PID,USER和COMMAND字段类似于ps。访问显示了进程如何访问文件。当访问特定文件作为挂载点,knfs导出或交换文件时,详细模式也会显示。在这种情况下,将显示内核而不是PID。

-V,-- version

显示版本信息。

-4,-- ipv4

仅搜索IPv4套接字。此选项不得与-6选项一起使用,仅对tcp和udp名称空间有效。

-6,-- ipv6

仅搜索IPv6套接字。此选项不得与-4选项一起使用,并且仅对tcp和udp名称空间有效。

--

重置所有选项,并将信号设置回SIGKILL

fuser [-fuv] [-a|-s] [-4|-6] [-c|-m|-n space] [ -k [-i] [-M] [-w]
      [-SIGNAL] ] name ...
fuser -l
fuser -V

Options

-a--all

Show all files specified on the command line. By default, only files that are accessed by at least one process are shown.

-c

Same as -m option, used for POSIX compatibility.

-f

Silently ignored, used for POSIX compatibility.

-k--kill

Kill processes accessing the file. Unless changed with -SIGNALSIGKILL is sent. An fuser process never kills itself, but may kill other fuser processes. The effective user ID of the process executing fuser is set to its real user ID before attempting to kill.

-i--interactive

Ask the user for confirmation before killing a process. This option is silently ignored if -k is not also present.

-l--list-signals

List all known signal names.

-m NAME--mount NAME

NAME specifies a file on a mounted file system or a block device that is mounted. All processes accessing files on that file system are listed. If a directory file is specified, it is automatically changed to NAME/. to use any file system that might be mounted on that directory.

-M--ismountpoint

Request will be fulfilled only if NAME specifies a mountpoint. This is an invaluable seatbelt which prevents you from killing the machine if NAME happens to not be a filesystem.

-w

Kill only processes which have write access. This option is silently ignored if -k is not also present.

-n SPACE--namespace SPACE

Select a different name space. The name spaces file (file names, the default), udp (local UDP ports), and tcp (local TCP ports) are supported. For ports, either the port number or the symbolic name can be specified. If there is no ambiguity, the shortcut notation name/space (e.g., 80/tcp) can be used.

-s--silent

Silent operation. -u and -v are ignored in this mode. -a must not be used with -s.

-SIGNAL

Use the specified signal instead of SIGKILL when killing processes. Signals can be specified either by name (e.g., -HUP) or by number (e.g., -1). This option is silently ignored if the -k option is not also present.

-u--user

Append the username of the process owner to each PID.

-v--verbose

Verbose mode. Processes are shown in a ps-like style. The fields PID, USER, and COMMAND are similar to ps. ACCESS shows how the process accesses the file. Verbose mode will also show when a particular file is being access as a mount point, knfs export or swap file. In this case kernel is shown instead of the PID.

-V--version

Display version information.

-4--ipv4

Search only for IPv4 sockets. This option must not be used with the -6 option and only has an effect with the tcp and udp namespaces.

-6--ipv6

Search only for IPv6 sockets. This option must not be used with the -4 option and only has an effect with the tcp and udp namespaces.

-

Reset all options and set the signal back to SIGKILL.

查看英文版

查看中文版

fuser 例子

fuser .

显示使用当前目录(“ ./ ”)的每个进程ID 。

fuser -v .

显示有关使用当前目录的每个进程的详细信息。此信息包括启动过程的用户的名称和过程名称的指示符。

fuser -v /

显示有关使用根目录的每个进程的详细信息。

fuser .

Display every process ID that is using the current directory ("./").

fuser -v .

Display verbose information about every process that is using the current directory. This information includes the name of the user who initiated the process and an indicator of the process name.

fuser -v /

Display verbose information about every process that is using the root directory.

查看英文版

查看中文版

发表评论
评论列表
共0条
点击加载更多