How to fix any Linux problem

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 Speedtest.net.

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

ESSID:

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.

How to fix any Linux problem

Wi-Fi Analyzer on Android shows access points in range and which channels they use, so you can set yours to avoid competition

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.

Streaming 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.

How to fix any Linux problem

Get Netflix running by installing Pipelight and telling your browser to pretend that it is running on Windows

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.

How to fix any Linux problem

MTP is the new way of connecting to Android devices, and it means you can keep using the device while it is mounted on your desktop

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 192.168.1.0/24

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.