I am a die hard fan of Ubuntu – a lot more better than Windows Operating System based on Linux – so much so that I have completely stopped using Windows in my PC long time back. Windows costs money and makes you pay for buying it, while Ubuntu is free and makes your life much much better after installing it.
Problem: Slow Wifi Speed in Ubuntu
Recently Ubuntu came out with its newest version 11.04 code named Natty Narwhal, and after upgrading my earlier 10.10 version Maverick to this new Version of Ubuntu, I faced my first real issue with Ubuntu in so many years – My USB Wireless Internet Connection speed had almost come to a standstill like a slow dial up connection after upgrading Ubuntu to 11.04! The connection was n times weaker than Windows based systems running on same wireless connection. Many a times it even simply dropped Internet connections.
And I was quite sure that the Upgrade to 11.04 was causing this issue, and that too only with my wireless connection. That was because, the upgrade which I downloaded which was more than a GB I guess was relatively very quick over my wireless connection and happened within a couple of hours. And when the wireless became dead slow after the upgrade, I did a check on the same connection using a normal Ethernet connection (a wire -full connection) and the speed with Ethernet was good as usual, only the wireless sucked.
I searched the entire Ubuntu documentation and forums, only to see that most people had the same problem after their upgrades, but none of the solutions posted there worked – not at least for me. I was going mad with my slow wireless Internet connection when I finally found this thread which said that it was the new Power Management settings in Ubuntu that were causing less power to be supplied to the wireless Internet device there by considerably slowing down the Internet speed in many wireless devices!
Solution to Slow Wifi in Ubuntu
And the solution? Well, that is the reason I wrote this post. The solution is to run the following command to turn off Power Management of your wireless device by Ubuntu, and instantly after running this command my wireless Internet gained Rocket speed!
Just open a Terminal window in Ubuntu and type
sudo iwconfigCode language: Bash (bash)
This will list the available wireless interfaces in your system. Now check out your wireless device name here, usually it will be wlan0
Now type the command
sudo iwconfig wlan0 power offCode language: Bash (bash)
What this essentially does is switch off the power management by Ubuntu for your wireless device. That’s it, and now trying to download a file or watching a Youtube video, and you will see that your wireless Internet connection is now back to top speed.
But this is only a temporary solution, because the next time your operating system starts, you will have to run this command again. So we actually need a permanent solution to forever prevent Ubuntu from handling the power management of our wireless device. How to get that done?
All we need to do is edit the file at the path /etc/pm/power.d/wireless – if this file or path does not exist, then you need to create it.
So cd to the directory /etc/pm/power.d and if this directory structure is not there then you need to create it using mkdir.
The create or edit the file called wireless in this folder using the following command in a terminal window
sudo pico /etc/pm/power.d/wirelessCode language: Bash (bash)
NOTE: I prefer pico to gedit, if you are more comfortable with gedit, then simply replace pico with gedit.
The above command opens the wireless file for editing as a root user.
In this file add the following lines and save the file and exit. That’s it.
/sbin/iwconfig wlan0 power offCode language: Bash (bash)
The above lines tell Ubuntu not to manage the power supply to the wlan0 wireless device. So even after you restart your system, Ubuntu will not control the power supply of your USB wireless device, and there you are your wireless internet speed back to normal forever or at least till you face another issue.
By the way, I also don’t like the new Unity interface in Ubuntu 11.04 and have reverted it back to the classic GNOME – don’t want my powerful PC to look like a small Notebook.
Update (Feb 21 2011)
Even though my wireless Internet connection gained back a significant amount of its original speed after applying the above fix, it still was not running at its peak speed and I continued to search for other solutions to bring back my wireless internet connection to full speed. And finally the below additional fix brought back my wireless connection to its top speed on par with my windows system. So here goes the solution.
There is a bug in the Debian Avahi daemon in Ubuntu. And to resolve this you need to edit the following file /etc/nsswitch.conf as follows.
Type the following in the command line
sudo gedit /etc/nsswitch.confCode language: Bash (bash)
This will open the nsswitch.conf file in the text editor. Then simply change the following line
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
to the below line and save the file.
hosts: files dns
That is it. Just reset your internet connection or probably restart your system and your wireless connection should be back on top speed. This worked for me like a charm.