38

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

43

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
  • Object 'radio' is unknown, try 'nmcli help' – Tessaracter Jul 24 '18 at 12:13
  • 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 4 at 7:17
30

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.

  • 7
    I think in 16.06 it would be nmcli r wifi off At least that is what worked for me. – MikeSchinkel Apr 24 '16 at 2:48
  • 1
    nmcli nm wifi off/on work for me in Ubuntu14.04 LTS – alhelal Aug 26 '16 at 3:44
  • 3
    @MikeSchinkel Right, works well. On the contrast, the nmcli nm wifi off command throws: Error: Object 'nm' is unknown, try 'nmcli help'. Thanks. – SkyRaT Feb 9 '17 at 9:34
7

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.

  • nice answer for a new user! – cat Jan 22 '16 at 2:16
  • This method works on Ubuntu 19.04, but the nmcli method does not. – Adam Erickson May 10 at 19:20
5

A method no one mentioned:

rfkill list to view wireless/bluethoot devices

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

2

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/"`
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
  • Wow, This works with 14.04 too. Amazing!! Thank you – Tessaracter Jul 24 '18 at 12:11
0

First, install the following cool 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.

Hope you enjoyed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.