Welcome back to my Beginner’s Linux tutorial series and today I’m going back to the subject of software installation. A while ago I looked at compiling software from source, but this time I’m going to look at installing RPM packages.
Note that this tutorial is specific to distributions that use the RPM package format. That is most distributions (SUSE, Fedora, Mandriva etc.) , but there are a few very notable exceptions including Ubuntu, MEPIS and anything else Debian-based. For those distros, a completely different packaging format and set of tools is used, so I might cover that in a future tutorial.
Just before we get into things, if you’re a complete newbie, I’d recommend reading my Linux Explained tutorial at Gizbuzz and my basic introduction into files and folders here to get you started with some of the concepts (I’m jumping in quite quickly to terminal stuff, so you need a basic understanding).
Oh, and the ‘consuming packages with yum’ section is weighted towards Fedora users, but the rest is sound advice for any RPM-based distro.
Right, so first of all, what exactly is an RPM package and why can’t I just double-click on it? RPM used to stand for Red Hat Package Manager (it originally debuted in Red Hat Linux) but now is used in so many more distros it’s called RPM Package Manager. Yes, the ‘r’ in RPM stands for RPM. Don’t ask, acronyms like that, are, kind of traditional.
An RPM package contains all the files needed to install your software package, but with any software installation on Linux, your program will most likely rely on other things being installed in order to run. These are dependencies, and, generally, they’re hell to deal with.
Consuming packages with yum
Thankfully, some distributions offer a tool which automatically goes out, resolves those dependencies and grabs everything you need before installing it all for you. Fedora Core includes a brilliant tool called yum which does exactly that (if you’re not on Fedora, bear with me, I’ll go distro-neutral again in a minute).
Provided your desired software is in a yum repository (a collection of packages hosted somewhere online), one command (or even a few clicks) can download and install what you want instantly. Generally, to install some new software on Fedora, your first port of call should be to try installing it via yum. So fire up a terminal program (Applications > System > Terminal on GNOME) and enter the following, making sure you’re connected to the internet.
$ su - Password: [[Enter root password]] # yum install softwarename
If all is well, you will get loads of messages fly about here and there and if your software is in the repository, you’ll be presented with a prompt which tells you how much data needs to be downloaded. Press y, then enter and it will be downloaded (along with anything it needs) and then installed. Now look in the Applications menus and you should find your application waiting for you to use.
95% of the time, this works, if the software you’re installing is 100% open source and is deemed good enough to be included in the repositories. Occasionally, the package might be under a different name (Mozilla Thunderbird, everyone’s favourite email client, is called thunderbird not mozilla-thunderbird for example). So you can do a yum search query to find related things and hopefully find what you are looking for. Also, if you’re package isn’t open source, or it’s new, it might not be at all.
If you’re a bit command-line shy (I don’t blame you), Fedora includes a few graphical tools to ease this process. Fedora Core 5 introduced pirut (pronounced pirate) for installing packages. You can find it from Applications > Add/Remove Software (in GNOME). Older Fedora users can use yumex, which is slightly more powerful (read: geekier) and can be installed by going to the command line only once and typing:
$ su - Password: [[Enter root password]] # yum install yumex
SUSE’s YaST and doing it the rpm -Uvh
If you can’t find it in a repository, aren’t on Fedora, or you just have got your hands on a .rpm and are wondering what to do with it, you can install .rpms the old school way. Note that doing installations this way won’t automatically resolve dependencies for you, so you might end up being a bit stuck when you get cryptic error messages about things resembling libfoobar.so.0.
Anyway, if you’re still game for some installations (most install fairly easily), then read on. Recent distributions might offer a graphical way to install .rpm files, and you might be more comfortable using that.
SUSE, for example, uses YaST to install .rpms, so double-click an RPM, choose Install with YaST and follow the prompts to install. Occasionally YaST decides to reject you and says “package xyz not included on medium”. If that happens, you’ll have to resort to the command line method below (it’s not that bad, really).
Supposedly Fedora has something similar as well, but as that only seems to work in GNOME and I’m running KDE, I can’t test that for you at the moment. Anyone with experience doing this, leave a comment and I’ll update this bit.
Other distros might have friendly ways to install, but we’ll go for the universal, if slightly geeky method here. Download your .rpm file to the desktop for now (it’ll make things easier), or if it’s on disc, copy it to your desktop. Now, fire up your favourite terminal and enter the following.
$ su - [[Enter root password]] # cd /home/yourusername/Desktop # rpm -Uvh nameofsoftware-1.0.0-i386.rpm
Replace yourusername with, well, your username and of course substitute in the name of your package (remember, typing the first few letters and pressing tab usually fills it in for you). If everything goes well, you should get a message saying ‘Preparing’, then a progress bar made out of hash signs (#) until the installation is complete. If that happened, whoo! You’re installed and ready to rock.
If not, you most likely ran into dependency problems. Try using your software manager to search for and install the offending software and try again. Obviously, I can’t cover every possible case here but if you’ve got problems, give me a shout and I might lend a hand if I have time.
So there you are – a quick look at installing .rpms with Fedora’s yum, through SUSE’s YaST on the graphical side and through rpm on the command line side of life.
Anyway, I hope this helped, and if you’ve got any suggestions, had a few problems or you genuinely found this useful, I’d love it if you’d drop a comment on this post, it makes writing these so worthwhile!
And finally, if you’re intrigued as to what -Uvh does, U is the switch to install/upgrade, v gives you status updates (verbose) and h gives you the hash progress bar.