Connections
networksetup -listallhardwareports
List macOS network adapters and device names.
Explanation
This macOS command lists hardware ports and their device names, such as Wi-Fi using en0. It is useful before running interface-specific commands.
Syntax
networksetup -listallhardwareports
List hardware ports
Hardware Port: Wi-Fi Device: en0 Hardware Port: Ethernet Device: en4
Use the device name in commands like ifconfig or ipconfig.