lsof search process connections

reference:

https://www.cnblogs.com/bonelee/p/7735479.html

 

# View the number of open files

lsof |wc -l

# View the number of files a process opens

lsof -p 19764|wc -l

lsof -p 19764|more

 

1. List all open files:
lsof
2. Check who is using a file
lsof / filepath / File
5. lists a user opens the file information
lsof -u username
6. a program list open files information
the lsof -C MySQL
8. the lists a user and a program information file open
the lsof -u -C MySQL Test
13 is a list of all network connections.
the lsof -i
14. a list of all tcp network connection information
lsof - tcp i
15. the list all udp network connection information
lsof -i udp
16. the list who is using a port
lsof -i: 3306

 

# View Connections:
the netstat -n | grep the TIME | awk '{}. 5 Print $' | Cut -d: -f1 | Sort | the uniq -C | Sort -n

First, connect the unit to see which IP
netstat -an

Second, check the TCP connection number
1) 80 Number of port statistics
netstat -nat | grep -i "80" | WC the -l
2) Statistics httpd process several
PS -ef | grep httpd | WC the -l
3), connected on statistics the status is "ESTABLISHED
the netstat -Na | grep the ESTABLISHED | -l WC
which connect up the IP address isolated
netstat -na | grep ESTABLISHED | awk ' {print $ 5}' | awk -F: '{print $ 1}' | sort | uniq -c | sort -r

The sealed up.
The netstat -Na | grep the SYN | awk. 5} {Print $ | awk -F: {}. 1 Print $ | Sort | the uniq -C | -R & lt Sort 0n +

 4) Check the connection of a number of ip

netstat antigen | grip 161.50 | wc -l

 

# View the process open file limit, first obtain the pid

cat /proc/2283/limits
Limit Soft Limit Hard Limit Units 
Max cpu time unlimited unlimited seconds 
Max file size unlimited unlimited bytes 
Max data size unlimited unlimited bytes 
Max stack size 10485760 unlimited bytes 
Max core file size unlimited unlimited bytes 
Max resident set unlimited unlimited bytes 
Max processes 63316 63316 processes 
Max open files 1000000 1000000 files 
Max locked memory 65536 65536 bytes 
Max address space unlimited unlimited bytes 
Max file locks unlimited unlimited locks 
Max pending signals 63316 63316 signals 
Max msgqueue size 819200 819200 bytes 
Max nice priority 0 0 
Max realtime priority 0 0 
Max realtime timeout unlimited unlimited us

Guess you like

Origin www.cnblogs.com/hongfeng2019/p/12168904.html