Skip to content

Network

VBrazhnik edited this page Jun 27, 2018 · 8 revisions

01. Get the list of the network interfaces of the machine without displaying any detail for these interfaces. Only the list of names.

man ifconfig:

The ifconfig utility is used to assign an address to a network interface and/or configure network interface parameters.

The -l flag may be used to list all available interfaces on the system, with no other additional information. Use of this flag is mutually exclusive with all other flags and commands, except for -d (only list interfaces that are down) and -u (only list interfaces that are up).

Answer

ifconfig -l

02. Identify the IP address of the Ethernet interface

Two character prefixes based on the type of interface:

Prefix Type of interface
en ethernet
sl serial line IP (slip)
wl wlan
ww wwan

Answer

ifconfig en0 | grep 'inet ' | awk '{print $2}'

Explanation

ifconfig en0 displays information about en0 interface.

grep 'inet ' prints lines which contain 'inet '.

awk '{print $2}' prints only second column from the input field.

Clone this wiki locally