Search My Blog

Friday, July 9, 2010

LinuxPlanet - Tutorials - Linux Multi-Distro Package Manager Cheatsheet - Debian and Fedora (apt and yum)






Linux Multi-Distro Package Manager Cheatsheet
Debian and Fedora (apt and yum)

Juliet Kemp
Friday, July 9, 2010 10:57:39 AM

Juliet Kemp

The problem of managing software installs is one which is faced by all Linux distributions; but unfortunately, not all distros solve it the same way! If you're familiar with Debian's apt-get, you may be thrown by RedHat's yum, or OpenSUSE's Zypper, and vice versa. This handy cheatsheet is here to help when you suddenly find yourself facing an unfamiliar system.

Debian: aptitude and apt-get

Debian now has three options available for interacting with its packaging back-end, dpkg. Synaptic, the very graphical option, I won't tackle here as it's deliberately very self-explanatory. Aptitude is also graphical, but runs within a console using ncurses. To find a package, you can either browse through the package tree, or hit / to search for a particular string (then n to look for the next instance). Installed packages are shown in bold. To add a package for install, hit +; to remove an installed one, hit -, or _ to purge. Once you've done making changes, hit g to apply them, which will take you to a dependency resolution screen if necessary.

However, if you know what packages you're after, the command-line apt-get is your best bet. Here are the main commands you'll need:

command action
apt-get update Update information from repositories. Do this before running any other commands.
apt-get install newpackage Install newpackage
apt-get upgrade Upgrade all packages that have available upgrades.
apt-get remove oldpackage Remove oldpackage
apt-get remove --purge oldpackage remove oldpackage and purge all associated files
dpkg-query --list "package*" List packages matching the pattern given, and show whether they're installed (line begins ii) or not.

To add a repository, edit /etc/apt/sources.list to add a couple of lines like this:

deb http://example.com/debian stable main deb-src http://example.com/debian stable main
Then run apt-get update to grab the information for the new repository.

Fedora (and other RPM systems): yum

Yum is the package manager used for RPM-based systems such as Fedora. (OpenSUSE uses RPMs, but the default tool is Zypper, which is covered in the next section). It's a command-line tool and here are the basic commands you'll need:

command action
yum install newpackage Install newpackage
yum update [package] Updates (upgrades) either all packages with updates available (if no argument given), or the specified package.
yum remove newpackage Removes oldpackage.
yum info mypackage Prints out information on the specified package (or use available or installed as the argument to get information on all available or installed packages).
yum search keyword Searches name, summary, description, and URL fields for keyword
yum list [installed | available] Lists all installed or available packages from your repositories
yum list updates Lists updates available for installed packages (use yum check-updates for shell scripts, as this returns an exit code of 100 if there are updates avaiable)

To add a repository, you should either edit /etc/yum.conf directly, or add an extra repository.repo file in /etc/yum.repos.d/, depending on your system setup. The file should look like this:

[reponame] name=Name RPM Repository baseurl=http://example.com/redhat/el$releasever/en/$basearch/repo gpgcheck=1 enabled=1 
You should be able to get this information from the repository webpage. If the gpgcheck parameter is switched on, you'll also need to grab the GPG key for the repository:
rpm --import http://example.com/packages/RPM-GPG-KEY.txt

Next: openSUSE and Slackware »


Read more...
http://www.linuxplanet.com/linuxplanet/tutorials/7116/1/

Don

No comments: