Disable wireless on startup
Solution 1
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
Solution 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.
Solution 3
You can stop it connecting to specific connections automatically quite easily.
- Right click the Network Manager notification applet
- Click Edit Connections...
- Under the Wireless tab, click edit on the connection(s) you want to disable by default and click edit.
- Uncheck Connect automatically
- 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.
Solution 4
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.
Solution 5
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
Eugene
Updated on September 17, 2022Comments
-
Eugene over 1 year
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.
-
Cedric over 2 yearsPeople searching an alternative answer could try askubuntu.com/questions/1039506/… (place sudo rfkill block wifi in your /etc/rc.local)
-
Cedric over 2 yearsAlso, 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)
-
-
Eugene over 13 yearsNope. 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.
-
Jorge Castro over 13 years@Eugene: Add that information to your original question please!
-
Eugene over 13 yearsStrange. 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 over 13 yearsAlso, 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 over 13 yearsDo I understand correctly, that placing this
sudo ifdown wlan0
inrc.local
will not affect the system anyhow even after reboot? Do I need to call this script somehow? -
Eugene over 13 yearsWould you care to elaborate on what will those operations do?
-
Eugene over 13 yearsBy the way it didn't disable those diodes, so I guess it didn't help.
-
Eugene over 13 yearsHow 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?
-
uuu777 over 13 years@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.
-
Eugene over 13 years@ithkuil You know what. I don't know what is my wifi driver actually, but I have Asus F3T laptop.
-
keyboardsurfer over 13 yearsThis 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) -
uuu777 over 13 years@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).
-
Eugene over 13 years@ithkuil Here is output of
lspci
command eugenes.pastebin.com/YCydCyhM. Here is output ofifconfig
command after I disabled the Wireless network with Fn+F2 eugenes.pastebin.com/7PxF1ked and here is before I disabled eugenes.pastebin.com/acKP2rTf. -
uuu777 over 13 years@Eugene, not ifconfig but iwconfig, just to see which parameters are changed by the Fn-F2, so that we can find a command to reproduce it programmatically at startup.
-
Eugene over 13 years@ithkuil Sorry for such long delay. I was ill, but now I'm back in action. So here is output of
iwconfig
command before Fn+F2 eugenes.pastebin.com/4YBJsfAh. And here is output after Fn+F2 eugenes.pastebin.com/6JrytwEY. -
uuu777 over 13 yearsGreat, it seems that the switch does indeed turn off the antenna power as controlled by the driver and the iwconfig command.
-
uuu777 over 13 yearsSo @Eugene (I'm glad you are well), next question: if you execute <code>sudo iwconfig wlan0 txpower off</code> when your wifi 'led' is on, does it turn it off ?
-
Eugene over 13 yearsNo. I tried already your main suggestion and it didn't help. Yes
Tx-Power
was set tooff
as if I pressedFn+F2
, but 'led' was still on. Actually both. WiFi and Bluetooth as you can see on the picture in main post. -
uuu777 over 13 yearsAh, and what happens if you press Fn+F2 after turning the tx-power off by command? Does it turn tx-power on again (and perhaps switches the led off?)
-
Thomas Ward almost 13 yearsThat 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.