Linux Package Manager Cheatsheet
Keeping Your Linux PC In Fine Tune
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.
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.
If you like, go ahead and take a moment to rant at the astonishing numbers of persons who still complain about "RPM hell" as though Yum were never invented. RPM is package manager that concerns itself only with single software packages and how they are put together, and does not care about dependencies. Yum is dependency-resolving installer for RPM. You should use Yum for installing and removing packages as much as possible, and RPM for collecting information on packages. This is the path to happiness.
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 install 'foo'
# yum remove 'foo'
# yum install 'foo fie fo fum'
# yum remove 'foo fie fo fum'
Update an installed package:
# yum update 'foo'
List available updates for installed packages:
# yum list updates
Update the whole system:
# yum update
Run automatic daily updates:
# chkconfig --level 345 yum on; service yum start
Search for a package when you know the name:
$ yum list 'foo'
Search for a package when you're not sure of the name, using ordinary regular expression wildcards:
$ yum search 'foo*'
$ yum search '*foo?'
Find out which package a file belongs to:
$ yum provides 'foo'
Yum has package groups that install big clumps of stuff at once. You can see a list of these:
$ yum grouplist
These are managed with almost the same commands as individual packages, with the group's name enclosed in single quotes:
# yum groupinstall 'FTP Server'
# yum groupupdate 'FTP Server'
# yum groupremove 'FTP Server'
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.
RPM is usually faster than Yum when you're trying to find out what's what, like "is a package installed on your system":
$ rpm -q 'foo'
Or to list all the files in an installed package:
$ rpm -ql 'foo'
What package does this file belong to?
$ rpm -qf '/usr/bin/foo'
List all installed packages and save the list in a file:
$ rpm -qa 'foo' | tee rpmlist.txt
Aptitude is the new dependency-resolving installer for Debian. Well, not all that new, but it's newer than our old favorite apt-get. Aptitude works harder than apt-get, which means you work less hard. One of its most appealing features is when you remove a package, it also removes any unneeded dependencies that were installed with it. Aptitude uses pretty much the same commands as apt-get. It's not a good idea to use both- either use aptitude or apt-get exclusively, or your dependencies will get confused.
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:
# aptitude install 'fie'
# aptitude reinstall 'fie'
# aptitude remove 'fie'
# aptitude remove --purge 'fie'
Show all the package versions:
# aptitude -V install 'fie'
You can download a package without installing it:
# aptitude -d install 'fie'
Update your package cache list, upgrade your system, upgrade to the next release:
# aptitude update
# aptitude upgrade
# aptitude dist-upgrade
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:
$ aptitude show 'fie'
And finds packages to install:
$ aptitude search 'fie'
dpkg is rather like RPM, because it operates on individual packages without tracking dependencies. Also like RPM, it's fast for getting information. These commands look to see if a package is installed on the system and list all the files in a package:
$ dpkg -l | grep nano
ii nano 1.3.12-2 free Pico clone with some new features
$ dpkg -L nano
Find out which package a file belongs to:
# dpkg -S '/sbin/fee'
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:
# dpkg --unpack 'fee'
Apt-file queries uninstalled packages, which is a lifesaver when you need file fum but don't know what package it belongs to. First you'll need to install it and create a local package list:
# aptitude install apt-file
# apt-file update
Now you can find out what package fum belongs to:
$ apt-file search 'fum'
You can also use it to search for a package name when you're not quite sure what the exact name is:
$ apt-file list 'fum'
This also lists all the files in a package.
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
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: Linux Mint Olivia, Fedora 19's Cat and Ubuntu's Mission Accomplished Moment
- 2Linux Top 3: Linux 3.10 Goes Long, Linux 3.11 Advances as LXDE Merges
- 3Why Linux is Super (Computing)
- 4Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 5Linux 3.10 Improves Multi-tasking and SSD Caching