参考:https://stackoverflow.com/questions/49381124/what-are-the-differences-between-lsof-and-netstat-on-linux
https://www.cnblogs.com/pc-boke/articles/10012112.html
- LSOF: List of Open Files. It lists all the open files belonging to all active processes.
- NETSTAT: It is a tool to get the network statistics. By default, netstat displays a list of open sockets. If you don’t specify any address families, then the active sockets of all configured address families will be printed.
- examples:
sudo lsof -n -i
sudo lsof -n -i4
sudo lsof -n -i :80
netstat -r
netstat -plunt
- 1.netstat无权限控制,lsof有权限控制,只能看到本用户
2.losf能看到pid和用户,可以找到哪个进程占用了这个端口