"Linux" common commands lsof viewing open files

Source: Internet
Author: User
Tags parent directory

The Linux system abstracts the hardware and software into files, so the files can be traced to a lot of important information, such as the read configuration file, open port and so on.

The following are common uses:

The default test file is named Text.txt

1, shows the process of opening text.txt:

Lsof Text.txt

2, shows the process that occupies a port:

Lsof-i: 80

3, displays a process (process name) Open file:

Lsof-c Process_name

4, display a process number (PID) Open file:

Lsof-p Pid_number

5, displays a file opened by a user:

Lsof-u user_name

The default output field is interpreted as:

[Groot] $lsof-U Groot
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME

COMMAND: Process name (only the first 9 characters are taken by default);

pid:process identification number;

User:the user ID number or login name of the user to whom the process belongs;

Fd:file Descriptor number or

CWD Current working directory;

LTX Shared library text (code and data);

Mem memory-mapped file;

Mmap memory-mapped device;

PD parent Directory;

RTD root directory;

TXT program text (Code and data);

Type:is the type of the node associated with the file-e.g, Gdir, GREG, VDIR, VREG, etc.

"Linux" common commands lsof viewing open files

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.