How to speed up your Linux machine
6th May 2012 | 07:00
Make your Linux box that bit snappier
Speed up your Linux machine
Linux brings with it many benefits, and we all have our favourites. For some, it's freedom from viruses, or virii, or even virus, if you're declining your Latin properly.
For others, it's the knowledge that no outside agent will be able to control the way you use your computer; software freedom can sound like a concern only for tin-foil-hat wearers, but, as Apple users found last year, if you need to pay to upgrade your operating system in order to listen to your music (that you've paid for) on your computer (that you've paid for), software freedom matters to you.
But, for anyone who has ever double-clicked on an icon in Windows and had to wait as the computer makes up its mind about what it's going to do, the general speed and snappiness of the Linux desktop is a winning advantage.
And this goes for everyone: whether you're using an eight-core flying machine or chugging along with a laptop from the golden age of steam, you're better off with Linux. And if you want even more speed? Just follow these tips…
8 of the best tiny Linux distros
How to dual-boot Linux and Windows
24 things we'd change about Linux
Beginner's guide to Linux
VirtualBox is your friend
Some of these tips involve the modification of system files, as root. When you're editing configuration files, there's always the chance that you'll accidentally break something and make your machine unusable, so we always recommend that you make a backup of whatever file it is you're working on, so you can restore the old values at a later date if something goes wrong.
Even better, though, is to experiment first with a virtual machine. That way, you can mess around to your heart's content, then simply revert to a working snapshot if you break the system. Check out our handy tutorial on how to run Linux in a virtual machine.
1. Boost your bootloader
If you have a dual-booting set-up, you'll be familiar with the menu screen that Grub gives you when you fire up your machine. But what you might not have noticed is the countdown underneath the menu entry area, which tells you how long the system will wait until it boots the default distro for you.
By default on Linux Mint, this is 10 seconds. You could press Enter, but if you're away from your machine and want it to boot more quickly, you can cut this time to something more sensible - three seconds, say, which is still long enough to give you time to make a choice if you want to.
To make unattended bootups faster, go in to etc/default and open the file grub (as root). Change the value that reads GRUB_TIMEOUT=10 to 3, then run update-grub to make the changes take effect.
2. Disable services
When you start up your machine, there's a huge lag between the kernel booting and your desktop appearing, in which time the distro is frantically loading all the background services it needs to run smoothly. Except you don't need all these services at all.
In most distros, the services live in /etc/init.d, and you can stop the ones you don't need from starting up by right-clicking (in Nautilus) and going to Properties > Permissions and unticking the box marked Execute: Allow Executing File As Program.
What's that? You don't know what you need, so you don't know what to turn off? Trial and error is one option, or, if you use SUSE or Mandriva, you're better off using Yast or the Mandriva Contro Centre.
In Yast, go to System > System Services and you'll see a long list of all the services that are available to you. Highlight any one of these to get a description of what that service does, and you should have a pretty good idea of what you can disable.
3. Unburden the login manager
One of the criticisms people used to level at Linux is that it didn't look very nice. So developers set to work on attractive ways to log in, which would present a lovely shiny face to the public right from the moment they fired up their machine.
Sadly, these login managers consume so much power that they end up slowing things down - which is bad. To save time at login (and to make your machine feel as if it's stuck in the nineties), replace your current login manager (this is most probably GDM or KDM, for Gnome and KDE respectively).
In Mint, go to /etc/X11 and look for the file default-displaymanager; in OpenSUSE go to /etc/sysconfig and look for displaymanager. In either distro, you should change the entry that reads gdm or kdm to xdm.
4. Speed up Nautilus
Nautilus, the file manager in Gnome, performs a quick scan of all the files it encounters in a folder once you open it up, to show you a thumbnail image of photos and videos, and the first few lines of text files. Well, we say "a quick scan", but in a folder that's packed with large files, this process can be anything but quick.
To stop wasting your machine's time on this helpful but non-essential task, go to Edit > Preview in Nautilus and change the options from Always, or Local Files Only, to Never. You should find that this gives Nautilus a much snappier, more responsive feel.
5. Lighten the load
In your quest for high-performance computing you may have dismissed distributions for older hardware as irrelevant. Stop. Think again.
The reason that Puppy, VectorLinux et al are so good for older hardware is that they don't demand much in the way of system resources. That's exactly the attribute that makes them run extremely quickly on modern hardware.
If you have a machine made in the last couple of years, with 2GB or more of RAM, you can tweak its performance with all the other tips in this feature, or you could achieve a similar result simply by installing VectorLinux. If you're willing to experiment with a new distribution, this is the single most convenient step towards a faster computer.
6. Use a faster window manager
If you're not in the mood for a complete distribution switch, then you can still make some big improvements by integrating some of their features into your current configuration. The window manager, for example, can usually be transplanted from one desktop to another, and if you're using a feature-heavy desktop such as KDE, this can give you a significant boost.
It's the window manager's job to look after those windows you've got open and give you enough control over them to make you productive. But they can also offer far more features than you need. If you right-click on a window's top bar in KDE and count the options, you'll see what we mean, which is why a different window manager should be both faster and less of a distraction.
Perhaps the most popular is Openbox, and it's common enough to be packaged with most distributions. Just install it from your favourite package manager.
After installation, from whichever desktop you may favour, open the command line and type 'openbox --replace'. This will generate some output, and some running applications may even complain, but we're forcing the system to replace the current window manager with a new one.
Within a few moments, you should find that the style of your window borders has changed. This is Openbox. Using the right-click Context menu from the top bar, you can still move windows to another desktop, or force them to hover over other windows, but you can't do anything else. Your windows should now move faster.
7. Boost KDE performance
KDE is pretty fast if you've got a modern machine, but it's a complicated stack of software. And each component can usually be configured more effectively for performance.
The best place to start is in the background, with the process that manages everything else. This process is called plasma-desktop, in reference to the new paradigm shift in usability that KDE now offers. This is also a process that can be launched with different options, one of which can improve performance on older and slower machines, and especially netbooks.
First, though, you need to kill off the old process. This is going to cause some disruption, so make sure you've closed down anything important and that your data is saved.
Now open the command line and type killall plasma-desktop. This will plunge KDE's functionality into the dark ages. Rekindle hope with another command, plasma-desktop-graphicssystem raster. This restarts the desktop and forces Qt to use the software rendering system it has always had. The latter is faster, but not on older hardware.
You can make the change permanent by locating the plasma-desktop.desktop file used to launch your desktop (usually in /usr/share/autostart, or /.kde4/share/autostart) and modifying the Exec line within that file to include the -graphicssystem raster argument.
8. Block advertising
When browsing the web, you often find that a site doesn't load immediately because it's waiting to be furnished with advertising from a different server. Combine this with the increasingly common Flash ads and annoying animations, and you have several good reasons for blocking them.
Both Firefox and Chromium offer an extension called AdBlock that uses a database to stop the most common offenders. In Chrome, for example, use the new chrome web store to search for and install AdBlock Plus. Then make sure it's enabled in the Extensions Preferences pane. You should no longer be bothered by the majority of ads, or held back by their loading times.
9. Use shortcuts
This might seem obvious, but moving your hand from the keyboard to the mouse to perform a function takes more time than doing the same function through the keyboard. Very few of us use the Copy and Paste commands from the Edit menu, for example.
For that reason, it's worth learning a handful of shortcuts for doing things such as switching between applications, and desktops. You can take this idea further without switching your life to Emacs.
Launching applications from the Run prompt that appears when you press Alt+F2 saves navigating through the launch menu. KDE's Run Command interface can do a great deal more, too. Type shutdown to turn off your system, or lock to lock the display.
Simple calculations can be performed by starting your line with an =, and there are dozens of other functions that come from the plugin structure. Use the ? button on the right to see a list of what's available and how to use it.
The ultimate shortcut command tool is Gnome Do, which is like KDE's Run interface on steroids. Through a series of plugins, you can augment almost every aspect of your desktop, from common SSH commands to quick access to popular websites, through a hotkey and a simple command. A few hours spent with Gnome Do will save you time.
10. Patch your kernel
If you're looking for the ultimate software performance upgrade, and perhaps the ultimate challenge, there are plenty of patches that can be applied to the kernel. If you're happy, roll your own - this can be done piece by piece.
But there's a better way. One of the most popular alternatives to the standard kernel is one that has been compiled by Con Koliva from lots of different performance patches. The kernel patchset is called -ck, and it has been built with an emphasis on desktop performance.
To install it, you'll need to download the kernel source for the version the patches apply to (through your package manager), along with all the tools for building your kernel. Then download the patch from http://users.on.net/ ckolivas/kernel/ and use the patch command (patch -p1 < patch-3.*-ck1) in the kernel source folder to apply the changes.
Now build the kernel according to your distribution's instructions. That last step is easier said than done, but there are plenty of guides.
11. Overclock your Nvidia graphics card
If you're using an older Nvidia graphics card - this trick doesn't work with the latest models - with the proprietary drivers, you also have the option of pushing more performance out of your device by overclocking the hardware.
Rather than using the BIOS, though, you can use Nvidia's own control panel. But before the option appears, you need to add a new option to the /etc/X11/xorg.conf configuration file. This file is no longer created by most distributions, but the nvidia-settings utility can generate one from your current set-up.
Just load the tool, switch to the X Server Configuration tab and click on Save to X Configuration File. After the file has been generated, open it with your favourite text editor (you'll need administrator credentials), and look for the Device section that lists your card. Within this, add the line Option "Coolbits" "5" and restart your graphical display.
Now, when you run the nvidia-settings utility, you'll see an extra page labelled Clock Frequencies. Click on the Enable Overclocking button, accept the disclaimer, and try adjusting the clock and memory frequencies up in small steps. You can do this for both 3D and 2D rendering, and we'd advise adjusting them both at the same time.
Each time you apply a change, switch to the Thermal Settings view and make sure the temperature stays within reasonable limits. You can also adjust the fan speed manually from this page if you need to. When you've found a faster, stable configuration, save the settings and make sure the Nvidia tool loads these settings when your system next starts.
12. Overclock your system
First, a disclaimer: overclocking, the trick of pushing components past their recommended speeds and tolerance, can be expensive. It can break your hardware and cause data loss. But many components today are designed to withstand much greater temperatures and capacity than their stock configuration allows, and that leaves plenty of room for experimentation.
Many modern motherboards, for example, even include simple options for boosting the speed of your system, without needing any further knowledge on your behalf.
The best place to look for a quick fix is within your BIOS. This is accessed when you launch your machine, usually through the F2 or Del keys. Within the BIOS menus, there's a good chance you'll find the options to increase the memory speed, configure your system automatically for performance rather than stability, and adjust the speed of your CPU, usually by adjusting the bus and multiplier values.
Some or none of these things might work, but you must make sure you make only one small change per boot, and that you monitor those changes using Lm-sensors from your desktop.
13. Improve network performance
Linux has supported IPv6 for some time, but if you're not using it, disabling it can speed up some network activities. The easiest way of making this configuration change is through the network manager daemon.
If you use Gnome, open the network manager applet and edit the connection you're using. On the IPv6 tab, select Ignore as the Method.
If you're using the latest version of KDE, without the network manager daemon, set the KDE_NO_IPV6 environmental variable (export KDE_NO_ IPV6=1), either from the command line, or within your desktop's startup script.
Taking this to extremes, you can stop the IPv6 kernel module being loaded by adding blacklist IPv6 to the end of /etc/modprobe.d/blacklist. You don't need to mess around with your network configuration if you don't want to.
Firefox gives you the option to disable IPv6 from its configuration registry. Type about:config as a URL, and disable \network.dns.disableIPv6.
If you run a small network, you can shave away some network delays by disabling arp in the DHCP daemon and set up static IPs. Add noarp to the /etc/dhcpd.conf configuration file and restart your system or the daemon. Addresses should now be assigned quicker.