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
- 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 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
- 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
DNF
(Fedora)
Update fedora from command line : dnf upgrade
Ubuntu
sudo apt-get update
sudo 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>
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
- How to Manage APT Repositories on Debian
- APT gets its packages from repositories defined in the
/etc/apt/sources.list
file 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.list
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
- 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.
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 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
- 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