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

8 Answers 8

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
6
  • Object 'radio' is unknown, try 'nmcli help'
    – Trect
    Jul 24, 2018 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 4, 2019 at 7: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, 2020 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 6, 2020 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, 2020 at 18:12
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.

3
  • 7
    I think in 16.06 it would be nmcli r wifi off At least that is what worked for me. Apr 24, 2016 at 2:48
  • 1
    nmcli nm wifi off/on work for me in Ubuntu14.04 LTS
    – alhelal
    Aug 26, 2016 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, 2017 at 9:34
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.

3
  • nice answer for a new user!
    – cat
    Jan 22, 2016 at 2:16
  • 2
    This method works on Ubuntu 19.04, but the nmcli method does not. May 10, 2019 at 19:20
  • "down" turns the device off. "up" turns it back on.
    – rveach
    Oct 23, 2021 at 11:14
10

A method no one mentioned:

rfkill list to view wireless/bluethoot devices

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

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.

1
  • This was what I needed! Thanks! =) Now to find an equivalent for brightnessctl...
    – x10an14
    Dec 22, 2020 at 9:58
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.

0
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
1
  • Wow, This works with 14.04 too. Amazing!! Thank you
    – Trect
    Jul 24, 2018 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .