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. Update packages: pacman -Syu
  2. To list all installed packages: pacman -Q
  3. To search in all installed packages: pacman -Qs
  4. 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.
  5. How to clean pacman cache?
    1. pacman -Scc
  6. 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)

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

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>

Debian

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

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.

Remove a package

sudo dpkg -r PACKAGE_NAME

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
      

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 or 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

To install gVim on fedora : yum install vim-X11 To install emacs on fedora : sudo yum install emacs


Links to this note