How to fix any Linux problem

Getting started and boot problems

Everyone has a problem with Linux at some point. The important thing is how quickly that problem gets solved. An amazing element of the open source and computing community is the vast network of help available online in the form of blogs, websites and forums.

Getting started and boot problems

Everyone has a problem with Linux at some point. The important thing is how quickly that problem gets solved. An amazing element of the open source and computing community is the vast network of help available online in the form of blogs, websites and forums.

Without doubt this is of huge importance in getting issues known and fixed, and it’s wonderful to see how willing the community is to help out complete strangers and beginners alike. That being said, there’s nothing that beats a bit of prior knowledge.

To help arm you with the knowledge you need to keep your Linux systems cheerfully ticking over, we’ve taken our years of experience answering all manner of reader questions and distilled this into a rich brew of condensed Linux knowledge, which will target the top issues that Linux users regularly run into.

How to fix any Android problem

In many ways computers are this wobbling tower of intertwined standards, protocols, interfaces and files. Considering just how complex a modern Linux system is, it’s astonishing that a Linux PC manages to successfully complete the delicate dance of powering up, launching the bootloader, handing over to the kernel, loading files of its file system, hopping through init and establishing an X graphical interface with interactive graphical desktop manager, wireless internet connection and all the other services that modern systems provide.

At any stage this wobbling tower can crash down – and when it does, we’re here to help you pick up the pieces! Our guide starts at the beginning with troubleshooting the boot process, moving through basic hardware and system issues, then on to more generic hardware, networking and finally classic desktop problems.

Hopefully you’ll come out of the darkness with at least a few invaluable nuggets of Linux knowledge to help make your Linux experience that little bit smoother and even more enjoyable. So lets turn the page and get fixing!

What’s the best Linux distro for beginners?Boot problems

Got boot problems? We tackle the common issues.

Stalled boot

My computer won’t boot. The splash screen comes up and then it just sits there.

The first thing to do is be patient – the boot process may be trying to initialise a piece of hardware, or access the network before it’s available. These can time out after a few minutes, either allowing boot to proceed or at least giving you an error message to work with.

In the good old days, distros used to stream reams of text up the screen as they were booting, until it became fashionable to hide this with a splash screen. Unfortunately, the splash screen also hides any error messages. You can disable the splash screen at the boot menu: if your computer starts booting without showing a menu, hold down Esc when it boots to call up the menu.

If there’s a recovery or safe option, pick that, as it disables the splash screen and often sets safer (if potentially less efficient) boot options. Otherwise, put the highlight on your normal boot option and press E for edit. Find the line that starts with linux and look for options like quiet, splash or theme.

Delete these options and press F10 to continue booting. This won’t fix your problem (unless the problem is the splash screen itself), but it will let you see what is going on and either get an error message or an idea of which stage of the boot is failing at. Then you can investigate further. If it appears to be a hardware detection issue, try disconnecting all unnecessary hardware, such as printers, scanners or USB rocket launchers. Once you can get past the problem, you can start to fix it.

Boot errors

When I boot I see error messages along the lines of

Pci Express Device Error. Severity NN. Uncorrected non Fatal. Pci Bus Error

Type:N Transaction Layer. Flow Control Protocol N:First.

Receiver 1

This is a problem I’m experiencing on a newly bought motherboard that works fine with Windows.

Hardware working with Windows is no indication that it’s fault free. The “It works with Windows, ship it and we’ll fix any other problems with an update” attitude is not uncommon. With anything motherboard related, the first step is to check whether there’s a BIOS update available.

Even with a brand new motherboard, by the time it has travelled through the shipping and distribution process to get from the Far East to your computer’s manufacturer and then to the shop and finally to you, there is usually a new BIOS available.

Flashing a new BIOS can fix a lot of boot problems but if yours persist, there is more you can do. You can change the way the kernel addresses the hardware with a number of parameters you can pass to it at boot time. At the Grub boot menu (press Esc if it does not show up by default), highlight your normal boot option and press E (for edit).

Edit the line starting with kernel by adding some or all of these options to the end of the line, separated by a space:



noapictimer, acpi=off






Note the difference in spelling between the second and third set of options – about all that acpi and apic have in common is the letters in their names. Press F10 to boot with the options you added. Once you find a combination that has the kernel and your hardware co-operating with one another, make the change permanent by adding the options to GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX in /etc/default/grub, saving the file and updating Grub with one of these commands.

Which one depends on your distro – if the first one fails, try the second and then the third.

sudo update-grub2

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

sudo grub2-mkconfig -o /boot/grub/grub.cfg

The best Linux distros: five versions of Linux we recommendRe-installing Windows broke Linux

I installed Linux onto my Windows computer and it gave me the choice of which to use when I turned it on. I recently had to reinstall Windows and now Linux has disappeared.

I don’t want to reinstall Linux as I would lose all my documents and settings. Is there any way to get my Linux back?

Linux uses the Grub bootloader to choose between different boot options, but Windows uses its own bootloader. A bootloader is a small piece of code embedded at the start of your hard drive that kickstarts the process of loading your operating system.

When you installed Windows, it installed its own bootloader, overwriting your existing Grub. Don’t worry, it’s only the bootloader code that’s gone – your Linux system and files are still there, and all you need to do is restore Grub. Some distro install discs have an option to repair the bootloader, or there’s a more generic option in Rescatux.

Boot from the Rescatux CD and select the Restore Grub option. This will search for your Linux partitions and ask you to choose the partition that contains the root filesystem of your Linux installation and then ask which hard disk you want to install Grub on – usually /dev/sda, the first disk. The window may go blank for a worrying amount of time but do not panic or reboot: wait until it tells you Grub was re-installed before rebooting, and you should then get your old boot menu back, with access to your untouched Linux system.

How to install Linux

Dual-booting more than one distro

I know I can dual-boot between Linux and Windows, but can I do the same with more than one Linux distro? If so, how do I share my data between them? How should I partition my disk?

Yes, it is possible. Each distro needs its own root partition but you can share the same swap between them all. Having a separate partition for /home is recommended – you don’t want to tie your data to a single distro you may later decide to stop using.

While a separate /home partition is desirable, don’t use the same home directory for each distro as there may be incompatibilities between different versions of the software used. I prefer to put the distro name in the username, as in “fred-ubuntu”, “fred-debian”, etc. As long as each user has the same UID – most installers make the first user 1000 – you’ll have write access to all of them, then you can create symlinks for important data directories, like documents, music, photos and so on, to share these files between all distros while keeping the configuration files separate.

As far as the boot menu is concerned, pick one distro as your main one and let that handle booting. Every time you install a new distro, skip the option to install a bootloader if possible. Then reboot into the main one and run:

sudo grub-mkconfig -o /boot/grub/grub.cfg

to update the boot menu.

How to dual-boot Linux and WindowsRemoving a distro broke everything

I deleted Linux partitions from my computer, in preparation for installing something else. Now I cannot boot it. All I get is a message that Grub cannot find files and a prompt saying ‘grub rescue>’. I can’t even boot into Windows.

While the initial boot code for Grub is stored in the Master Boot Record (MBR) at the start of your hard disk, this is a very small space. So the initial Grub code loads files and configuration information from the grub or grub2 directory on your Linux boot partition.

When you removed that partition, you left Grub nowhere to go. If you are planning on installing another distro in the now-empty space, simply run the installer and it will set up Grub for you, detecting your Windows system too, and all will be well after a reboot.

If you are using the space for an existing Windows or Linux installation, you need to either set up Grub for the other Linux system or reinstall the Windows bootloader. The easiest way to reset Grub is use the Restore Grub option on the Rescatux live CD – choose the Linux installation you want to be responsible for holding the Grub files.

Restoring the Windows bootloader involves booting the Windows disc (or rescue partition) and running one of these commands, depending on the Windows version. For Windows XP it’s the following:



For Windows Vista and Windows 7, Windows 8 and Windows 10 it’s:

bootrec /fixboot

bootrec /fixmbr

bootrec /rebuildbcd

When your computer won’t even boot, a live CD is a godsend, so it pays to always have one handy. A live CD is a complete Linux environment that boots from a CD and needs no installation, or even access to a hard drive.

Apart from being very handy for being used as a portable distro or as a sampler to try a different distro without installing it, a live CD is ideal for a rescue system. There are some dedicated rescue CDs, such as System Rescue CD, Rescatux and Grml, but most distro installer discs nowadays boot into a live environment that contains enough software to fix many problems.

For more solutions to Linux boot problems, check out our guides on how to repair Ubuntu if it won’t boot.

Linux hardware problems
Finding hardware drivers

Where do I get drivers for my hardware? The accompanying disc includes Windows drivers only.

Most hardware doesn’t need separate drivers with Linux: the kernel includes drivers for a massive range of hardware.

Nine times out of ten, the kernel recognises the hardware when you plug it in and loads the appropriate driver without any input from you. Some hardware does have separate drivers, often because they use proprietary code that cannot be included with the kernel.

In such cases, a live CD, such as Knoppix or System Rescue CD, will often recognise the device – these tend to include a lot of extra drivers. If the hardware is an internal device, it will usually show up in the output from lspci, and adding the -k option shows which driver is being used.

Once you know that, you can search for which package provides that driver, either using your package manager or a web search. If it’s in a standard package that’s not installed by default, as is the case with many wireless drivers, installing the package should be all you need to get the hardware working.

The process is similar with USB devices except you use the lsusb command, and there is no handy -k equivalent.

Note that on some systems, these can only be run as root. If there’s no driver support by your kernel or package manager, you have to enter the murky waters of downloading and installing drivers directly from a manufacturer’s website.

If they provide a Deb or RPM package suitable for your system, this isn’t too bad. Otherwise, make sure you get the right driver for your architecture and follow the installation instructions carefully. Drivers have to be linked into the kernel, so you will probably need the kernel source and build-essentialpackages installed.

Random crashes

My computer is suffering from random crashes and lockups – it doesn’t seem to be related to any particular piece of software.

This may well be a hardware issue and there are a number of common causes. Faulty memory can cause this and, because of the way Linux makes use of all available memory, is more likely to do so in Linux that Windows.

Boot from a live CD and select Memtest from the menu. Let this run for at least a couple of passes, preferably overnight. Overheating is also a common cause: try running a system monitor or Taskbar applet that shows your system temperature.

Make sure all vents are clear and, if you are comfortable with taking a screwdriver to your case, check that your CPU heatsink and fan are not clogged with dust. A third cause, for desktop computers, is a substandard power supply.

Cheap units can often fail gradually, giving just this sort of behaviour and damaging other components on their way down. The only reliable test is to try a different PSU.

Printer problems

My distribution hasn’t spotted my printer. How do I install the drivers?

How you install drivers – or even if there are any available – depends on your printer. The first place to go is The Linux Foundation’s website to check their database. If you do this before buying a printer, it will save you a lot of trouble.

Enter the make and model of printer and their database will tell you if it is supported, and which drivers to use. CUPS, the printing system used by Linux, comes with many drivers, so there’s often no need to install anything. There are further drivers in the gutenprint package.

HP provides open source drivers for its printers, so if you have an HP model, install the hplip package to make all HP printer and scanner drivers available.

Other manufacturers provide closed source binary packages. Check whether your distro supplies these as a package, or otherwise, as a last resort, you will need to download and install them by following the instructions on the printer manufacturer’s website.

Once you have the proper drivers installed, you can set up the printer using either your distribution’s printer administration tool or the CUPS web interface. To use the latter, which will work on any distro, point your browser at https://localhost:631, log in if asked, click on the Administration tab, then Add Printer and follow the prompts, bearing in mind the information you already have about the best driver to use.

The solid option

I’d like to replace my hard drive with an SSD. How do I set it up and is there anything I need to be careful of? I’m thinking about the problems caused by writing to flash memory too often. What about TRIM?

There isn’t much different to be done with setting up an SSD compared with a spinning drive these days. Disk partitioning tools default to values that are safe for both types of drive now.

Most of the data around now suggests that an SSD is capable of outlasting a spinning drive. However, it won’t hurt to add noatime to your mount options in /etc/fstab, if you don’t already: it gives a speed boost too.

You have a couple of options for copying the data. You could back up your home directory and do a fresh installation on the SSD, or you could copy everything across.

You should boot from a live CD to do this, and use a SATA to USB adaptor if you don’t have a spare SATA port. Mount each partition, apart from swap, in both drives, and use rsync to copy everything across for each partition:

rsync -a /mnt/old_partition/ /mnt/new_partition/

You’ll also need to reinstall Grub to the bootloader, by booting something like Rescatux with only the new drive in the computer. TRIM, cleaning up no-longer-used areas of the storage, can be done in two ways. The easiest is to add relatime,discard to the mount options in /etc/fstab.

The only drawback, however, is that this can slow the drive down while trim operations are ongoing, so many prefer to run fstrim when the computer is lightly loaded. A Cron task that runs fstrim –all once a week should be enough for most usage. The –all option trims all filesystems that support it and silently ignores others. Add the –verbose option and Cron will mail you a summary of what was done.

Deleting files for real

I would like to make sure my hard drive is completely wiped before disposing of it. I understand that simply deleting all files is not enough, so what should I do to clear all trace of my data from the drive?

It depends on how you intend to dispose of the drive. If you are throwing it away, a large hammer is pretty terminal to your data, but there are more sophisticated – if decidedly less satisfying – ways of securely clearing a drive, methods that also leave the drive in a state suitable for resale.

You are right in thinking that deleting files isn’t enough, as that only removes their entries from the directory table, and the data is still there. You need to overwrite all the data on the drive. Conventional wisdom states that you need to do this several times, overwriting with different patterns, or random data, to prevent even the most determined of data recovery attempts. For most purposes, overwriting the drive with zeroes will do:

sudo dd if=/dev/zero of=/dev/sdb bs=4k

This cannot be run on the system drive, so if that’s the one that you wish to wipe, you’ll need to run the command from a live CD instead. You can give yourself further peace of mind by adding in some random data, by using /dev/urandom instead of /dev/zero.

Be aware that the dd command doesn’t ask if you are sure or double-check to see if you’ve given it the right device before pressing Enter – there are no second chances here.

If you still want to go down the route of multiple overwrites for peace of mind, try the Darik’s Boot and Nuke (DBAN) live CD which is the next most effective thing to that large hammer you’re waving about.

Linux system issues
Drive filling up

I am running out of space on my hard drive – the space just seems to be disappearing. Where did it go and how can I get it back?

If you have more than one partition, the first step is to see which is affected, with the df command:

df -h

This shows the total, used and available space on each partition. If you have a separate /home, you now know whether it’s your home directory or the system root that’s filling up.

The steps taken are the same in each case, although you need to be root to clean up the system directories. For the system files, the usual culprits are /tmp and /var.

The first is used for temporary files, but sometimes old files get left in here, especially when processes fail without cleaning up. /var/log contains system log files and can fill up, particularly if a process is logging lots of errors. Look at the contents of any large files in here before you deal with them.

It’s worth installing logrotate, which keeps your log files under control. Its default setup starts a new log file each week and compresses the last one, keeping the last four weeks of logs.

This can save a huge amount of space. In your home directory, check your downloads folder, your browser and mailer caches and also the .cache directory. You can use du to check the sizes of directories:

du -sh * | sort -h

lists everything in size order. If you want to check on hidden directories, use:

du -sh .[0-9a-z]* | sort -h

There are also graphical tools to visualise disk usage – Filelight for KDE and Disk Usage Analyser for Gnome – while Bleachbit is good for identifying and cleaning up unnecessary files, like browser caches and other temporary files.

How to extend the life of your hard driveWhere has all my memory gone?

I have noticed that after running Linux for a while, I’ve hardly any memory left. Where is it going? How can I find the culprit and what can I do about it?

This is actually perfectly normal and the way Linux is designed to work. Free memory is memory that’s doing nothing when it could be helping the performance of your computer.

The Linux kernel allocates memory that isn’t in active use by processes to things, such as filesystem caches in order to improve performance. You can see this by looking at the output from free -h.

On a computer fitted with 16GB of physical memory, only 128MB is reported as free. Of the memory in use, 13GB of it is in use as buffers. These greatly speed up disk access by caching written data in memory and reading in more than you need in anticipation of your next read.

If this memory is needed for anything more important, it will be released immediately. It’s not just filesystem data that remains in memory – try checking your free memory, then starting and stopping a large program like Firefox and you will see that your free memory decreases.

Now start Firefox again and see how much quicker it starts the second time. This is because the kernel keeps data in memory ready for the next use. The same applies to shared libraries, which is one reason why sticking to programs from one desktop environment can be faster than running a mixture, especially with limited memory.

Moving home

I have heard that it’s better to have my home directory on a separate partition. Why is this and how do I do it?

First of all, it’s not normally your individual home directory that has its own filesystem but the complete /home directory, in which your home resides. There are a number of reasons for doing this, such as simplifying backup procedures, but the main reason is to keep your data, and that of any other users, separate from the operating system.

That means you can upgrade or even replace your OS and still keep all your personal settings and data.

The simplest way to do it is with Gparted and a separate hard drive. Make sure the hard drive is formatted with a Linux filesystem, to preserve all the information saved with your files, then use rsync to copy everything over.

sudo mkdir /media/extdrive/home/

sudo rsync -a –delete /home/ /media/extdrive/

This assumes your separate drive is mounted at /media/extdrive. The trailing slashes are important. There are other tools you can use for the copy, but rsync has the advantage that it can carry on where it left off if the process is interrupted.

This means you can carry on using your PC while you do this, then boot from a live CD and repeat the process to update the files altered while you were using the system.

A live CD is needed for the next stage, where you delete the contents of /home and use Gparted to resize the root partition to a reasonable size – 20GB should be enough, but make it around 50% larger than the space currently used.

Now create a new partition after the root partition and format it, using ext4 unless you have a reason to do otherwise. Load the /etc/fstab file from the root partition into an editor and add an extra line:

/dev/sdaN /home ext4 defaults,noatime 0 0

where sdaN is the partition you just created. Finally, copy the data back from the external drive into the new /home and reboot. It is possible to do this without access to an external drive, but it is a more fiddly process.

Universally Unreadable IDs

I find the use of UUIDs in /etc/fstab annoying. What’s wrong with the old method of using the device nodes, like /dev/sda1, and can I change back?

The trouble with device nodes is that they can change. If you add or remove a drive, including USB flash drives, or change the BIOS boot order, sda can become sdb. UUIDs on the other hand are (fairly) unique; it doesn’t matter if the drive order changes, that unfriendly string stays the same.

And that’s the problem: UUIDs are good for computers as they give a simple, reliable identification, but they are not human-friendly. A compromise is to use filesystem labels. If your root partition is on /dev/sda1 you could run

sudo e2label /dev/sda1 root

Then change the device specification in /etc/fstab from “UUID=youllneverreadorrememberthis” to “LABEL=root”. Unlike many operation on the root filesystem, this one is safe to perform on a running system. It will take effect when you reboot. If you are ever likely to move drives between computers, use less generic label than ‘root’.

Hard drive copying

How do I clone a complete hard drive? I am using Ubuntu but the drive also contains Windows.

Cloning a drive that the system is running on is a risky proposition. The OS could, and probably will, change files on the drive as you are trying to clone it. The simplest and safest way of doing this is with Clonezilla, a dedicated live CD distro.

Burn the ISO to a CD and boot from it. Then use the menus in Clonezilla to make a clone of your hard drive, either directly to another drive or to an image file.

How to take a system image of your computerLinux software glitches
Installing software

I’m new to Linux and cannot see how to install software. On Windows, I go to the program’s website, download an .exe and run it. What do I do?

Software installation works differently in Linux. Programs are generally provided as source code and the individual distros create program packages from this. That means you know the program is compatible with the rest of the software from your distro.

It also means you use the distro itself to install. Look for a program called Software Manager or similar: this will let you search for and install any software you need. It will also take care of any dependencies (other programs needed by the one you are installing) and notify you when updates are available. There is no need for you to check back on web pages or for programs to ‘phone home’.

Use the source

I want to install a program but there’s no package for my distro and the program’s website only provides source code. How do I install it?

The precise method varies from one program to another. The first step is always to unpack the tarball or ZIP file and look for a file called Readme, Install or similar.

This will explain how to install the software. For 90% of projects, the standard autotools system is used, which requires three commands to build and install the software.

These must be run from inside the directory created when you unpacked the tarball:



sudo make install

The first command checks that your system has all the required dependencies and sets up the build environment to suit your system. The second compiles the source code into programs to run on your computer, and the third command installs those programs to the correct locations and handles any final configuration.

You need a standard build environment installed to do this. Most distros have a package called build-essentials, or something similar, that installs everything you need to build and install programs from source.

Don’t throw away the source directory after installation. If you want to remove the software at a later date, go back in there and run:

sudo make uninstall

No DVD drive

I have an ISO image that I can burn to a CD/DVD, but I want to use it with a slimline laptop with no DVD drive. Can I use a USB stick instead?

You can do this. The exact approach depends on the type of ISO image. Some distros now release what are called hybrid ISO images that work with either medium. You copy them to a DVD using whatever DVD burning software you prefer, or you can copy the file to a USB stick with dd

sudo dd if=distro.iso of=/dev/sdb bs=4k

where if is the file to copy and of is the destination (bs=4k speeds up the process quite dramatically, but isn’t compulsory).

Warning: dd does exactly what you tell it to, with no ‘are you sure’ niceties/annoyances, so make sure you have the correct destination drive.

How do you know you have a hybrid ISO? The distro’s website may well say so, but you can test with fdisk:

sudo fdisk -l distro.iso

If the line under the Device line includes the name of the ISO image, you have a hybrid. If you don’t, you can convert it with isohybrid. You may need to install the syslinux package first, then run:

isohybrid distro.iso

Now fdisk should show it as a hybrid and you can dd it to your USB stick.

Go slow

My computer seems to be running with one of its CPU cores tied behind its back. What is going on?

The most likely cause is that a particular process is hogging a lot of your resources, and the program to investigate this is called top. Run it in a terminal and it will show you a summary of overall system usage and a list of programs in order of their CPU usage.

The third line will show you the overall CPU usages, which will be something like this (on a lightly loaded system):

%Cpu(s): 0.7 us, 0.2 sy, 0.0 ni, 99.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

The first three figures show how much of your CPU capacity is being used for user, system and nice tasks. A nice task is one running at a lower priority, so it uses the CPU only when nothing else wants it.

The fourth figure is ‘idle’ – the amount of CPU time not being used. If this is close to zero, you now know why your computer is running slowly – look at the list of tasks to see which is eating the most CPU time.

If you have a multi-core CPU, pressing 1 switches between showing an overall usage and separate figures for each core. That wa (waiting) figure is also significant: it shows how much time the CPU is waiting for I/O and can be high on disk intensive operations.

If it is routinely high, you may have a disk problem – either read errors or a nearly full filesystem that has become heavily fragmented. Look at the memory line. If memory is full and swap is in use, you will lose performance. The task list is ordered by CPU usage, but you can press F to pop up a list of fields. Move the cursor over the field you want to sort on and press S followed by Q. It sounds fiddly but the window opened by F allows for a lot more than changing sort orders. If memory is low, this will help you find the greedy programs.

Lost password

I reinstalled Linux recently and thought I kept the same password, but I cannot log in with it. Is there a way I can find or reset my password?

You can reset your password by booting from a live CD/DVD – either a specific rescue disc like System Rescue CD or your distro’s own disc. The first step is to identify the partition where your distro is installed (this is the root filesystem for the distro; your home directory is not needed).

If you have booted to a graphical desktop, you can browse the available drives, looking at those of a suitable size until you find the one that contains directories such as bin, etc and lib.

Once you have the correct partition mounted, say in/mnt/myroot, you can use chroot to fix it:

sudo chroot /mnt/myroot /bin/bash

This changes the root directory to the path you give and runs the command following. So this switches you to the root of your installed system and runs the Bash shell as root.

You are now inside your installation and can change your password with:

passwd yourusername

It will ask you for the new password twice and then write it to disk. Press Ctrl-D to exit the chroot, reboot from your hard disk and you should now be able to log in.

Killing windows

I run some bleeding edge versions of software and occasionally they crash, leaving the window still open. How do I close a window and program like this so that I can run it again?

For graphical programs, the simplest answer is xkill, which is usually installed by default. When you run xkill, your mouse pointer changes to a skull-and-crossbones, the next window you click on will be forcibly closed, along with its program, so be careful where you click.

There are also command line alternatives. kill takes a process ID as an argument and kills it. Killall does the same but works with program names, so be careful if you may have more than one copy of the program running.

Both send a TERM signal by default, which asks the program to shut down cleanly. If this fails, add -KILL to the arguments to send the more forceful KILL signal:

killall -KILL someprogram

If you want to use kill, there are various ways to find the PID. If the process is using a lot of CPU or memory it will show up in top, and you can kill it from there by pressing K. Otherwise, use pgrep:

pgrep -fl programname

The -fl options mean you see the full command line, so you can be sure you are killing the right process.

Linux internet issues
Going slower

My Internet connection seems really slow – downloading files takes forever. Do I need to fix this in Linux or change my router’s settings?

Stay away from your router settings until you have tried everything else – you could end up breaking a fully working setup. The first step is to check that it really is slow, by using a service like

Next, check that nothing is sucking up your bandwidth in the background. A good program for this is nethogs, which you may have to install from your package manager:

sudo nethogs eth0

This gives a top-like display of what’s using your bandwidth. If you’re connecting to your router by wireless, try a wired connection to rule out Wi-Fi issues. If that makes a difference, try testing in different locations. There’s also the possibility of congestion with other wireless routers from your neighbours, which can be avoided by switching your router to a different wireless channel.

You can see the wireless channels in use with this command

sudo iwlist wlan0 scan | grep -e Address: -e Channel: -e


Iwlist produces a lot of output about each access point it discovers, hence the need to filter it with grep. You can also use something like Wi-Fi Analyser on Android, which gives a graphical display of the channel and strength of all access points in range, enabling you to map any points where the signal from your router is weak as well as identifying competition for bandwidth.

There’s also the highly scientific test of picking up the phone: if the line is noisy, you will suffer reduced speeds and you’ll need to report the problem to your line provider. If all the above checks show nothing, check with your ISP before tampering with previously working router settings.

How to get super-fast Wi-Fi in every roomStreaming video

When I try to watch videos on Amazon Prime or Netflix (I have accounts with both) I get a message saying my computer is unsupported. Can I fool them into thinking I am running Windows? Will that let me watch the services I have paid for?

These services use Silverlight, a proprietary technology from Microsoft, to render the video and apply DRM. There’s no Silverlight for Linux but there’s a solution called Pipelight, which is a browser plugin that in turn uses Wine to run Silverlight.

It requires a patched Wine but all the packages you need are available for most distros. Users of Ubuntu-based distros can add a PPA and install everything with:

sudo add-apt-repository ppa:pipelight/stable

sudo apt-get update

sudo apt-get install pipelight-multi

This adds the Pipelight PPA and then installs the software. Instructions for other distributions can be found at the Pipelight website. Set it up with:

sudo pipelight-plugin –create-mozilla-plugins

pipelight-plugin –enable silverlight

This will download the required Silverlight software and set up plugins for your browser. Installing Pipelight isn’t enough to watch your videos; you will still be denied access because your browser tells the website you are running Linux. Install one of the User-Agent control extensions for your browser: such as user-agent-overrider or uacontrol on Firefox or useragent-switcher-for-chrome if you use Chrome.

Then use it to set your User Agent to “Firefox for Windows” and enjoy your streaming video.

Mounting Android

I have bought myself a Nexus 7 Android tablet and I’m very pleased with it. But – there’s always a but, isn’t there? – I can’t mount it as a USB device. My Android phone pops up a dialog when I plug it into the USB port of my computer and lets me mount it as a storage device, but this tablet doesn’t seem to work like that. Why have they got rid of a perfectly reasonable system and how do I get my files on there now?

The trouble with the USB storage system is that a filesystem can be mounted by only one OS at a time. That means that before you can mount it on your computer as a mass storage device, it has to be unmounted on the phone/tablet.

That’s why you get the warning message on your phone about apps that use the SD card having to be stopped. It’s even worse on something like the Nexus 7, where there’s no removable storage – you can’t unmount a filesystem currently in use by the OS.

Newer Android devices avoid this by using MTP (Media Transfer Protocol). There are a few options for mounting MTP devices under Linux, all implemented as FUSE filesystems. We prefer jmtpfs. To mount the first device found – you would normally only have one connected at a time – pass jmtpfs the name of the mount point.

This directory must exist and be writable by the user running the command:

jmtpfs /nexus

Then you can access the contents of the device while still using it. When you have finished, unmount the device with:

fusermount -u /nexus

Remote desktops

I want to be able to access the desktop of one computer from another, like the remote desktop feature of Windows.

You have two options here. For a complete desktop you can use VNC. This is often installed by default; if not, install either the TightVNC or VNC package (the former should give better speed on slower networks). You run the server on the computer you want to view; the first time you will be asked to set up a password.

Then run the client on the other computer, giving it the address of the first computer. However, if you only want to run a single program from the remote computer on your local desktop, VNC can be overkill and the X display of Linux already allows network forwarding.

You need to set up SSH on the remote computer – just install the ssh-server package in the usual way. Then test that you can connect from the local computer with:

ssh user@hostname

This will ask for your password and then give you a shell session on the remote computer – you can check you are on the remote computer by running uname -a. Press Ctrl + D to log out, then try running a graphical program like this:

ssh -Y user@hostname someprogram

It should open its window in front of you. Depending on how your distro set up its SSH server, you may find -X is better than -Y. If neither works, check /etc/ssh/sshd_config on the computer running the server and make sure it contains

X11Forwarding yes

Incidentally, if you are using the same username on both computers, you can leave that out and just do

ssh -Y hostname progname

What’s my address?

I’ve got a Raspberry Pi, which I’m running without keyboard or screen. I plugged it into my network but I don’t know what its IP address is, so can’t SSH into it.

If your device is getting its IP address from a DHCP server, you can often configure the server to give a specific address to a hostname. Plug the Raspberry Pi‘s SD card into your computer and edit /etc/hostname on it to set your hostname, then set your DHCP server, usually in your router, to give that hostname a set address.

Alternatively, install netdiscover and run it like this:

sudo netdiscover -i eth0 -r

where -i is your network interface and -r the IP range used by your network. This will list all the hosts on your network. Unfortunately the Raspberry Pi shows up only as ‘Unknown vendor’, so run it with and without the Raspberry Pi to see the address that appears.

If you have an Android device, install Fing, which does the same thing graphically and recognises the Raspberry Pi. Once you have the address, you can SSH in and run ipconfig to get the MAC address, which you can use to tell your DHCP server which address to give it.

Raspbian prints the IP address from /etc/rc.local when it boots. You could modify this to email you instead.

Check out our collection of fantastic Raspberry Pi projectsLinux desktop problems
No blinking desktop

I applied some system updates as notified by my Ubuntu desktop. After the next reboot I was faced with a black screen, a login prompt, a blinking cursor and nothing else. I could log in as my user, but there was still no desktop.

This happened because the system update installed a new kernel, which became the default when you rebooted. If you are using a graphics card with third party drivers, such as Nvidia, you have to reinstall the drivers before you can get your desktop back.

If you installed the drivers through the Software Center, it should have taken care of the reinstallation, but if you installed the drivers manually it became your responsibility, and graphics card drivers need a kernel module to function.

If you use an open source driver, the module is included with the kernel, so the process of switching kernels is transparent. With the binary drivers, the module is compiled and installed by the driver installer, so you have to redo this for a new kernel.

The good news is that you can reboot, select your previous kernel from the boot menu and your desktop will be back. Then you can install the drivers again, in the same way you did last time.

User error, replace user

Program XYZ has started misbehaving, no longer acting as it used to. I have tried reinstalling it but it makes no difference.

Have you recently updated the program or one of the libraries it uses? Look at your package manager’s log files so see what has been installed recently (users of Ubuntu or Debian-based distros can look in /var/log/apt/history.log).

If it has not been changed, this is most likely a configuration issue. Reinstalling a package does not affect the users’ settings, stored somewhere in your home directory. The easiest way to test this is to create a new user, log in as them and try the same software, which will take you back to a default configuration.

If the problem disappears, it is an issue with your configuration. The next step is to find where the program stores its configuration. KDE programs store settings in /.kde4/share/config, but most other programs use .config, .local or write their configuration files directory in your home directory.

An easy way to find files modified by a program is to use the find command. First create a file with the current time stamp

touch /now

Then run your program, make a config change and exit it. Now you can find any files in your home directory that were changed with

find -newer /now

Once you’ve found the configuration file or directory for the offending program, you’ll need to rename it and run the program again to return to a standard setup. Remember the idea of creating a new user with no settings – it can save you a lot of time in the future.

Login refused

I’ve had repeated problems trying to get Ubuntu to accept my password, which I know is correct. Originally I had set automatic install but nevertheless was presented with the login screen but my password was not accepted. If I booted into recovery mode my same password was OK!

The problem is not with your password; otherwise you would not be able to log into the recovery console either. Something else is preventing you from logging into the desktop, which is why you see the login window even though you have auto-login turned on. It tries to log you in, fails and returns to the login screen.

This is usually caused by incorrect ownership on files the desktop needs to write to. You may have inadvertently made a critical file owned by root, usually as a result of trying to fix something else.

Boot into recovery again and log in as the affected user, then run this command to reset ownership of all files in your home directory back to you.

sudo chown -R ${USER}:

The chown command is used to CHange OWNership of files. The -R option tells it to recursively change all files below the given path. The environment variable ${USER} is expanded to your user name (this is why you need to be logged in as the affected user for it to work). The colon (:) following the user name instructs chown to also change the group ownership to the default group for that user.

Finally, the shell expands to the path to your home directory. You need to run it with sudo as you need root permissions to change ownership of anything that does not belong to you, and those are the files we are interested in. If it still fails, check .xsession-errors in your home directory.

Device locked

When I try to eject a DVD or remove a USB flash drive, it sometimes refuses to do so, along with a message along the lines of “Operation failed: device in use”. How do I get around this without rebooting, which does seem to work?

Some program somewhere has a lock on a file or directory on the filesystem you want to unmount, so the operating system is refusing to do what you want.

The lsof command lists all open files, including directories and device nodes. By passing its output through grep, you can find the guilty process, for example:

# lsof | grep /media/cdrom

bash 15243 nelz cwd DIR 11,0 6144 1856 /media/


This shows that Bash, running under my user, has cwd locked on that directory. cwd is Change Working Directory – in other words I have a shell open that is displaying the CD’s directory. Simply issuing a cd command in that shell, to switch back to my home directory, will release the lock and let me unmount the CD.

Once you know which program is locking the device, you can deal with it. An alternative command is fuser, which simply returns the process ID of the program locking the file:

# fuser /media/cdrom

/media/cdrom: 15243c

You’ll see it is the same PID as given by lsof. This may look less useful, and indeed it is in this case, because I only need to find the shell and change directories, but fuser has a trick up its sleeve. Using

fuser -k /media/cdrom

will find the PID and send it a KILL signal, terminating the program immediately and releasing the lock, which is useful if a crashed program has left a lock on the device. This is safer than removing the device without unmounting, which can cause data loss.

Where’s that file?

I don’t know if it’s my age or what, but I have a habit of saving files and then forgetting where I saved them, leaving me with the prospect of trawling through many gigabytes of files in my home directory. Is there any help for the terminally forgetful?

Apart from things like KDE’s semantic desktop, which indexes all files you create, there are some general options. The first is find, which (surprise!) locates files based on various criteria. For example, if you know roughly when you saved the file, you can use -mtime to search on the last modified time stamp of the file:

find -type f -mtime 0

find /documents -type f -mtime +7 -mtime -14

The first finds all files in your home directory modified in the last 24 hours; the second looks in your documents directory for files more than a week but less than two weeks old. We need -type f to stop it matching on directories.

You can also match on file names to look for spreadsheets modified in the last week:

find -mtime -7 -name ‘*.ods’

If it is a text file and you know some of the file’s contents, you can use grep:

grep -rI “some text”

This is a lot slower because it has to read every file, so try to narrow it down. The -r option searches recursively while -I tells grep to ignore binary files. There are also graphical find commands with most desktops, but what they cannot do is combine find and grep, such as

grep -I “some text” $(find -type f -mtime 0)

This runs find to generate a list of files, then passes them to grep for searching.

Enjoyed this article? Expand your knowledge of Linux, get more from your code, and discover the latest open source developments inside Linux Format. Read our sampler today and take advantage of the offer inside.

Leave a Reply

Your email address will not be published. Required fields are marked *