How do you disable the wireless Internet from the command line?
I tried sudo ifconfig eth1 down but network-manager seems to ignore this and keeps trying to reactivate it. What's worse is the network-manager widget doesn't let you disable it either once it starting "trying to connect". Whenever I'm near a spotty connection, it just keeps trying and trying to connect, failing each time and showing an annoying error message, "sorry, we couldn't connect".
8 Answers
The command-line equivalent in ubuntu 16.04
nmcli radio wifi offTo re-enable, use
nmcli radio wifi onTo help
nmcli radio help
nmcli radio wifi help 6 Enable/disable networking completely
nmcli networking offJust for WiFi
nmcli radio wifi offOn both cases on to re-enable.
If you need to permanently disable a particular device, then you can do that programatically using the unmanaged-devices feature in /etc/NetworkManager/NetworkManager.conf or (at a lower level) by blacklisting or removing the corresponding driver.
For older versions than v0.9.10
- Use
nminstead ofnetworking. Seenmcliman page. - Table with differences between nmcli v0.9.8 vs. v0.9.10.
- The top-level
nmobject no longer exists, and the equivalentnm wifioptions are now provided by aradioobject. - The
nmcliinterface changed significantly between v0.9.8 and v0.9.10, and the documentation notes that:
3Even if nmcli tries to keep backwards compatibility in general, there were requirements during Networkmanager development that forced some incompatible changes in nmcli. The table bellow list differences between 0.9.8 and 0.9.10.
In general, simple
sudo ifconfig wlan0 down...should be enough. Sometimes, wireless card can be shown as
ethXinstead of
wlanYthen you need to double check which ethX to disable and you can do it with
sudo lshw -C networkand look for your wireless card entry inside which you will find:
logical name: <ethX_or_wlanY_goes_here>I guess you probably know and your problem is bigger then that but at the same time, probably lots fresh of people will find this topic and this should be enough for them.
3A method no one mentioned:
rfkill list to view wireless/bluethoot devices
rfkill block <device number> to (soft) block it
First, install the following package:
sudo apt install tlpNow, turning your WiFi connection on or off will be really simple:
wifi on
wifi offGreat! Even more, you can also toggle your WiFi connection:
wifi toggleTip: You can do the same with your bluetooth device using bluetooth command.
Causion: Although I know this is an Ubuntu forum, however, a caution for Fedora users: If you install TLP package on Fedora, then you might have issues starting RFKill service during boot process. For more information, see what's RFKill and this related problem.
Warning: Not sure about every possible case, but TLP might slow down your system, and could cause you experience lags and/or freezes. The reason is, it's mainly a package for improving battery life and usage, perhaps by making your processor mode to powersave.
1For me, on Ubuntu 15.04 nmcli radio wifi off worked for turning off wifi. To turn off networking in general (including LAN) I use nmcli networking off.
There is a way to toggle the state of the WiFi connection. It might be useful to know.
nmcli radio wifi `nmcli r wifi | grep enabled -c | sed -e "s/1/off/" | sed -e "s/0/on/"` nmcli networking off and nmcli radio wifi off does not work for me in ubuntu 12.04! The following commands works for me:
nmcli nm status
nmcli nm wifi off 1