14

I use Ubuntu 10.04 and I see, that every time when I start it enables Wireless Connectivity.
I know, that there is a topic about it on Ubuntu forums, but I think I will get old before I get an answer there (if there is one).

I would like to disable it by default, but to have possibility to enable or disable it later.

I want to know how to disable the wireless adapter. Something like Fn + ... in Windows, but in windows it remembers the last state. In Ubuntu the wireless adapter is always enabled at startup.

When I press Fn+F2 it disables those diodes and Wireless + Bluetooth.

2
  • People searching an alternative answer could try askubuntu.com/questions/1039506/… (place sudo rfkill block wifi in your /etc/rc.local)
    – Cedric
    Feb 11, 2022 at 12:52
  • Also, if there is no file /etc/rc.local , create it, add #!/bin/bash as a first line, then rkfill block wifi , make it executable (sudo chmod 755 /etc/rc.local)
    – Cedric
    Feb 11, 2022 at 12:53

12 Answers 12

12
+25

There are so many ways to disable the card. The simplest I would say would be to put:

sudo ifdown wlan0 

in your /etc/rc.local above the line exit 0. This should disable the wireless card (replace wlan0 with your wireless interface card)

If you want to enable/disable on a keyboard press, this thread on Ubuntu Forums explains how to link a keyboard event to a script. If you want it to toggle when you push keys you will have to add some logic to the script. Though the simplest way might be to have one key to enable and another to disable.

down script

    #!/bin/bash
    IFACE=wlan0
    ifconfig ${IFACE} down

and up script

    #!/bin/bash
    IFACE=wlan0
    ifconfig ${IFACE} up
2
  • Do I understand correctly, that placing this sudo ifdown wlan0 in rc.local will not affect the system anyhow even after reboot? Do I need to call this script somehow?
    – Eugene
    Sep 9, 2010 at 16:11
  • That script is called immediately at the end of the boot script. It will effectively turn off the wifi card once the system has finished booting. The only thing that will happen is that the wifi card gets turned off.
    – Thomas Ward
    Jul 15, 2011 at 13:38
3

You can stop it connecting to specific connections automatically quite easily.

  1. Right click the Network Manager notification applet
  2. Click Edit Connections...
  3. Under the Wireless tab, click edit on the connection(s) you want to disable by default and click edit.
  4. Uncheck Connect automatically
  5. Click apply, close the window, rinse and repeat.

When you want to connect, just left click the applet and select an access point.

Note: This doesn't power off the wifi card and it'll still be searching for wireless access points. This might not be what you're looking for. But if it is, great!

Note 2: If your connection drops, it won't automatically reconnect.

2
  • Nope. That's not it. I'm looking how to disable Wireless adapter. Something like Fn + ... in Windows, but in windows it remembers the last state. In Ubuntu wireless adapter is always enabled at startup.
    – Eugene
    Sep 5, 2010 at 17:54
  • @Eugene: Add that information to your original question please! Sep 5, 2010 at 18:00
2

Create session on startup application such as:

Settings >> Preference >> Startup Application

Add then fill command :

dbus-send --system --type=method_call --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.DBus.Properties.Set string:org.freedesktop.NetworkManager string:WirelessEnabled variant:boolean:false

false means off but it can be to enable by fn+F2 or something else.

1

I use wicd instead of NetworkManager. It remembers wi-fi state after reboot/next boot. Don't know how, but it does. :)

If you don't need some NM features, use wicd. It's easyer to use and control.

2
  • How does it remember wireless network state? I can't even disable it from there. Do you need a screenshot of what I see from there? Maybe some specific tab?
    – Eugene
    Sep 10, 2010 at 16:41
  • Sorry for late response. Does Fn+F2 works for you now? If yes WiCD should save wireless adapter state upon next boot.
    – PocketSam
    Oct 10, 2010 at 13:27
1

If your FN+F2 do not work in Ubuntu (it should, mine does in an Asus EeePC netbook), then i really reccomend you using Jupiter. Its a sweet, well polished notification area applet.

With it, you can enable and disable Bluetooth and WiFi separately, as well as other nice controls for notebooks and netbooks. It remembers the state after reboot and even remember the state per power source (meaning it can always turn WiFi ON when you plug in power, and automatically turn it OFF when you are on battery). And you can bind all actions to keystrokes.

A nice review, and some screenshots: http://www.webupd8.org/2010/06/jupiter-take-advantage-of-asus-super.html

Official project page: http://www.jupiterapplet.org/

PPA (for automatic updates in APT/Synaptic/Software Center: https://launchpad.net/~webupd8team/+archive/jupiter

Wiki (great thecnical documentation): http://sourceforge.net/apps/mediawiki/jupiter/index.php?title=Main_Page

1

Wireless can be enabled or disabled using rfkill tool. Here is solution based on it, that will allow to save state and restore it at system startup.

Step 00: creation of file to store wifi state

cd /usr/local/etc
sudo touch .wifistate
sudo chmod 666 .wifistate

Step 01: script

    #!/bin/bash
    IFACE="wlan1"
    STATE_FILE="/usr/local/etc/.wifistate"

    STATE="$(iwconfig $IFACE | grep Tx | cut -d '=' -f2 | grep off)"
    if [ "$STATE" ]
    then
       rfkill unblock wifi &&
       echo 1 > "$STATE_FILE" &&
       echo "Wireless enabled"
    else
       rfkill block wifi &&
       echo 0 > "$STATE_FILE" &&
       echo "Wireless disabled"
    fi
    exit 0;

Step 10: making script executable

chmod +x <script name>

Step 11: modifying Ubuntu startup script

open /etc/rc.local in any text editor (must be edited as root) and add following code
before exit 0; line:

    FILE="/usr/local/etc/.wifistate"
    if [ -r "$FILE" ]
    then
       if [ $(cat $FILE) -eq 0 ]
       then
          rfkill block wifi
       fi
    else
       rfkill block wifi
    fi

Done, now script from step 01 may be linked to keyboard event. After first use it will write 0 or 1 in .wifistate file, and on system startup rc.local script will take attempt to read this value and, if it is 0, disable wifi.
If .wifistate file does not exist, by default wifi will be disabled at startup.

0

try sudo iwconfig wlan0 txpower off

replace wlan0 with eth2 or whatever is your wifi interface.

this will disable your wifi antenna and save power, but it doesn't prevent Network Manager from trying to connect so you might want also to disable network manager's wifi auto connect settings as described by Oli.

12
  • Strange. If it will disable my wifi antenna, then logicaly it will not find any wireless networks and it will not try connect. At least this is how I see it logicaly, but I could be wrong.
    – Eugene
    Sep 6, 2010 at 16:06
  • Also, now when I tried it I can say, that this was not the correct solution and I'm adding a picture to question. Maybe, that will help.
    – Eugene
    Sep 6, 2010 at 16:41
  • @Eugene, what is your wifi driver and exact laptop model? I suspect that you need a driver specific solution, if you want that the led on your laptop is turned off.
    – mkm
    Sep 10, 2010 at 17:50
  • @ithkuil You know what. I don't know what is my wifi driver actually, but I have Asus F3T laptop.
    – Eugene
    Sep 11, 2010 at 11:42
  • @Eugene, please attach the output of the lspci command ? Probably it's an Atheros 5006EG WLAN card. This guy here personal.inet.fi/koti/vjankala/sf/asus.html says that Fn-F2 works on your laptop with festy. Does it work for you? if yes, please invoke "iwconfig" while the wifi is active, deactivate the wifi with Fn-F2, and then execute iwconfig again (pasting the output here).
    – mkm
    Sep 12, 2010 at 14:22
0

Try looking under 'System > Preferences > Network Connections > Wireless' and make sure none of the listed wifi spots are set to auto connect. This will not stop wireless starting, but will stop it from making any connections.

0

Install sysv-rc-conf then run it as root and make sure there is an X at runlevels S 0 1 2 for wpa-ifupdown or simply type sudo sysv-rc-conf --level S012 wpa-ifupdown on after installing.

3
  • 1
    Would you care to elaborate on what will those operations do?
    – Eugene
    Sep 10, 2010 at 8:17
  • By the way it didn't disable those diodes, so I guess it didn't help.
    – Eugene
    Sep 10, 2010 at 16:40
  • This adds the wpa-ifupdown script to the corresponding runlevels. Maybe you have to add even more runlevels. S012345 should add it to all runlevels except the reboot level (6)
    – Ben Weiss
    Sep 11, 2010 at 15:03
0

Whatever the reason is for what you're trying to disable it, I'm not sure if it works for every laptop, but it worked for me: with a plugged LAN cable Ubuntu ignores the wi-fi, thus making you able to sorta "turn it off" prior to system loading.

0

Run sudo lshw -c network and look for the name of the driver for your wireless card. Run lsmod | grep DRIVERNAME to show the exact name of the driver. Then add a line to /etc/modprobe.d/blacklist.conf that says blacklist EXACTDRIVERNAME. This will stop the wifi module from being loaded at boot time. Run sudo modprobe EXACTDRIVERNAME at any time to restart the wifi.

This works quite effectively, but is not the best solution. It does not disable the Wireless card. It just prevents the OS from using it, but it may still be on, consuming battery power.

0

Bruteforce would be the blacklisting of the wifi-kernel modules:

  1. dmesg | grep atheros (or whatever in your pc) or lsmod
  2. look for that driver/module in /lib/modules//kernel/drivers/wireless/...
  3. create a blacklist file "no-wireless.conf" in dir /etc/modules.d, containing

    # blacklist wifi
    blacklist [a blacklist line for each name of your wifi modules eg. ath...]
    blacklist rfcomm
    blacklist mac80211

--

But you can't enable wifi anymore after boot, except you remove this file from modprobe.b and reboot

PS: Don't forget, before you should backup your system somehow (eg with ubuntu live or whatever)

(Sorry didn't read that post underneath)

You must log in to answer this question.

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