≡ Menu

How To: Restart Apple Mac OS X Airport Networking From the Bash Terminal

How do I enable and/or disable networking (AirPort) Ethernet and Wireless from the bash command Line in Apple Mac OS X? How can I restart Wi-Fi via command Line in OS X?

You can use ifconfig command to to assign an address to a network interface and/or configure network interface parameters including restarting interface.

Procedure: How to restart Wifi (en0) using the terminal

  1. Open the terminal.
  2. Type the following command to shutdown en0 interface:
    sudo ifconfig en0 down
  3. Type the following command to bring it back en0 interface:
    sudo ifconfig en0 up
  4. Verify that interface is back online again:
    ifconfig -u en0

Sample session:

Fig.01: Enable and Disable OSX Wi-Fi

Fig.01: Enable and Disable OSX Wi-Fi

You can create an alias as follows in your ~/.bashrc file:

alias restart_en0='sudo ifconfig en0 down && sudo ifconfig en0 up'

To restart simply type:


Say hello to networksetup command

The networksetup is a configuration tool for network settings in OS X.

Use networksetup restart (on and off) Mac OS X networking

Type the following command to turn it off en0:
networksetup -setairportpower en0 off
networksetup -setairportpower "Wi-Fi" off
Type the following command to turn it on en0:
networksetup -setairportpower en0 on
networksetup -setairportpower "Wi-Fi" on
Sample outputs:

Wi-Fi is not a Wi-Fi interface.
Turning on the only airport interface found: en0

Both commands have many more options. See the man page by typing the following command:
man ifconfig
man networksetup

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 0 comments… add one }

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: