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.

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
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
$ 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

share|improve this question
    
I foudn something here: ubuntuforums.org/showpost.php?p=10248717&postcount=10 - will try it out ... –  mit Feb 13 '11 at 22:07
1  
Exact duplicate of How can I keep a wireless card's radio powered off by default?. –  Lekensteyn Feb 13 '11 at 22:08
    
@Lekensteyn The other question does not help me. In my case rfkill list has an empty output. sudo rfkill block wifi does nothing. –  mit Feb 13 '11 at 22:39
    
If rfkill doesn't work or lists no devices, you really should open a bug on Launchpad about it, against the 'linux' package, using the "ubuntu-bug linux" command. –  Mathieu Trudel-Lapierre Apr 20 '11 at 20:32
1  
Keeping the right state for NetworkManager (whether wireless is enabled or disabled) across reboots is now fixed in Maverick and Natty. –  Mathieu Trudel-Lapierre Apr 20 '11 at 20:34
add comment

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
could you add the command to do the opposite? –  myusuf3 Feb 13 '11 at 22:33
    
sudo rfkill block wifi doesn't seem to do anything. Wifi stays on. –  mit Feb 13 '11 at 22:37
    
@dustyprogrammer: done @mit: can you post the output of rfkill list (nvm, I saw your comment in your question)? –  Lekensteyn Feb 13 '11 at 22:41
    
I updated the question with the output. See my "EDIT A" - all the commands return no result in the console. –  mit Feb 13 '11 at 23:05
1  
FYI: sudo ifconfig <interface> down is not recognized by Network Manager. This isn't a bug, and EVENTUALLY Network Manager gets that the wifi card is disabled (although sometimes it doesn't. I have the same issue with both the command line and the wifi "kill switch" I have on my system (Ubuntu 10.04 and Ubuntu 10.10) –  Thomas W. Mar 16 '11 at 3:35
add comment

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.