One of the major differences between various Linux distributions is package management. Many times, this is the reason somebody steers away from one distribution to another, because he/she doesn't like the way software is installed or because there is software needed that isn't available in the distro's repositories. If you are a beginner in the Linux world and are wondering about the differences between distributions, this will be a good start. If you've only used one or two distributions for some time and you want to see what's on the other side of the fence, this article also might be for you. Finally, if you need a good comparison and/or a reminder about major PM systems, you'll find something interesting too. You will learn the most important things a user expects from a PM system, like install/uninstall, search and other advanced options. We don't expect some special knowledge on your part, just some general Linux concepts.
We chose as terms for the comparison some popular systems from popular distributions, and those will be dpkg/apt*, rpm/yum, pacman and Portage. The first is used in Debian-based systems, rpm is used in Fedora, OpenSUSE or Mandriva, but yum is Fedora/Red Hat only, so we will focus on that.Gentoo is a source-based distribution, you will be able to see how things are done both in binary and source distributions, for a more complete comparison. Bear in mind that we will talk about the higher-level interfaces to package management, e.g. yum instead of rpm or apt* instead of dpkg, but we will not cover graphical tools like Synaptic, because we feel that the CLI tools are more powerful and usable in any environment, be it graphical or console-only.
Actually, apt should be capitalized, since it's an acronym that stands for Advanced Packaging Tool, but since the actual utilities are lowercase-only, we will refer to them like that. The apt family is a frontend to dpkg in the Debian family of Linux operating systems, and also used in some OpenSolaris offshoots. Some of these applications are apt-get, apt-cache, apt-cdrom or apt-file. This is not a comprehensive list, but all the more often used utilities are there. There's also aptitude, which, when invoked without arguments, presents a nice menu , either curses-based or GTK-based, but can be used with commands/arguments like the apt-* commands to manage software on your computer. It might be worth noting that various Debian-derivatives might have changed some things in these applications, but this part will treat the tools that are to be found in a standard Debian system.
Since it's Debian vanilla we're talking about, I would recommend aptitude instead of apt-*. But there would be others that would recommend the opposite. We suggest you try them both and see what you like most. There aren't many differences between the two if you're a beginner with Debian or derivatives, but in time you will notice you will prefer one of them.We will show you how to use both, however, so you'll find it easier to choose.
Installing software is simple, all you have to do is
# apt-get install $software
or, is you choose aptitude,
# aptitude install $software
If you get some messages telling you that the software you want is not found, make sure you've updated your package index with the update command:
# apt-get update
# aptitude update
We don't wanna waste space here, so unless specified, the commands are the same for apt-get and aptitude. Speaking of aptitude, here's how it looks when invoked with no arguments:
We invite you to play a bit with aptitude, curses-version or not, to see all the commands available and what options you have.
Unlike other PM systems, the apt family requires two steps to update the software installed on your system, of which the first one we've shown already. This is considered an advantage by the proponents and a waste of time by the naysayers, who think that a single command would have been easier (like yum's update command). We, as usual, don't take sides and recommend you to create your own opinion. So, without further ado, here's how one updates a Debian system:
# apt-get update && apt-get upgrade
Now, here comes the tricky part: there is also a dist-upgrade command, and aptitude also supports full-upgrade, which are different from the upgrade command in that they are more intelligent and more, let's say invasive, in that they will, for example, remove old packages when important upgrades are available. That also depends on what kind of Debian you're running. On a stable system you can live with the upgrade command peacefully, but on a mixed testing/unstable system we recommend dist-upgrade.
You don't know the exact name of the package you want to install? You can either install bash-completion and do "aptitude install $first_letters + Tab" or you can use the search functions offered by the apt tools. You can do
$ apt-cache search $search_term
or, with aptitude,
$ aptitude search $search_term
Again, make sure you ran an update beforehand so the package manager knows what's available.
aptitude, as well as apt-get, supports the remove and the purge commands for getting rid of installed software. While remove supports the basic function of uninstallation, purge takes this a step further and also deletes the configuration files specific to the package(s) being removed. It's up to you, the user, to decide on a case-to-case basis when to use remove and when to use purge, depending on the task at hand.
Some of you may remember the dark old days of RPM dependency hell. Well, now, thanks to yum, those days are a thing of the past and software installation became simpler. Just like the other package managers, yum supports basic functions like installing or removing software, plus a bunch of other useful options.
The basic commands for software management are more or less the same as the ones we talked about above, in the Debian part. So, if, for example, you want to install jed, the text editor, just do
# yum install jed Loaded plugins: auto-update-debuginfo, langpacks, presto, refresh-packagekit Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package jed.i686 0:0.99.19-3.fc15 will be installed --> Processing Dependency: slang-slsh for package: jed-0.99.19-3.fc15.i686 --> Running transaction check ---> Package slang-slsh.i686 0:2.2.4-1.fc16 will be installed --> Processing Dependency: libonig.so.2 for package: slang-slsh-2.2.4-1.fc16.i686 --> Running transaction check ---> Package oniguruma.i686 0:5.9.2-2.fc15 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: jed i686 0.99.19-3.fc15 fedora 795 k Installing for dependencies: oniguruma i686 5.9.2-2.fc15 fedora 125 k slang-slsh i686 2.2.4-1.fc16 fedora 165 k Transaction Summary ================================================================================ Install 3 Packages Total download size: 1.1 M Installed size: 1.1 M Is this ok [y/N]: y Downloading Packages: (1/3): jed-0.99.19-3.fc15.i686.rpm | 795 kB 00:02 (2/3): oniguruma-5.9.2-2.fc15.i686.rpm | 125 kB 00:00 (3/3): slang-slsh-2.2.4-1.fc16.i686.rpm | 165 kB 00:00 -------------------------------------------------------------------------------- Total 268 kB/s | 1.1 MB 00:04 Running Transaction Check Running Transaction Test Transaction Test Succeeded Running Transaction Installing : oniguruma-5.9.2-2.fc15.i686 1/3 Installing : slang-slsh-2.2.4-1.fc16.i686 2/3 Installing : jed-0.99.19-3.fc15.i686 3/3 Installed: jed.i686 0:0.99.19-3.fc15 Dependency Installed: oniguruma.i686 0:5.9.2-2.fc15 slang-slsh.i686 0:2.2.4-1.fc16 Complete!
This is how the complete output looks like on my Fedora 16 machine. yum also supports the localinstall command, which is very useful if you have a RPM package downloaded locally and you want to install it. We recommend the use of localinstall versus "rpm -i $package" because the package gets added to the yum database so you have a less chaotic environment.
As said before, the commands are pretty similar to some extent, but with yum you don't have two separate commands like you have with apt*. So a simple "yum update" will update the repository data and proceed to the update proper if newer versions of software is found. You can see if there's something new by using the check-update command, which is close to "aptitude update" as it updates the repo data but doesn't do anything else.
Until recently I didn't like yum's search command because it yielded too many results, some quite unrelated to what I wanted. It seems that there were others with the same problems, so the developers changed the search function to print only relevant results, and added the "search all" command to emulate the old behavior.
If I want to remove software, of course the command is "yum remove". This will remove the package and its dependencies. Should you want not to go that route, that is you want to keep the dependencies (we recommend great care here), you should type
# yum --nodeps remove jed
The yum wiki says this about --nodeps so again, be careful: "--nodeps is only used when a package or system is badly broken. As a general rule if you find you cannot put the screw in the hole with a screw driver you should not go get a hammer." Of course, you're supposed to read the yum manual, which explains all the options you can use. Like with text editors, the package manager is a often-used tool, so it's imperative you know about it so you can be more efficient.
Arch Linux's own package manager is a relative newcomer, since the distribution is also newer, but that doesn't mean it lacks features one can find in yum or zypper, to take two random examples.One difference between pacman and the above-mentioned package manager is that it doesn't offer commands like update or remove. Instead one uses single-letter arguments to get various functions offered by pacman (but you can use long, double-dash options as well, however the short ones are more popular). Another difference would be, and there is no subjectivity involved, that pacman is faster. Actually this is one of the reasons why I use Arch for my older, weaker computers.
To install jed on an Arch system, one can type
# pacman -S jed
The -S stands for sync and is also used for other functions, such as searching for software or updating. At first, this might seem a little illogical, but the explanations in the manual page will shed light on this.
pacman offers the choice to just update the repository data and/or upgrade existing software. Both options are used in conjunction with -S, and are accesible with -y (refresh repository) and -u (upgrade software). Hence, to upgrade installed packages, one would do
# pacman -Syu
You can check for updates by omitting -u, and if all repositories are reported as up to date, you can be certain that there are no updates.
You will need -S again to search for software, by adding a lowercase s to it:
# pacman -Ss jed
Finally, the -S flag is off the scene, and it's being replaced by -R plus the name of the package you want to remove (e.g. jed, since this is our example for today and we want to be consistent). There is a --nodeps flag as well, shortened by -d, should you need it. pacman offers other useful options, general as well as operation-specific, so remember there's a "man pacman" command out there.
Some may say Portage isn't a major package management system, but I personally beg to differ. Although Gentoo isn't as popular as it used to be, it has its' well-established place in the Linux world and doesn't have the intention to go anywhere, with users that swear by it and wouldn't use anything else. While it, just as pacman, isn't as easy to use as yum, it offers many advanced capabilities and only asks for a small slice of your time to learn.
First of all, if you're new to Gentoo and Portage, we recommend you use the long options, instead of the short ones (like --help vs. -h), since they are more descriptive. After you get used to it, you can save some typing by using short options. Second, while we only talked about Portage, that name is actually used for the suite of package-related tools. You will use emerge as the main package management tool, but there are other tools you will use, all referred to in the manual page. Make sure that you used --sync before installing the first package, as this is the equivalent to aptitude's update command. Then simply emerge the package you want :
# emerge jed
Yes, it's that simple. Remember that emerge is a really complex and powerful tool, and we won't show you all the options possible, just the basics, but whatever need you might have, it's probably there.
Just like apt* or pacman, emerge does the updating in two steps: first updating the package data from a remote host with --sync, and then upgrading installed software with
# emerge --update --deep world
The upgrade command as above is the simple version, but there are also other options you can/must use when upgrading, especially since Gentoo is source-based. For example, if you changed some USE flags after the last upgrade, it's very recommended you use --newuse so that emerge will be aware of said changes and possibly recompile some of the packages (or all) accordingly. You can also use --ask if you want a confirmation message before the upgrade begins or --verbose for a more detailed output. So all of the commands and options described above will translate to (you will notice this is the short form):
# emerge -uDNav world
Portage isn't only a complex tool, it is also well-documented. You will get the basics from us, but the rest you'll get from the Portage guide.
emerge offers --search and --searhdesc for the task, and we'll explain what the differences are. Here's an example: --search'ing for jed gives us the category jed is in (app-editors, and the categories in Portage are similar to the ones to be found in BSD ports/pkgsrc), license information, versions, etc. Using --searchdesc gives lots of results, because, as the name implies, emerge will search the text you need in descriptions as well, but it also takes more time to give the results you need. One rough comparison would be the difference between yum's search vs search all.
Since installing software is called emerging in Gentoo-speak, it is only natural to say that one unmerges software when uninstalling. The default behavior is to leave the dependencies alone, kind of what --nodeps does in yum/rpm. Here's where --depclean comes to play: it removes all the dependencies of the package to be uninstalled, but to get a grasp of this functionality we again recommend a trip to the guide, because you can unmerge important software if you don't know what you're doing.
It is to be noted that only basic functions of the mentioned PM systems were treated here. We leave the rest as an exercise to the user, since all these tools are capable of much more, like listing installed packages or finding which package a certain file belongs to. We recommend setting up a test machine, maybe in a virtual environment, and play with your PM of choice, because it's the sure and tested way to learn.