CentOS: view the process of the file or file in which the process is "opened ".

Source: Internet
Author: User
1. view the process & ldquo; open the file & rdquo;: 1) pidofprograme-name (obtain the PID of the process (programe-name) you want to know) or ps-aux | grepprograme-name (obtain the PID of the process (programe-name) you want to know) to find the PID2 of the process) cd/proc/$ PID/fd (the file descriptor will be seen) 3) ls-l to get

1. view the files opened by the process:
1) pidof programe-name (obtain the PID of the process (programe-name) you want to know)
Or ps-aux | grep programe-name (obtain the PID of the process (programe-name) you want to know)
Find the PID of the process
2) cd/proc/$ PID/fd (the file descriptor is displayed)
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) obtain the PID method of the process you want to know.
2) lsof-c programe-name
Or lsof-p $ PID

3. view the process corresponding to the file:
Lsof file-name

4. lsof command usage:
Lsof-c abc displays the files currently opened by the abc process
Lsof abc displays the process for enabling file abc
Lsof-I: 22 shows what programs are running on port 22
Lsof-g gid: displays the processes that belong to the gid.
Lsof + d/usr/local/Display files opened by processes in the directory
Lsof + D/usr/local /.
Lsof-d 4 displays processes with fd 4
Lsof-I is used to display qualified processes
Lsof-s lists the size of open files. if there is no size, leave blank
Lsof-u username uses UID to list open files

5. view the network status:
Lsof-Pnl + M-i4 displays ipv4 service and listener status
Netstat-anp all listening ports and corresponding processes
Netstat-tlnp functions are the same as above

Related Article

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.