Ubuntu – How to switch off wifi on startup or from the console


I have installed ubuntu 10.04 on a laptop. Wifi is switched on by default on startup. I can disable it rightclicking the network manager icon in the gnome bar.

How can I set it to have wifi switched off as default?

Alternatively, how can I switch off wifi on the console?

I tried already the rfkill command but it does not list any devices and it does not switch off wifi, I tried different parameters.

This is a standard install of the Ubuntu 10.04 i386 Desktop Live CD on an IBM T40 Laptop.

EDIT A: This is the output of some rfkill commands on my system, and it does not affect the wifi of the laptop:

$ rfkill --help
Usage:  rfkill [options] command
    --version   show version (0.4)
    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
$ rfkill list
$ rfkill list wifi
$ rfkill list all
$ rfkill list wlan
$ sudo rfkill list all
$ sudo rfkill block all
$ sudo rfkill block wlan
$ sudo rfkill block wifi

EDIT B: Now I found out that

sudo ifconfig eth1 down

turns it off.

And I can turn it on through the gnome network applet again. But the applet does not reflect the change from the commandline, it stills believes wifi is switched on. I have to switch it off and on again on the applet to switch it on again, when I switched it off from the console.

Is there a better way?

This is what the syslog looks like when I switch wireless off and on again from the network manager:

NetworkManager: <info>  (eth1): device state change: 3 -> 2 (reason 0)
NetworkManager: <info>  (eth1): deactivating device (reason: 0).
NetworkManager: <info>  Policy set '24' (eth0) as default for routing and DNS.
NetworkManager: <info>  (eth1): taking down device.
avahi-daemon[660]: Withdrawing address record for fe80::202:8aff:feba:d798 on eth1.
kernel: [  971.472116] airo(eth1): cmd:3 status:7f03 rsp0:0 rsp1:0 rsp2:0

NetworkManager: <info>  (eth1): bringing up device.
NetworkManager: <info>  (eth1): supplicant interface state:  starting -> ready
NetworkManager: <info>  (eth1): device state change: 2 -> 3 (reason 42)
avahi-daemon[660]: Registering new address record for fe80::202:8aff:feba:d798 on eth1.*.
kernel: [  965.512048] eth1: no IPv6 routers present

EDIT C: It works somehow now, but in a hacky way, not very nice. I added a line to rc.local, just before exit 0:

$ cat /etc/rc.local 
#!/bin/sh -e

# turn off wifi on boot:
ifconfig eth1 down

exit 0

When I start the machine, wifi comes up, and after an instance it is turned off. This must be the effect of the standard configuration of ubuntu that turns it on, then my script ifconfig eth1 down kicks in and turns it off. And network manager does not realize that it was turned off and thinks it is still on.

It would be desirable to configure network manager's so that the standard state when turning on the machine can be on or off, and not only on

Best Answer

You can turn off Wifi using rfkill:

sudo rfkill block wifi

To turn it on again, run:

sudo rfkill unblock wifi

See my answer on How can I keep a wireless card's radio powered off by default?.

Related Question