Restart Mac OS X networking (AirPort) from the Mac command line

It looks like there may be a couple of ways to restart Mac networking -- AirPort to be specific -- from the Mac command line. The first is the old-school approach of using the ifconfig command. This command shuts down the en0 or en1 interface, which is typically the AirPort wireless interface. On my MacBook Air it's en0, so I'll show that here:

sudo ifconfig en0 down

You bring it back up/online in the same way:

sudo ifconfig en0 up

Using the networksetup command

I saw a different approach on this web page. You turn off the power with this command:

networksetup -setairportpower airport off

You turn the power back on with this command:

networksetup -setairportpower airport on

This command does not work on my MacBook Air as shown; it yields this error:

$ networksetup -setairportpower airport off
airport is not a Wi-Fi interface.
Turning off the only airport interface found: en0

However, by replacing airport with en0, this command works just like this previous command:

networksetup -setairportpower en0 off

Both commands turn off the wi-fi icon in the Mac menu bar when you issue the down/off commands, and turn the icon back on when you issue the up/on commands. I'll stick with the first command for now, since I've used ifconfig for something like ... wow ... 20 years now.

Showing your network interfaces

If you need to see the network interfaces on your Mac OS X system, use this command:

ifconfig -a

It will show output like this:

$ ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	inet netmask 0xff000000 
	inet6 ::1 prefixlen 128 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
	ether 44:2a:60:f7:72:82 
	inet6 fe80::462a:60ff:fef7:7282%en0 prefixlen 64 scopeid 0x4 
	inet netmask 0xffffff00 broadcast
	media: autoselect
	status: active
	ether 06:2a:60:f7:72:82 
	media: autoselect
	status: inactive

When I first tried en1 and it didn't work, I used this command to find out that my MacBook Air only has the en0 interface. At the moment I only know that the lo0 interface is the "loopback" interface. I don't know what the others are