Sunday, 17 December 2017

macos - Linux-like top/netstat/etc. on Mac OS X?


Unix utilities on Mac OS X are quite painful to use. port install coreutils +with_default_names and a few other such replacements fix most of them, but it leaves some in broken Mac OS X defaults - most annoyingly top and netstat, but I'm sure I could think of a few more.


I'm guessing that commands like top and netstat are quite OS specific, so just grabbing sources of their Linux equivalents and recompiling won't work.


What's the best equivalent of these and other such commands that works on Mac OS X?



Answer



Many netstat features can be replaced with a lsof command. I was often using


netstat -lnp | grep 1234

to find out who was listening on port 1234. With lsof (that is available on both systems), I can do:


lsof -i :1234

The top command on OSX is not bad either, it's just different. And I'm quite sure some of the metrics only make sense on Mac.


Note that lsof -Pi :1234 should make it a bit faster by not trying to resolve the service names (of the ports).


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...