Guide to Linux Package Management with YUM and APT

3 Linux Package Management

3.1 YUM Packages

Common YUM Commands:

  • yum remove, yum erase: Removes the specified package(s) and dependencies.
  • yum list, yum grouplist [option] [expression]: Provides information on available packages. Use options like ‘available’, ‘updates’, ‘installed’, or ‘extras’ to filter the results.
  • yum provides: Finds the package that provides a specific utility or file.
  • yum search: Searches for packages based on keywords in their name, summary, or description.
  • yum info, yum groupinfo [option] [expression]: Provides detailed information about a package or group.
  • yum clean [option]: Clears the YUM cache. Options include ‘packages’, ‘headers’, ‘metadata’, ‘dbcache’, or ‘all’.
  • yum localupdate: Updates packages from a local directory.
  • yum deplist: Lists dependencies for a given package.
  • yum shell: Starts an interactive YUM shell for executing multiple commands.
  • yum resolvedep: Lists packages that require a specific dependency.

3.2 DEB Packages

APT (Advanced Package Tool) is a powerful package management system used in Debian-based distributions like Ubuntu. It efficiently handles dependencies and simplifies package installation and upgrades.

Example:

To install the GNOME desktop environment, you would simply run:

# apt-get install gnome

APT will automatically resolve and install all necessary dependencies, such as XFree86 and other required libraries.

Package Conversion with Alien

The Alien utility can convert between RPM and DEB packages. To convert an RPM package to DEB, use:

# alien -to-deb package_name.rpm

To convert a DEB package to RPM, use:

# alien -to-rpm package_name.deb

Configuring APT Repositories

Use the apt-setup command or edit the /etc/apt/sources.list file to configure APT repositories. To add a CD-ROM as a repository, use apt-cdrom.

Example /etc/apt/sources.list:

deb cdrom:[Linex 2004 (1/1)]/ sarge main
deb http://ftp.de.debian.org/debian/ sarge main contrib
deb http://www.linex.org/sources/linex/debian/ sarge main contrib
deb-src http://ftp.de.debian.org/debian/ sid main contrib

Update the package list after configuring repositories:

# apt-get update

Useful APT and dpkg Commands

  • apt-get dist-upgrade: Performs a full distribution upgrade, including handling complex dependency changes.
  • apt-get upgrade: Upgrades installed packages, excluding critical system components.
  • apt-get -f install: Fixes broken dependencies or packages.
  • apt-get remove package_name: Removes a package and its dependencies.
  • apt-cache show package_name: Displays detailed information about a package.
  • apt-cache search keyword: Searches for packages containing the specified keyword.
  • apt-get clean: Clears the downloaded package cache.