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

How does CentOS view files opened by processes or processes corresponding to files

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "CentOS how to view the files opened by the process or the corresponding process". In daily operation, I believe that many people have doubts about how to view the files opened by the process or the corresponding process in CentOS. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for everyone to answer the question of "how to view the files opened by the process or the corresponding process of files opened by CentOS". Next, please follow the editor to study!

1. View the files "opened" by the process:

1) pidof programe-name (get the PID of the process (programe-name) you want to know)

Or ps-aux | grep programe-name (get the PID of the process (programe-name) you want to know)

Find out the PID of the process

2) cd / proc/$PID/fd (you will see the file descriptor)

3) ls-l

Get the actual file pointed to by the file descriptor, that is, the file opened by the current process

2. View the file "opened" by the process 2:

1) the PID method of getting the process you want to know is the same as above.

2) lsof-c programe-name

Or lsof-p $PID

3. View the process corresponding to the file:

Lsof file-name

4. Usage of lsof command:

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

Lsof abc shows the process of opening the file abc

Lsof-I: 22 shows what programs port 22 is running now.

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

Lsof + d / usr/local/ displays the files opened by the process in the directory

Lsof + D / usr/local/ is the same as above, but will search the directory under the directory for a long time.

Lsof-d 4 shows processes using fd 4

Lsof-I is used to display eligible processes.

Lsof-s lists the size of the open file, leaving it blank if there is no size

Lsof-u username lists open files in UID

5. Check the network status:

Lsof-Pnl + M-i4 displays ipv4 services and listeners

Netstat-anp all listening ports and corresponding processes

Netstat-tlnp function is the same as above

At this point, the study on "how CentOS views the files opened by the process or the corresponding process" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 244

*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