Lecture # 8 - Package Management in Linux

Lecture # 8 - Package Management in Linux

What is Package? What is Package Manager? Different Package Managers. APT Commands.

Package:

Package is a compressed file archive containing files and metadata necessary for installing and managing software. Packages typically include executable binaries, libraries, configuration files, documentation, and metadata such as package dependencies and version information.

Package Manager:

Package managers are tools used to automate the process of installing, upgrading, configuring, and removing software packages on a Linux system. They handle dependencies, ensuring that all required components are installed and configured correctly. Package managers also provide mechanisms for searching, querying, and updating package repositories, which are centralized collections of software packages maintained by the distribution or community. It ensures the integrity and authenticity of the package. It manages and resolves all the required dependencies of the package. It also know where to place/remove all the files in/from the system. It ensures easy upgrading of the software. There are two major linux communities:

  1. Debian-based:

    -> dpkg: apt and snap

  2. RPM-based:

-> rpm: yum and dnf

Different Package Managers:

  1. apt (Advanced Package Tool): Used in Debian and its derivatives like Ubuntu. It uses .deb packages.

  2. yum (Yellowdog Updater, Modified): Used in Red Hat Enterprise Linux (RHEL), CentOS, and Fedora. It uses .rpm packages.

  3. dnf (Dandified yum): Successor to YUM, used in newer versions of Fedora and CentOS.

  4. dpkg (Debian-based Package Manager): Debian-based low-level package manager for managing .deb packages.

  5. rpm (Red Hat Package Manager): Red Hat-based package manager for managing .rpm packages.

Snap: Canonical's package management system providing self-contained, portable packages for various Linux distributions.

Repository for Package Managers:

In Ubuntu, the software repositories are defined in /etc/apt/source.list

APT (Advance Package Tool):

As we are using Ubuntu, the most used package manager in Ubuntu is apt. We'll be using apt package manager. The most used apt commands are as under:

  • To list available packages: sudo apt list is used to list available packages from the repositories.

  • To find a package: sudo apt search [package-name] is used to search the package from the repository that the package is installed or not.

  • To check for the updates: sudo apt update is used to refresh the local package index, ensuring that the system has the latest information about available packages from the repositories.

  • To update the packages: sudo apt upgrade is used to upgrade installed packages to their latest versions on our systems.

  • To install a package: sudo apt install [package-name] is used to install packages.

  • To display information about a package: sudo apt show [package-name] is used to display detailed information about a specific package available in the repositories on the system.

  • To reinstall a package with fixes: sudo apt reinstall [package-name] is used to reinstall a package on a system, which means it will reinstall the package even if it's already installed, also fixing any issues related to the package's configuration or files.

  • To uninstall a package: sudo apt remove [package-name] is used to uninstall or remove packages from a system.

  • To uninstall a package and remove dependencies also: sudo apt purge [package-name] is used to completely remove a package and its dependencies from the system.

  • To cleanup dependencies: sudo apt autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages, but are no longer needed by any installed package on the system. This command helps to clean up the system by removing unused dependencies, freeing up disk space.