97

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".

Cerin
  • 6,485

8 Answers8

130

The command-line equivalent in ubuntu 16.04

nmcli radio wifi off

To re-enable, use

nmcli radio wifi on

To help

nmcli radio help   
nmcli radio wifi help
Adriano
  • 1,416
  • Object 'radio' is unknown, try 'nmcli help' – Trect Jul 24 '18 at 12:13
  • 3
    Tried this on Ubuntu 18.10. Not sure if I was too impatient, but looks like I had to throw a "sudo" in there to get it to work: sudo nmcli radio wifi off. – Stéphane Oct 04 '19 at 07:17
  • 2
    Thanks @Stéphane, on Ubuntu 20.04 this command is silently ignored without sudo. It should fail with an error message. – MarcH May 13 '20 at 22:50
  • 1
    @Stéphane On Ubuntu 16.04, I had to use sudo because I was connected to the machine through a remote connection (the sudo was needed maybe to prevent a normal user from stopping the wifi). When I logged in locally, it worked fine without using sudo – SebMa Jun 06 '20 at 13:41
  • 1
    This does not disable the wireless. It turns it off. Any ideas on how to actually disable it? Do I have to disable the mod for the wifi? cfg80211 710770 3 iwlwifi,mac80211,iwldvm – J Roysdon Aug 22 '20 at 18:12
  • As of Jan 2022 and Ubuntu-MATE 21.04 this works nicely without sudo. (also nicely+immedeatly reflected in the top panel network widget) – Frank N Jan 30 '22 at 15:41
44

Enable/disable networking completely

nmcli networking off

Just for WiFi

nmcli radio wifi off

On 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 nm instead of networking. See nmcli man page.
  • Table with differences between nmcli v0.9.8 vs. v0.9.10.
  • The top-level nm object no longer exists, and the equivalent nm wifi options are now provided by a radio object.
  • The nmcli interface changed significantly between v0.9.8 and v0.9.10, and the documentation notes that:

Even 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.

Pablo Bianchi
  • 15,657
steeldriver
  • 136,215
  • 21
  • 243
  • 336
14

In general, simple

sudo ifconfig wlan0 down

...should be enough. Sometimes, wireless card can be shown as

ethX

instead of

wlanY

then you need to double check which ethX to disable and you can do it with

sudo lshw -C network

and 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.

10

First, install the following package:

sudo apt install tlp

Now, turning your WiFi connection on or off will be really simple:

wifi on
wifi off

Great! Even more, you can also toggle your WiFi connection:

wifi toggle

Tip: 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.

10

A method no one mentioned:

rfkill list to view wireless/bluethoot devices

rfkill block <device number> to (soft) block it

13dimitar
  • 935
4

For 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.

1

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/"`
Vic
  • 587
  • 1
  • 6
  • 16
0

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
N. S.
  • 371