MacOS – How to launch system’s “Network diagnostics” from the command line

command linemacosNetwork

I would like to launch "Network diagnostics" from the command line.

Best Answer

To open a standard macOS application bundle, e.g. Network Diagnostics.app, via the command line, in e.g. Terminal, you can use the open command with the -a option, e.g.:

open -a Network\ Diagnostics

Note that you do not necessarily need to use the .app extension or its pathname, /System/Library/CoreServices/Network Diagnostics.app, although you can if you so choose or the situation warrants it.

Note: In the use case there is no need or advantage to using the fully qualified pathname of the binary executable:

/System/Library/CoreServices/Network\ Diagnostics.app/Contents/MacOS/Network\ Diagnostics

Aside from the fact it's not necessary because the open -a command is there for that, using just the fully qualified pathname of the binary executable from the command line forces Terminal to stay open and that window is unusable until finished and Terminal cannot be closed without also terminating the binary executable of Network Diagnostics in the case.

Also note that even using an & after the fully qualified pathname, while it will return the command prompt, Terminal still cannot be closed without also terminating e.g. Network Diagnostics.

This is why using the open command with the -a option is the way to go when wanting to open a standard macOS application bundle from the command line.