How to use the Fuser tool to query the user of a file on Linux

Source: Internet
Author: User
Tags socket root directory

In Linux, the Fuser tool can be used to query the user of the file, in addition, Fuser has many uses, can be used with parameters, the following small series will be for the use of fuser tools to give you a detailed introduction, I hope to help you.

Lsof also has a similar function, it can also find the process that is accessing the specified file, the difference is fuser it can kill the process that is accessing the specified file at once.

The fuser commonly used occasions are:

Fuser can be used to query files, directories, socket ports, and file system usage processes, and you can use Fuser to shut down processes.

When the file system umount device busy, it is commonly used to fuser queries and to close processes that use the appropriate file system. (In the DRBD switch time can use to OH);

How to use:

Basically, you can display most of the content with-V:

The user under the/root directory, the process id,pid The following C represents the working directory of the process, followed by a specific command;

Access also has other options:

E: The file is the executable file for the process;

F: The file is open by the process and the default f is not displayed;

F: The file is opened by the process and written, the default f is not displayed;

R: Represents the directory as the root directory of the process;

M: Indicates that the process uses the file for memory mapping, or that the file is a shared library file, mapped to memory by the process;

To inquire about the user of the socket port:

To view the usage of a file system:

Kill the process that is being accessed by a file:

Fuser is the process of sending sigkill signals to related processes. In addition to sending Sigkill signals, Fuser can send the following signal:

FUSER-V-k filename;

To end all processes that access a file system:

Fuser-ck/data (directory on which a file system is mounted);

Above is the Linux using the Fuser tool Introduction, Fuser Plus-V can display process content, can query socket port users, but also query file system usage.

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.