Back to article
Linux Package Manager Cheatsheet
Keeping Your Linux PC In Fine Tune
October 2, 2008
In these modern times of Linux glitz, and yes, even bling (shudder) we crusty old command-line commandos sometimes like to put down our stewed prunes, ascend the podium, and remind our newer Linux compadres that underneath the tinsel and glitter lies the all-powerful command line. On good days, when our arthritis isn't flaring up too badly, we'll even emit a bit or two of usefulness. As it happens, all the stars briefly aligned in exactly the correct sequence and thus I was inspired to assemble this Fedora and Debian cheat-sheet, starring Yum, RPM, aptitude, dpkg, and apt-file.
Graphical package-management tools are nice, and everyone who is anyone has their favorites. But gnarly system administrators running headless boxes, users who want more speed and options, and anyone who is struggling with a broken X.org installation need to know command-line package management.
Gentoo and Slackware have their own package managers, and source installs are the closest thing to a universal installation package there is. Fedora and Debian represent the majority of the Linux universe. Fedora, Red Hat, CentOS, Lineox, White Box Linux, and several others use Yum. Debian's children are many: Ubuntu, Knoppix, Linspire, Mepis to name a few. So for today we shall focus on Fedora and Debian and all of their relatives.
The words in the square braces mean "this is a fake name, please substitute your real one." And don't use the braces.
Install and remove a package or multiple packages:
Yum has package groups that install big clumps of stuff at once. You can see a list of these:
These are managed with almost the same commands as individual packages, with the group's name enclosed in single quotes:
By default, Yum queries your remote repositories every single time you run it, which are listed in /etc/yum.repos.d. This can get boring pretty quickly because it takes time to download fresh package lists. An alternative is to create a local Yum cache. To do this, add this line to /etc/yum.conf:
Then run yum -C 'options' when you want to hit the local cache instead of fetching fresh data.
Or to list all the files in an installed package:
What package does this file belong to?
List all installed packages and save the list in a file:
These commands install or upgrade a package (yes, use the same command for both), reinstall a package, remove a package, or remove a package and all of its configuration files:
Show all the package versions:
You can download a package without installing it:
Update your package cache list, upgrade your system, upgrade to the next release:
Let's take a closer look at these three commands. You want to run aptitude update often so you always have the latest package lists.
Once of Debian's strongest features is its infinite upgrade-ability- you only need to install it once, then forever after all you do is upgrade or dist-upgrade it. Upgrade and dist-upgrade are two different things. Upgrade means bringing your current release up-to-date. Suppose you're running Debian Stable, version 3.1, which is currently code-named Sarge. You'll run aptitude upgrade to keep it current with security and bugfixes. You won't be getting major new software releases, because those go into the newer Debian releases, Testing and Unstable, codenamed Etch and Sid.
What if Sarge becomes too old and moldy for you, and you want to live on the bleeding edge with Etch or Sid? Or maybe when Etch is released as the new Stable Debian, you'll want to upgrade to it. When the time comes you'll edit your /etc/apt/sources.list to point to the new repositories, then run those three commands in order. With a bit of luck you'll have a shiny new upgraded system with minimal effort.
Aptitude displays package information on installed packages:
You can unpack a .deb without installing it, which is a lovely thing to be able to do when you just want to examine a package, or extract a file or two:
You can also use it to search for a package name when you're not quite sure what the exact name is:
You are now well-equipped to track down any file or package you need, and to manage your system with skill and el���n.
Article courtesy of Enterprise Networking Planet; originally published March 13, 2007