I would like to find out which of the available network services (e.g. Ethernet or Wi-Fi) is currently active. In this screenshot from the Network Preferences, you can see that Wi-Fi is currently active (the green dot):
How can I get that information from the command line?
networksetup command allows me to list the available network services:
$ networksetup -listallnetworkservices An asterisk (*) denotes that a network service is disabled. Ethernet FireWire Wi-Fi
It can also show some details on the service, like the device name:
$ networksetup -listnetworkserviceorder An asterisk (*) denotes that a network service is disabled. (1) Ethernet (Hardware Port: Ethernet, Device: en0) (2) FireWire (Hardware Port: FireWire, Device: fw0) (3) Wi-Fi (Hardware Port: Wi-Fi, Device: en1)
Unfortunately, the info on which service is active (the green dot from the screenshot) is not available in this info. Is there another command that I could use to get this information?