See also command lines it is tedious to remember for general unix/macOS/BSD commands.
Which process is bound to
lsof -nP -i4TCP:$PORT | grep LISTEN # macOS High Sierra or later lsof -nP -iTCP:$PORT | grep LISTEN # other macos
For linux one could try this one.
netstat -pntl | grep $PORT # or fuser -n tcp $PORT
Stream to web
Seashells lets you pipe output from command-line programs to the web in real-time, even without installing any new software on your machine. You can use it to monitor long-running processes like experiments that print progress to the console. You can also use Seashells to share output with friends!
Finding bandwidth hogs
This is related to firewalls, which often monitor the traffic as well as purely directing it.
On macOS LittleSnitch, is once again the winner, by collecting statistics on various programs and how much internet they suck down.
On Linux, it’s less shiny but still feasible.
watch -n1 sudo ss -ntp
See also pyroute
which is some kind of
ss clone in, presumably, python.
Things like ntop will give you an overview of which ports and servers and suchlike are consuming your bandwidth, i.e. at the protocol level. The presentation can be friendly, even. I couldn’t work out how to make it tell me which processes were making the connections but maybe the problem is me.
nethogs, will tell you which processes are using data right now, but it won’t give you lovely graphs of data-versus-time etc. There are various GUIs, e.g. hogwatch (for web tech), gnethogs, nethogs-qt.
Fresh off the rank, bandwhich
bandwhich sniffs a given network interface and records IP packet size, cross referencing it with the
/procfilesystem on linux or
lsofon MacOS. It is responsive to the terminal window size, displaying less info if there is no room for it. It will also attempt to resolve ips to their host name in the background using reverse DNS on a best effort basis.
e.g. Not consuming all your bandwidth when you do that tether thing with your phone.
This is closely related to application firewalls, which manage traffic per process, but that is a lot more general, and also doesn’t usually include neat things like throttling.
The luxurious solution is to use the intuitive GUI to create rules in Little Snitch, which is nominally privacy software, but is in fact more generally useful. Worth the money. Go into Little Snitch and create a “profile” called “low bandwidth” which prevents e.g. your Droppantsbox or Ogle Drive or P3wncloud or other file syncing software from accessing the internet when you are in a “low bandwidth” situation. Remembering to switch, now…
Also possibly useful for might be lulu, a macOS firewall.
macOS with bad internet
You don’t live in San Francisco? Do you live somewhere with corrupt infrastructure politics, (e.g Australia,) and hence awful internet. Don’t worry, these and other deficiencies of the differently bandwidthed are no longer debilitating in modern society.
Switch your wifi off an on again, detailed version.
Turn off wifi on your macbook from the Mac macOS terminal command line:
networksetup -setairportpower en0 off
Turn on wifi on your macbook from the Mac macOS terminal command line:
networksetup -setairportpower en0 on
I’m just kidding, you’re still doomed; The hanging network connections of Indonesian broadband will still bring your OS down eventually. Apply for a Californian visa, even a temporary one, just until the singularity arrives and you ascend into digital heaven, drinking kombucha with George Lucas in the back of his convertible, and livestream the whole thing on youtube without pausing to buffer.
Apparently the bandwidth is also good in South Korea, but you’ll probably need a different ride.
If you are a developer, try to develop using traffic throttling to test your users’ experiences.