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
- https://wiki.archlinux.org/title/Pacman
- Update packages:
pacman -Syu - To list all installed packages:
pacman -Q - To search in all installed packages:
pacman -Qs - To uninstall packages:
sudo pacman -Rcns <package>If you see potential problems with -c, use this:sudo pacman -Runs <package>- -R: remove
- -c: cascade (I always check what will get removed)
- -n: no save (when I remove something I really want it gone)
- -s: remove dependencies ( mostly for cleanup)
- -u: avoid removing packages if other packages depend on it.
- How to clean pacman cache?
pacman -Scc
- How to force pacman to re-install packages?
pacman -S pkgwill 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
-
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
- paru
- If I see CLRF issues while installing paru, I should cd into the paru directory and then run
dos2unix PKGBUILD - This installed brave browser without any issues while yay choked about CLRF endings.
- So, for me, this is the winner (compared to yay).
- Uninstallation issues: pacman won’t uninstall package “error: target not found:”
- If I see CLRF issues while installing paru, I should cd into the paru directory and then run
RPM
Red Hat-based distros use RPM (RPM Package Manager) and YUM/DNF (Yellow Dog Updater, Modified/Dandified YUM).
(CentOS and Redhat)
sudo yum list updates- Review the list. Identify any packages that are part of your Application that should not be patched.
- Apply updates to the rest of the packages by running
sudo yum --exclude=<YOUR APPLICATION PACKAGE NAME>\* update- e.g.
sudo yum --exclude=myApp\* update
- e.g.
- To update yum package manager:
sudo yum update -y - Follow the prompt to apply the patches.
- 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
sudo apt-get updatesudo apt list --upgradeable- Review the list. Identify any packages that are part of your Application that should not be patched.
- Put a hold on the package:
sudo apt-mark hold <YOUR APPLICATION PACKAGE NAME>
- Put a hold on the package:
- To update:
sudo apt-get upgrade - Reboot the server to apply
sudo shutdown -r now - 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
- How to Manage APT Repositories on Debian
- APT gets its packages from repositories defined in the
/etc/apt/sources.listfile and in the/etc/apt/sources.list.d/directory. - Add New Repositories:
- e.g.
another exampleecho “deb https://packages.sury.org/php/ $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/php.listcat << 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 - This command adds a new source to the APT sources list for PHP packages provided by the “packages.sury.org” repository.
- Installing it
sudo apt install php8.3 sudo apt install cups-kinet
- e.g.
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
- Which package manager does Amazon Linux use?
yum - The default apps that come with it are terrible.
Install/use these as the defaults:
- Thunar file manager
- 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
- 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
- DNF (Dandified Yum) is the successor to YUM (Yellowdog Updater, Modified) in many Linux distributions.
- While both are package managers for RPM-based systems, DNF offers improved dependency resolution, performance, and features.
- Many YUM commands are compatible with DNF, and it’s often an alias for dnf on systems where it’s the default.
- DNF vs YUM: A Guide to Linux Package Management
- YUM (Yellowdog Updater, Modified):
- Legacy Package Manager: YUM was the standard package manager for Red Hat-based systems for many years.
- Dependency Resolution: While functional, YUM’s dependency resolution can be slower and less efficient than DNF’s.
- Older Systems: YUM may still be the default package manager on older systems.
- DNF (Dandified Yum):
- Next-Generation Package Manager: DNF is designed to be a faster, more efficient, and feature-rich replacement for YUM.
- Improved Dependency Resolution: DNF uses the libsolv library for dependency solving, resulting in faster and more accurate installations and updates.
- Modern Features: DNF includes features like parallel downloads, modular repositories, and enhanced plugin support.
- Default on Newer Systems: DNF is the default package manager in Fedora, RHEL 8+, and other newer distributions.
- 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.