On Linux, I can use netstat -pntl | grep $PORT
or fuser -n tcp $PORT
to find out which process (PID) is listening on the specified TCP port. How do I get the same information on Mac OS X?
相关问题
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Advice for supporting both Mac and Windows Desktop
- Avoid cmake to add the flags -search_paths_first a
- installing packages for python 3
相关文章
- 现在使用swift开发ios应用好还是swift?
- Socket编程 TCP方式发送时间有点长
- Visual Studio Code, MAC OS X, OmniSharp server is
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- ImportError: No module named twisted.persisted.sty
- How can I vertically align my status bar item text
On Snow Leopard (OS X 10.6.8), running 'man lsof' yields:
(actual manual entry is 'lsof -i 4 -a -p 1234')
The previous answers didn't work on Snow Leopard, but I was trying to use 'netstat -nlp' until I saw the use of 'lsof' in the answer by pts.
On the latest macOS version you can use this command:
If you find it hard to remember then maybe you should create a
bash
function and export it with a friendlier name like soand then add the following lines to that file and save it.
Now you can type
listening_on 80
in your Terminal and see which process is listening on port80
.You can also use:
This works in Mavericks.
For the LISTEN, ESTABLISHED and CLOSED ports
For the LISTEN ports only
For a specific LISTEN port, ex: port 80
Or if you just want a compact summary [no service/apps described]
Explaining the items used:
-n suppress the host name
-i for IPv4 and IPv6 protocols
-P omit port names
-a [over netstat] for all sockets
-n [over netstat] don't resolve names