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

What does the lsof command refer to in linux

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

Share

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

This article will explain in detail what the lsof command in linux refers to. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Lsof (list open files) is a tool that lists files currently open by the system. In the linux environment, everything exists in the form of files, through which you can access not only regular data, but also network connections and hardware.

Therefore, lsof is very powerful. The average root user can execute the lsof command, and the ordinary user can see the / usr/sbin/lsof command, but the average user execution will display "permission denied". So being able to view this list through the lsof tool will be very helpful for system monitoring and troubleshooting.

Enter lsof under the terminal to display the files opened by the system. Because lsof needs to access core memory and various files, it must be run as a root user in order to give full play to its functions.

Each line displays one open file, and if you do not specify conditions, all files opened by all processes will be displayed by default. The significance of lsof's output of each column of information is as follows:

COMMAND: the name of the process

PID: process identifier

USER: process owner

FD: a file descriptor that the application recognizes by the file descriptor. Such as cwd, txt, etc.

TYPE: file type, such as DIR, REG, etc.

DEVICE: specifies the name of the disk

SIZE: the size of the file

NODE: Inode (identification of files on disk)

NAME: the exact name of the open file

The use of the lsof instruction is as follows:

Lsof abc.txt displays the process of opening the file abc.txt lsof directory name to find out who is using the file directory system

Lsof-I: 22 know which process port 22 is occupied by

Lsof-c abc displays the files now opened by the abc process

Lsof-g gid shows the process that belongs to the gid

Lsof-n does not convert IP to hostname. By default, the-n parameter is not added.

Lsof-p 12 to see which files are opened by the process with process number 12

Lsof-u username to see which files the user opens

Lsof-I @ 192.168.1.111 View remote open network connections (connect to 192.168.1.111)

So much for sharing what the lsof command refers to in linux. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

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