Stop/Start Wi-Fi from Mac Terminal
Controlling your Mac’s Wi-Fi connection from the Terminal can be useful for troubleshooting, automating network management, or working remotely. The networksetup
command-line tool in macOS allows you to easily enable or disable your Wi-Fi connection directly from the Terminal.
In this guide, we will show you how to stop (turn off) and start (turn on) Wi-Fi on your Mac using networksetup
.
How to Find Your Wi-Fi Interface Name
Before turning Wi-Fi on or off, you need to know the name of your Wi-Fi interface. On most Macs, the Wi-Fi interface is called Wi-Fi
or en0
. You can confirm this by running the following command in the Terminal:
networksetup -listallhardwareports
This command will list all of your Mac’s network interfaces. Look for the section labeled Wi-Fi
, and note the interface name (it will likely be Wi-Fi
or en0
). For example:

Once you’ve identified your Wi-Fi interface name, you can proceed with turning Wi-Fi on or off.
How to Stop (Turn Off) Wi-Fi
To stop or disable Wi-Fi from the Terminal, use the following command, replacing Wi-Fi
with your interface name if necessary:
networksetup -setairportpower Wi-Fi off
This command will immediately turn off the Wi-Fi on your Mac. You won’t be connected to any networks until you turn the Wi-Fi back on.

How to Start (Turn On) Wi-Fi
To start or enable Wi-Fi from the Terminal, use the following command:
networksetup -setairportpower Wi-Fi on
This will turn the Wi-Fi back on, and your Mac will automatically attempt to connect to known networks.

Checking Wi-Fi Status
If you want to check the current status of your Wi-Fi (whether it is on or off), you can use the following command:
networksetup -getairportpower en1
The output will indicate whether Wi-Fi is currently on or off. For example:

Automating Wi-Fi Control with Scripts
You can automate turning Wi-Fi on or off by creating a simple shell script. For example, create a script called wifi-toggle.sh
that toggles the Wi-Fi state:
#!/bin/bash
STATUS=$(networksetup -getairportpower en1 | grep "On")
if [ -z "$STATUS" ]; then
networksetup -setairportpower Wi-Fi on
echo "Wi-Fi turned on"
else
networksetup -setairportpower Wi-Fi off
echo "Wi-Fi turned off"
fi
Make the script executable with the following command:
chmod +x wifi-toggle.sh
Now you can run the script to toggle Wi-Fi on or off with a single command:
./wifi-toggle.sh