I want to know how to control (specifically turn off) the networking (specifically AirPort - I want to turn off the radio) from the command line (specifically from bash in Terminal.app, being run by me) as a user (no sudo privileges or admin priviliges). You CAN turn off AirPort as a user, but I need to do this from the command line – as a user.
1 Answer
See OSX Daily - Enable and Disable AirPort Wireless from the Command Line in Mac OS X. Quote:
Turn Airport Off via Command Line
networksetup -setairportpower airport off
Turn Airport On via Command Line
networksetup -setairportpower airport on
You won’t see any confirmation in the Terminal that the command succeeded or failed, but if you watch the AirPort menu icon you will see the bars disappear indicating the wireless interface is turned off, or reappear indicating that wireless is activated again.
NOTE: In OS X Lion, use the hardware name above instead of airport
,
e.g. networksetup -setairportpower en1 off
.
-
2This a great answer, but you should specify that they need to replace
airport
with the network adapter name their computer uses. For my MacBook Pro, it'sen1
. Mar 31, 2012 at 0:54 -
Great point. The article I quoted to even had a similar comment. Mar 31, 2012 at 1:10
-
Thank you! This was very helpful, a friend of mine is on a computer where when you try to change airport to off it pops something up for the admin password. This seemed easier than fixing that - now he has two workflows for connecting automatically to various networks at times of the day and stuff like that. Mar 31, 2012 at 2:42
-
2Beware that it is not always
en1
. To find out what it is on your computer, you can use eithernetworksetup -listallhardwareports
orifconfig
.– mhuckaNov 20, 2012 at 1:19