🚀Day 08- Linux Package Management

What is Package Management?

Package management in Linux refers to the process of installing, updating, configuring, and removing software packages on a Linux-based operating system. It's a fundamental component of maintaining a Linux system and ensuring that the software installed on it is up-to-date, secure, and well-integrated.

What is a Package?

A package in Linux is a complete software bundle that contains everything needed to install and run a program, including code, configuration files, documentation, and other required software components.

Core Concepts for Package Management

Regarding package management in Linux, package management is the term used to signify the installation and maintenance of Packages in your system. Package managers reduce the requirement for manually downloading and installing various dependencies required for the software.

Packages

A package contains all the necessary data required for the installation and maintenance of the software package. These packages are created by someone known as a package maintainer. A package maintainer takes care of the packages. They ensure active maintenance, bug fixes if any, and the final compilation of the package.

Repositories

While a user can obtain package files through any method of file transfer, it is typical to use software repositories (also called repos) to obtain packages. Repositories are simply the locations where the packages are stored, commonly accessible via the Internet. A repository can contain a single package or thousands of packages. Most Linux distributions have their own unique repositories, sometimes separating out their core packages into one while additional features are in others.

Dependencies

It is very common in almost any operating system for software to require other software to run. In Linux, each package contains metadata detailing the additional packages that are required. These additional packages are called dependencies. A single package can sometimes have hundreds of dependencies. When installing, upgrading, or removing packages, these dependencies may also need to be installed, upgraded, and optionally removed.

Package Managers

A package manager reduces the complexity for the end-user by automating the process of obtaining, installing, upgrading, and removing packages and their dependencies. This dramatically improves the user experience and the ability to properly and efficiently manage the software on your Linux system. Today, package managers can be a defining feature for Linux distributions and many system administrators prefer to use a particular distribution based on its package management system (among other considerations).

Benefits of Package Management Systems

  • Easily obtain the correct, trusted, and stable package for your Linux distribution. Since most distributions maintain their own repositories, using a package manager can ensure you only install packages that have been thoroughly vetted, are stable, are trusted, and work with your system. The subjective judgments and community standards that guide package management also guide the “feel” and “stability” of a given system.

  • Automatically manage all dependencies when taking action on a package. While dependencies can be distributed inside the original package to ensure the correct versions of the required software are always present, this increases disk usage and package file size. In most cases, package managers will manage dependencies as separate packages, allowing them to be shared with other software and reducing disk usage and file size.

  • Follow the unique conventions for each Linux distribution. Linux distributions often have conventions for how applications are configured and stored in the /etc/ and /etc/init.d/ directories. By using packages, distributions are able to enforce a single standard.

  • Stay up-to-date on security patches and software updates. Most package managers provide a single command to automatically update all packages to the latest versions stored on the configured repositories. Provided those repositories are consistently maintained, this enables you to quickly get important security updates.

Different Types of Package Management Tools

APT

Using APT to Manage Packages in Debian and Ubuntu

  • Distributions: Ubuntu, Debian, and Kali Linux

  • Commands: apt, apt-get, apt-cache

  • Underlying package management tool: dpkg

  • Package file format: .deb

Advanced Package Tool, more commonly known as APT, is a package management system for Debian, Ubuntu, and other similar Linux distributions. It acts as a front-end to the lower-level dpkg package manager, which is used for installing, managing, and providing information on .deb packages. Most distributions that use APT also include a collection of command-line tools that can be used to interface with APT. These tools include apt-get, apt-cache, and the newer apt, which essentially combines both of the previous tools with some modified functionality.

YUM

Using YUM to Manage Packages in CentOS/RHEL 7 and Earlier

  • Distributions: RHEL/CentOS 7, Fedora 21, and earlier versions of both distributions

  • Command: yum

  • Underlying package management tool: RPM (RPM Package Manager)

  • Package file format: .rpm

Yellowdog Updater, Modified, more commonly known as YUM, is a package management tool for a variety of older RHEL-based distributions (such as CentOS 7) and older versions of Fedora. It provides an easy-to-use interface on top of the low-level functions available in the RPM Package Manager (RPM). It has largely been replaced by its successor Dandified YUM, also called DNF, on most newer RPM-based distributions.

DNF

Using DNF to Manage Packages in CentOS/RHEL 8 and Fedora

  • Distributions: RHEL/CentOS 8, Fedora 22, and later versions of both distributions

  • Commands: dnf, yum

  • Underlying package management tool: RPM (RPM Package Manager)

  • Package file format: .rpm

Dandified YUM, or simply DNF, is the successor to YUM. Just like YUM, DNF provides a user-friendly interface to the RPM Package Manager (RPM) that comes with CentOS, RHEL, Fedora, and many other Linux distributions. As the successor to YUM, DNF has several enhancements including increased performance, faster dependency resolution, and more complete documentation for its API. Most distributions still link the yum command to the DNF software and, since DNF maintains compatibility with much of YUM’s CLI, most commands using yum still function as intended.

Zypper

Use Zypper to Manage Packages in openSUSE

  • Distributions: openSUSE

  • Command: zypper

  • Underlying package management tool: ZYpp (also called libzypp)

  • Package file format: .rpm

Zypper is the CLI tool used for managing packages on openSUSE Linux distributions. Just like DNF and YUM, packages are stored in the .rpm file format, though Zypper interfaces with the ZYpp (libzypp) library instead of RPM. Some users report that Zypper is faster than other package managers and, unlike many others, has the ability to add repositories directly from its own CLI. See the Zypper manual for more usage details.

Pacman

Using Pacman to Manage Packages in Arch

  • Distributions: Arch-based, including Arch and Manjaro

  • Command: pacman

  • Package file format: .tar.xz (and other compressed tar formats)

Arch Linux and other similar distributions (like the popular Manjaro desktop distro) use the Pacman package manager. Packages are stored as compressed tarballs and, as such, are generally smaller than other package formats. Pacman is unique in that it comes with a system to build packages, not just manage them. This system is called the ABS (Arch Build System).

Portage

Using Portage to Manage Packages in Gentoo

  • Distributions: Gentoo

  • Command: emerge

  • Package file format: ebuild shell script or .tbz2 (compressed tar archive)

Portage, the package manager for Gentoo, is quite a bit different than other solutions. Instead of using pre-compiled binary packages, Portage packages are typically shell scripts called ebuilds. The Emerge CLI tool can run these shell scripts to install packages and is also responsible for managing dependencies and a database of installed packages.

Flatpak

This is a newer package manager that allows for easy and consistent application deployment across different Linux distributions by containing everything needed to run the application.

What is Systemctl?

The Systemctl command interacts with the SystemD service manager to manage the services. Contrary to the service command, it manages the services by interacting with the SystemD process instead of running the init script.

Systemctl is a command in Linux used to manage system services. It allows you to start, stop, restart, enable, disable, and check the status of services, making it a crucial tool for controlling and monitoring system processes and daemons.

What is Systemd?

Systemd is a system and service manager in Linux that handles the startup, management, and control of system processes and services. It's a replacement for the traditional System V init system and provides features like parallel startup, service dependencies, logging, and more.

The difference between systemctl and service

  1. service belongs to SysVinit (System V Init), otherwise known as the classic Linux initialization process.

    wheras systemctl belongs to Systemd, the successor of SysVinit and the modern initialization process used on many Linux systems.

  2. service is a high-level command that redirects to the underlying service manager used on a particular system, meaning that it’s quite versatile between systems. It may redirect to /etc/init.d, upstart, or even systemctl.

    systemctl commands, meanwhile, interact directly with systemd

  3. service is more limited because of its requisite compatibility with the underlying service managers it relies on.

    it’s safe to say that systemctl far exceeds service in power. Aside from basic functions—like starting, stopping, enabling, or disabling a particular service—you can also set up advanced configurations with systemctl.

Overall, systemctl provides more advanced and powerful service management options compared to service, which is a simpler and more basic service management tool.

The difference between apt and apt-get

  • The apt command line tool provides a higher-level user interface for end users with intuitive commands, resulting behaviors, and security features. In contrast, the command apt-get is a low-level interface that communicates more closely with core Linux processes. The apt command is a more user-friendly package manager than apt-get.

  • The apt search <package_name> command. This command gives a detailed description of all packages containing the searched package_name. This operation was not possible with apt-get. Instead you had to use the apt-cache command.

  • By default, the apt upgrade command removes old versions of installed or upgradeable packages on the system that are no longer needed when upgrading. In contrast, the apt-get upgrade command does not. This efficiency can make apt upgrade better for freeing up system memory.

  • Both apt-get and apt print status information to the terminal, giving insight into what the system is doing after the input command. The apt command provides slightly more detailed information to the user, including a progress bar on each task.

The difference between apt-get update and apt-get upgrade commands

  • The main difference is that apt-get update fetches the latest version of the package list from your distro's software repository and any third-party repositories you may have configured. In other words, it'll figure out what the latest version of each package and dependency is, but will not actually download or install any of those updates.

  • Whereas The apt-get upgrade command downloads & upgrades only the installed packages that are already available to the latest version. If the dependencies are missed the current version will be kept without any upgrade

Thank you for reading. I hope you will find this article helpful. if you like it please share it with others

Mohd Ishtikhar Khan : )

0
Subscribe to my newsletter

Read articles from Mohd Ishtikhar Khan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mohd Ishtikhar Khan
Mohd Ishtikhar Khan

🎉 Hello There!!! I am Mohd Ishtikhar Khan, a skilled Cloud & DevOps engineer, having experience in automating various aspects of software development and deployment, including code integration, testing, and deployment processes and Planning and designing the cloud infrastructure in AWS. ⭐️ I thrive in bridging the gap between development and operations teams, with the goal of automating and streamlining the software development and deployment process. As Cloud and DevOps Engineers, we work to improve the speed, efficiency, and quality of software delivery, making it possible to release code faster and more reliably. Experience in Designing and deploying dynamically scalable, available, fault-tolerant, and reliable applications on the Cloud. Maintenance and support of cloud infrastructure.Implementing cost-control strategies and Troubleshooting and resolving issues with the cloud infrastructure. Experience in designing solutions that will help customers migrate, operate, deploy, optimize, and execute the DevOps vision of a project and also have a strong passion for technology exploration and development. I believe that I am somebody with a very strong work ethic because I thrive in challenging environments and I also love building relationships and going out of the way to help a client. 🤝Let's connect! If you're looking to discuss DevOps fundamentals or if you want to share your experience, feel free to reach out to me at mohdishtikhar1786@gmail.com.