Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My desktop's PCI wireless card is always scanning for available wireless networks, but I only rarely use it. Can I keep the radio turned off until I need it?

share|improve this question

4 Answers 4

up vote 4 down vote accepted

"Modern" solution using Network Manager: simply uncheck the Wireless Enabled option at the Network Manager applet (KDE: Network Management). The command nmcli nm wifi off is equivalent. Continue reading if you sporadically enable Wi-Fi, but would like to revert it to disabled on reboot.

The wireless state is remembered in the file /var/lib/NetworkManager/NetworkManager.state. To disable Wi-Fi at boot, ensure that the key WirelessEnabled stays at false. You could do that by editing the init script of Network Manager, or by using the /etc/rc.local trick below. The command you need is:

sed s/^WirelessEnabled=true/WirelessEnabled=false/ -i /var/lib/NetworkManager/NetworkManager.state
rfkill block wifi

Put this before exit 0 (as described below). The rfkill block wifi command is still needed due to a race with startup of Network Manager (NM). Once NM has started, changes to the state file have no effect.


(old answer that involves editing file /etc/rc.local with an explanation of the rfkill command)

A bit hacky, but it should work. A wireless card can be disabled using the rfkill command. All devices used by rfkill can be shown using rfkill list. Sample output:

0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no

Hard blocked is dependend on a hardware setting, e.g. a wireless switch on a notebook. Soft blocked can be controlled by the OS (Ubuntu).

How does it work? It does not have a manpage, running rfkill provides a help text in this case:

Usage:  rfkill [options] command
Options:
        --version       show version (0.4)
Commands:
        help
        event
        list [IDENTIFIER]
        block IDENTIFIER
        unblock IDENTIFIER
where IDENTIFIER is the index no. of an rfkill switch or one of:
        <idx> all wifi wlan bluetooth uwb ultrawideband wimax wwan gps fm

Ah, now we get somewhere. You need to run rfkill block wifi as root to disable the wireless device. (wlan is an alias of wifi, see the source code of rfkill).

Now, if you want to disable the wireless functions at boottime, add the command to /etc/rc.local by running sudo nano /etc/rc.local. Use the arrow keys / page up/down keys to navigate to the line before exit 0 and add rfkill block wifi, so that the file end like this:

# By default, this script does nothing

rfkill block wifi
exit 0

When finished, press Ctrl + X, then press Y to save it and press Enter to accept the filename.

If you decide to activate the device later, run: sudo rfkill unblock wifi. Do not forget to remove the line from /etc/rc.local if you decide to use the wireless card.

share|improve this answer
    
Thanks. I don't understand why, but it looks like I don't need to use sudo for rfkill to work. –  ændrük Feb 4 '11 at 14:16
1  
You do not need sudo in /etc/rc.local as the script is run with root permissions. It's very unlikely you can disable wifi without root permissions. If I try rfkill block wifi or rfkill unblock wifi, I get "Can't open RFKILL control device: Permission denied". –  Lekensteyn Feb 4 '11 at 20:41
    
On both my ThinkPad X60 and my desktop with a PCI wireless card, running $ rfkill block wifi causes the NetworkManager applet to display "Wireless is disabled" and $ iwconfig to display Tx-Power=off. $ rfkill unblock wifi undoes this effect. –  ændrük Feb 13 '11 at 23:22
    
This doesn't work on my Ubuntu 14.04. If I have Wifi enabled by hand (in the network manager applet) and then restart the system, it gets enabled although i have that line in rc.local. maybe it is restored by the session somehow, that comes later in the boot process? –  rubo77 Jul 1 at 15:35
1  
@rubo77 Here (Arch Linux, Network Manager 0.9.8.10-3), there exists a /var/lib/NetworkManager/NetworkManager.state file which persists the settings, WirelessEnabled=false is one of those. I'll post in your question.. –  Lekensteyn Jul 1 at 19:30

Personally I use Jupiter the power management applet to disable the wireless on my laptop as it is controlled by a special button. I don't think is in the main repo I had to add a ppa from Andrew at Webupd8 to get it.

Hope this helps.

share|improve this answer

The easiest way to disable your wireless card is to right-click on the NetworkManager indicator (small icon on top-right on the panel), and untick the Enable Wireless. This brings down (ifconfig wlan0 down) the interface and it does not perform scanning anymore.

share|improve this answer
1  
Checking this menu item does not affect the default behavior. The next time I turn on the computer, the wireless radio is active again. –  ændrük Jan 31 '11 at 23:22
    
At my Ubuntu 14.04 it stays off as desired after a reboot if I turn it of in the network manager applet –  rubo77 Jul 1 at 15:42

You could add

ifconfig wlan0 down

to /etc/rc.local, but first,

ensure that, if you're using NetworkManager (I have version 0.8.4~git.20110319t175609.d14809b-0ubuntu3), you go to menu "Edit Connections" -> "Wireless" tab, click on the connection, click "Edit", and make sure that, in the "Wireless" tab, the "Connect Automatically" checkbox is NOT checked.

share|improve this answer
1  
While this will bring the interface down, it won't save as much power as disabling the radio using rfkill. –  gertvdijk Feb 3 '13 at 20:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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