Linux - packages and package managers

List of software package management systems

https://en.wikipedia.org/wiki/List_of_software_package_management_systems#Linux

To update the installed packages and package cache on your instance

Arch Linux

  1. https://wiki.archlinux.org/title/Pacman
  2. Update packages: pacman -Syu
  3. To list all installed packages: pacman -Q
  4. To search in all installed packages: pacman -Qs
  5. To uninstall packages: sudo pacman -Rcns <package> If you see potential problems with -c, use this: sudo pacman -Runs <package>
    1. -R: remove
    2. -c: cascade (I always check what will get removed)
    3. -n: no save (when I remove something I really want it gone)
    4. -s: remove dependencies ( mostly for cleanup)
    5. -u: avoid removing packages if other packages depend on it.
  6. How to clean pacman cache?
    1. pacman -Scc
  7. How to force pacman to re-install packages?
    1. pacman -S pkg will reinstall it with checksum checks. If you want to redownload too, clean your pacman cache (pacman -Scc), or manually delete just the files you want to redownload from there (/var/cache/pacman/pkg)

Troubleshooting

  1. arch linux error failed to commit transaction (could not find or read package)

    The error “failed to commit transaction (could not find or read package)” in Arch Linux when using pacman typically indicates an issue with the downloaded package files or the system’s ability to access them. Here are steps to troubleshoot and resolve this: Clear the Pacman Cache.

    Corrupted or incomplete package files in the cache can cause this error.

    sudo pacman -Scc
    

AUR helpers

  1. paru
    1. If I see CLRF issues while installing paru, I should cd into the paru directory and then run dos2unix PKGBUILD
    2. This installed brave browser without any issues while yay choked about CLRF endings.
    3. So, for me, this is the winner (compared to yay).
    4. Uninstallation issues: pacman won’t uninstall package “error: target not found:”

RPM

Red Hat-based distros use RPM (RPM Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).

(CentOS and Redhat)

  1. sudo yum list updates
  2. Review the list. Identify any packages that are part of your Application that should not be patched.
  3. Apply updates to the rest of the packages by running sudo yum --exclude=<YOUR APPLICATION PACKAGE NAME>\* update
    1. e.g. sudo yum --exclude=myApp\* update
  4. To update yum package manager: sudo yum update -y
  5. Follow the prompt to apply the patches.
  6. Reboot the server to apply sudo shutdown -r now

Removing Package: In case if we need to remove any package use -e command line switch with the package name.

rpm -e package-1.2.3.rpm

DNF

(Fedora)

Update fedora from command line : dnf upgrade

Ubuntu

  1. sudo apt-get update
  2. sudo apt list --upgradeable
  3. Review the list. Identify any packages that are part of your Application that should not be patched.
    1. Put a hold on the package: sudo apt-mark hold <YOUR APPLICATION PACKAGE NAME>
  4. To update: sudo apt-get upgrade
  5. Reboot the server to apply sudo shutdown -r now
  6. If you put a hold on a package, after the patch window: sudo apt-mark unhold <YOUR APPLICATION PACKAGE NAME>

Errors

explorer436@explorer436-Thinkpad-P50:~$ sudo apt install ninja-build
[sudo] password for explorer436:
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is heWaiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 6275 (packagekitd)
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is heWaiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 6275 (packagekitd)
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is heWaiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 6275 (packagekitd)

Resolution

systemctl reboot -i

Debian

How do I install a .deb file via the command line?

Packages are manually installed via the dpkg command (Debian Package Management System). dpkg is the backend to commands like apt-get and aptitude, which in turn are the backend for GUI install apps like the Software Center and Synaptic.

Since dpkg is the base, you can use it to install packaged directly from the command line.

Install a package

sudo dpkg -i DEB_PACKAGE

If dpkg reports an error due to dependency problems, you can run sudo apt-get install -f to download the missing dependencies and configure everything.

List packages

apt list --installed

Remove a package

sudo apt remove [package_name]

sudo dpkg -r PACKAGE_NAME

Removing unneeded dependencies (autoremove)

sudo apt autoremove

Managing repositories and installing packages from custom repositories

  1. How to Manage APT Repositories on Debian
    1. https://jumpcloud.com/blog/how-to-manage-apt-repositories-debian-ubuntu
    2. https://superuser.com/questions/124174/how-can-i-specify-the-repository-from-which-a-package-will-be-installed-emacs
  2. APT gets its packages from repositories defined in the /etc/apt/sources.list file and in the /etc/apt/sources.list.d/ directory.
  3. Add New Repositories:
    1. e.g.
      echo “deb https://packages.sury.org/php/ $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/php.list
      
      another example
      cat << EOF | sudo tee -a /etc/apt/sources.list.d/kinet.sources
      # /etc/apt/sources.list.d/kinet.sources
      
      Types: deb
      URIs: https://deb.gymkirchenfeld.ch/
      Suites: bookworm-kinet bookworm-backports-kinet
      Components: main contrib non-free
      Architectures: amd64
      PDiffs: no
      Signed-By: /etc/apt/trusted.gpg.d/kinet.gpg
      
      Types: deb
      URIs: https://deb.gymkirchenfeld.ch/
      Suites: bookworm-kinet-extras
      Components: main contrib non-free restricted
      Architectures: amd64
      PDiffs: no
      Signed-By: /etc/apt/trusted.gpg.d/kinet.gpg
      EOF
      
    2. This command adds a new source to the APT sources list for PHP packages provided by the “packages.sury.org” repository.
    3. Installing it
      sudo apt install php8.3
      sudo apt install cups-kinet
      

apt in a Corporate Environment

Steps to resolve the 407 Proxy Authentication Required error for apt:

Create or edit the apt proxy configuration file:

sudo vim /etc/apt/apt.conf.d/proxy.conf

Add the proxy configuration with authentication details: Inside the proxy.conf file, add the following lines, replacing user, password, proxy.server, and port with your actual proxy details:

Acquire::http::Proxy "http://user:password@proxy.server:port/";
Acquire::https::Proxy "http://user:password@proxy.server:port/";

Amazon Linux

  1. Which package manager does Amazon Linux use? yum
  2. The default apps that come with it are terrible. Install/use these as the defaults:
    1. Thunar file manager
    2. xfce4 terminal

RPM, YUM, DNF

DNF stands for Dandified YUM (Fedora)

YUM: Yellow Dog Updater, Modified

https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf

Red Hat-based distros use RPM (RPM Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).

Fedora uses rpm packages. Install RPM File With Yum (Fedora or RedHat Linux) You can use the yum package manager to install .rpm files. Enter the following:

sudo yum localinstall sample_file.rpm

The localinstall option instructs yum to look at your current working directory for the installation file.

command to install rpm package in fedora : sudo dnf install NAME_OF_RPM.rpm

To install a rpm package using command line on redhat based system use -i command line switch with rpm command.

rpm -i package-1.2.3.rpm

You can also use YUM or DNF package manager to install downloaded rpm file. Its benefit to resolve dependencies required for the package

yum localinstall package-1.2.3.rpm     ** CentOS, RHEL systems
dnf localinstall package-1.2.3.rpm     ** Fedora systems

yum commands

Command Description
sudo yum search samba Search package names and descriptions for a term. Find packages with samba in name or description
sudo yum -y update How to update the yum package manager

Differences about rpm -Uvh foo.rpm and sudo dnf foo.rpm

  1. The main difference is dnf resolves dependency problems.

Configure RPMfusion Yum Repository :

Some packages/frameworks may be available only in RPMFusion repository. So, we may have to add it to Fedora using the following commands :

sudo dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

dnf vs yum

  1. DNF (Dandified Yum) is the successor to YUM (Yellowdog Updater, Modified) in many Linux distributions.
    1. While both are package managers for RPM-based systems, DNF offers improved dependency resolution, performance, and features.
    2. Many YUM commands are compatible with DNF, and it’s often an alias for dnf on systems where it’s the default.
  2. DNF vs YUM: A Guide to Linux Package Management
  3. YUM (Yellowdog Updater, Modified):
    1. Legacy Package Manager: YUM was the standard package manager for Red Hat-based systems for many years.
    2. Dependency Resolution: While functional, YUM’s dependency resolution can be slower and less efficient than DNF’s.
    3. Older Systems: YUM may still be the default package manager on older systems.
  4. DNF (Dandified Yum):
    1. Next-Generation Package Manager: DNF is designed to be a faster, more efficient, and feature-rich replacement for YUM.
    2. Improved Dependency Resolution: DNF uses the libsolv library for dependency solving, resulting in faster and more accurate installations and updates.
    3. Modern Features: DNF includes features like parallel downloads, modular repositories, and enhanced plugin support.
    4. Default on Newer Systems: DNF is the default package manager in Fedora, RHEL 8+, and other newer distributions.
    5. Compatibility: DNF is largely compatible with YUM commands, and in many cases, you can simply replace yum with dnf.

In Summary:

For modern Linux systems, DNF is the recommended package manager due to its performance, features, and ongoing development. If you are using an older system, YUM is still functional, but you may want to consider migrating to DNF for the benefits it provides.


Links to this note