How to fix any Linux problem
Linux issues begone!
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:
Get daily insight, inspiration and deals in your inbox
Sign up for breaking news, reviews, opinion, top tech deals, and more.
./configure
make
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.