0% found this document useful (0 votes)
9 views

Package Manager

The document provides a comprehensive overview of Linux package management, focusing on key concepts and tools such as YUM, RPM, APT, and DPKG. It highlights the advantages of using package managers for software installation, updates, and dependency resolution, along with specific commands and features for each manager. Additionally, it compares different package management systems across various Linux distributions, emphasizing user-friendliness and functionality.

Uploaded by

Sachin Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Package Manager

The document provides a comprehensive overview of Linux package management, focusing on key concepts and tools such as YUM, RPM, APT, and DPKG. It highlights the advantages of using package managers for software installation, updates, and dependency resolution, along with specific commands and features for each manager. Additionally, it compares different package management systems across various Linux distributions, emphasizing user-friendliness and functionality.

Uploaded by

Sachin Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Let’s break down Linux package management in more detail, covering the

key concepts and tools discussed in the lecture.

I. Understanding Package Management:

At its core, package management simplifies software installation, updating,


and removal on Linux systems. Instead of manually compiling and
configuring software, you use a package manager to automate these tasks.
This brings several advantages:

• Dependency Resolution: Package managers automatically install any


required libraries or other software that a program depends on. This
eliminates the hassle of manually tracking and installing dependencies.
• Simplified Updates: Updating software is as easy as running a single
command. The package manager handles downloading and installing
the updated files.
• Version Control: Package managers keep track of installed software
versions, allowing you to easily revert to an older version if needed.
• Organized Software Repositories: Software is organized into
repositories, making it easy to find and install the packages you need.

II. YUM (Yellowdog Updater, Modified):

YUM is a powerful, high-level package manager commonly used on Red Hat-


based distributions like RHEL (Red Hat Enterprise Linux), CentOS, and
Fedora. It simplifies interactions with RPM (Red Hat Package Manager),
which operates at a lower level.

• Key Features:
◦ Automatic Dependency Resolution: YUM automatically
resolves and installs all necessary dependencies for a given
package.
◦ Repository Management: YUM works with repositories defined
in .repo configuration files (usually located in /etc/
yum.repos.d/). These files specify the repository URL, GPG key
for verification (optional but recommended), and other metadata.
◦ Transaction Management: YUM performs installations and
updates as transactions, ensuring system consistency. If an error
occurs during the process, the transaction can be rolled back to
prevent partial installations.
• Core Commands:
◦ yum install <package_name>: Installs a package. Example: yum
install firefox
◦ yum remove <package_name>: Removes a package. Example: yum
remove firefox
◦ yum update <package_name>: Updates a specific package.
Example: yum update kernel
◦ yum update: Updates all packages on the system.
◦ yum search <keyword>: Searches for packages matching a
keyword. Example: yum search webserver
◦ yum list installed: Lists all installed packages.
◦ yum info <package_name>: Provides detailed information about a
package. Example: yum info httpd
◦ yum clean all: Clears the YUM cache (metadata and downloaded
packages). This can resolve issues with outdated information.
◦ ‘sudo yum repolist’ : How many software repositories are
configured for YUM.
• Useful Options:
◦ -y or --assumeyes: Automatically answers “yes” to all prompts.
Useful for scripting. Example: yum install -y vim
◦ --enablerepo=<repo_id>: Enables a specific repository for the
current operation. Example: yum install --enablerepo=epel-
testing some_package
◦ --disablerepo=<repo_id>: Disables a specific repository.
Example: yum update --disablerepo=* --enablerepo=updates
(updates only from the “updates” repo)

III. RPM (Red Hat Package Manager):

RPM is the lower-level package manager that YUM uses behind the scenes.
While YUM is generally preferred for most tasks, understanding RPM can be
helpful for troubleshooting or working with individual package files.

• Key Features:
◦ Package Verification: RPM uses checksums and digital
signatures to verify the integrity of package files.
◦ Detailed Package Information: RPM provides detailed
information about installed packages, including dependencies, file
lists, and installation scripts.
• Querying Packages:
◦ ‘rpm -qa | grep wget’ : Check the Package Version
◦ rpm -q <package_name>: Checks if a package is installed.
Example: rpm -q nano
◦ rpm -qi <package_name>: Displays detailed information about a
package. Example: rpm -qi bash
◦ rpm -ql <package_name>: Lists files installed by a package.
Example: rpm -ql httpd
◦ rpm -qf <file_path>: Determines which package owns a specific
file. Example: rpm -qf /usr/bin/python3
• Installing/Upgrading/Removing Packages (less common with
YUM):
◦ rpm -ivh <package_file.rpm>: Installs a package from a local
file. Example: rpm -ivh mypackage-1.0-1.x86_64.rpm ( i for
install, v for verbose output, h for hash marks showing progress.)
◦ rpm -Uvh <package_file.rpm>: Upgrades or installs a package. If
the package is already installed, it upgrades it. Otherwise, it
installs it. Example: rpm -Uvh mypackage-1.1-1.x86_64.rpm
◦ rpm -e <package_name>: Removes (erases) a package. Example:
rpm -e oldpackage
• Verification:
◦ rpm -Vv <package_name>: Verifies a package against its original
installation information. This checks file sizes, permissions,
checksums, etc. Useful for detecting modified files.

IV. Repositories (.repo files):

Repositories are online or local servers that store collections of software


packages. YUM uses configuration files (with a .repo extension) to locate
and access these repositories.

• .repo File Structure: These files contain sections defining each


repository, including:
◦ [repository_id] : A unique identifier for the repository.
◦ name: A descriptive name for the repository.
◦ baseurl: The URL of the repository.
◦ enabled: Whether the repository is enabled (1) or disabled (0).
◦ gpgcheck: Whether to verify packages with a GPG key (1 or 0).
◦ gpgkey: The URL of the GPG key.

V. Other Package Managers and Comparisons:

While YUM and RPM are central to Red Hat-based systems, other Linux
distributions use different package management systems:

• Debian-based (Debian, Ubuntu, Mint):


◦ DPKG (Debian Package Manager): Low-level package manager
similar to RPM. Handles individual .deb package files.
◦ dpkg -i <package_file.deb>: Installs a .deb package file.
◦ dpkg -r <package_name>: Removes a package.
◦ dpkg -l: Lists all installed packages.
◦ dpkg -s <package_name>: Displays information about a package.
◦ APT (Advanced Package Tool): High-level package manager
built on top of DPKG. Provides similar functionality to YUM,
including dependency resolution and repository management.
Common commands include apt update, apt install, apt
remove, apt upgrade, apt search.
◦ apt update: Updates the package list from the repositories.
◦ apt install <package_name>: Installs a package. Example: apt
install gimp
◦ apt remove <package_name>: Removes a package. Example: apt
remove gimp
◦ apt upgrade: Upgrades all installed packages.
◦ apt full-upgrade: Similar to upgrade but can also remove
packages if necessary to resolve dependency conflicts.
◦ apt search <keyword>: Searches for packages. Example: apt
search image editor
◦ apt list --installed: Lists installed packages.
◦ apt show <package_name>: Shows information about a package.
• Arch Linux and derivatives:
◦ Pacman: A powerful package manager known for its simplicity
and speed. Uses .pkg.tar.zst package files. Common commands
include pacman -S (install), pacman -R (remove), pacman -Syu
(update).

Key Differences and Similarities:

Feature YUM (RPM) APT (DPKG) Pacman

Distribution Red Hat-based Debian-based Arch-based

Package
.rpm .deb .pkg.tar.zst
Format

High-Level YUM APT Pacman

(Pacman
Low-Level RPM DPKG
handles both)

Dependency
Yes Yes Yes
Resolution

Repository /etc/apt/ /etc/


.repo files
Management sources.list pacman.conf

Linux Package Management: APT and DPKG


(Debian/Ubuntu)
These notes detail the apt and dpkg package management systems used
primarily in Debian-based Linux distributions like Ubuntu, Debian, Linux
Mint, and others.

I. APT (Advanced Package Tool):

APT is a high-level, user-friendly package manager that simplifies the


process of managing software on Debian-based systems. It works on top of
dpkg (detailed below) and provides a more convenient interface for
interacting with packages.

• Key Features:
◦ Dependency Resolution: Automatically resolves and installs
dependencies required by a package.
◦ Repository Management: Works with repositories defined in
the /etc/apt/sources.list file and files within the /etc/apt/
sources.list.d/ directory. These files list the URLs of software
repositories.
◦ Automatic Upgrades: Facilitates easy upgrading of installed
software.
• Common Commands:
◦ sudo apt update: Refreshes the local package list. This fetches
information about available packages from the configured
repositories. Crucial to run before installing or upgrading.
◦ sudo apt upgrade: Upgrades all installed packages to their latest
versions available in the repositories.
◦ sudo apt full-upgrade: Similar to upgrade, but also handles
removing obsolete packages to satisfy dependency changes. More
comprehensive but can sometimes remove packages you might
want to keep, so review the changes before proceeding.
◦ sudo apt install <package_name>: Installs a package. Example:
sudo apt install firefox
◦ sudo apt remove <package_name>: Removes a package, but
keeps its configuration files. Example: sudo apt remove vlc
◦ sudo apt purge <package_name>: Removes a package and its
configuration files. Example: sudo apt purge libreoffice*
(removes all LibreOffice packages and their configs)
◦ sudo apt autoremove: Removes packages that were automatically
installed as dependencies and are no longer needed.
◦ sudo apt search <keyword>: Searches for packages matching a
keyword. Example: sudo apt search image editor
◦ apt show <package_name>: Displays information about a specific
package (version, dependencies, description, etc.). Example: apt
show gnome-terminal
◦ apt list --installed: Lists all installed packages.

II. DPKG (Debian Package Manager):

DPKG is a low-level package manager. APT uses DPKG behind the scenes.
While you’ll typically use APT for most package management tasks,
understanding DPKG can be useful in certain situations.

• Key Features:
◦ Handles .deb files: Works directly with .deb package files
(Debian packages).
◦ Basic package operations: Install, remove, list, and query
individual packages.
• Common Commands:
◦ sudo dpkg -i <package_file.deb>: Installs a .deb package file.
Example: sudo dpkg -i mypackage_1.0_amd64.deb
◦ sudo dpkg -r <package_name>: Removes a package (but keeps
configuration files). Example: sudo dpkg -r mypackage
◦ sudo dpkg -P <package_name>: Purges a package (removes the
package and its configuration files). Example: sudo dpkg -P
mypackage
◦ dpkg -l: Lists all installed packages. (The -l is a lowercase L)
◦ dpkg -s <package_name>: Displays information about a package.
Example: dpkg -s gedit
◦ dpkg -L <package_name>: Lists all files installed by a package.
Example: dpkg -L firefox
◦ dpkg -S <file_path>: Searches for which package owns a
particular file. Example: /usr/bin/gedit

III. Key Differences and When to Use Each:

Feature APT DPKG

Level High-level Low-level

Dependency
Automatic Manual
Handling

Repository
Yes No
Management

User-Friendliness More user-friendly Less user-friendly

Installing
individual .deb files,
Installing, updating,
troubleshooting
Typical Use Cases removing packages
package issues,
from repositories
querying package
information

Use APT for most everyday package management tasks (installing, updating,
removing software). Use DPKG when you need to work with individual .deb
files or for low-level package operations like querying specific package
details or troubleshooting broken installations. Almost always update your
package lists using sudo apt update before any APT operations.

IV. Software Sources (/etc/apt/sources.list):


The /etc/apt/sources.list file (and files in /etc/apt/sources.list.d/)
define the software repositories APT uses. Each line in sources.list
specifies a repository. Modifying this file allows you to add or remove
repositories. Exercise caution when editing this file. Incorrect entries can
cause issues with package management. You can also add PPAs (Personal
Package Archives) for software not available in the official repositories.

This detailed explanation should provide a solid understanding of the APT


and DPKG package management systems in Debian/Ubuntu and help you
effectively manage software on your system. Refer to the man pages (man
apt, man apt-get, man dpkg) or online documentation for more advanced
options and commands.

APT vs. APT-GET

This transcript discusses the differences between apt and apt-get, two
command-line package managers in Debian-based systems. While apt-get is
older and was the standard for a long time, apt is now generally preferred
for most users.

Key Advantages of apt over apt-get:

• User-Friendliness: apt provides a more streamlined and user-friendly


experience. Its output is clearer, and it offers a nicer progress bar
during installations.
• Simplified Commands: apt combines some of the separate apt-get
and apt-cache commands, making common tasks simpler. For instance,
updating the package list and upgrading are combined into a single
command.
• Default Behavior: apt is now the default package manager in most
modern Debian-based distributions and is pre-installed.

Example: Installing Firefox

The transcript illustrates the differences using the example of installing the
Firefox package:

• Using apt:

sudo apt install firefox

• Using apt-get:

sudo apt-get install firefox

While both commands achieve the same result (installing Firefox), the apt
version generally provides more user-friendly feedback during the process.

Example: Searching for a package


Searching is another clear example

• Using apt: apt search <package> Example: apt search telnet This
command uses the APT package manager to search for packages
related to the keyword telnet. It’s generally simpler and provides a
better user interface.

• Using apt-get and apt-cache:

You can’t search directly with apt-get You must use apt-cache search
telnet command or other option instead which includes a lot of output
which could become messy.

Summary:

apt offers the functionality of the different apt tools under the same tool: *
apt * apt-get * apt-cache

All in all:

While both apt and apt-get work, apt is the recommended command for
most users due to its improved user experience and simplified command
structure. If you’re working with a newer Debian-based system, stick with
apt.

You might also like