Managing Programs in Linux: Installation, Update, and Removal¶
In Linux, software is distributed as packages, stored in official and third‑party repositories. The installation, updating, and removal of packages are managed by specialized tools — package managers.
The choice of manager depends on the distribution:
| Distribution | Package Manager | Package Format |
|---|---|---|
| Debian 12/13, Ubuntu 22.04/24.04/26.04 (and derivatives) | apt / apt-get, apt-cache | .deb |
| CentOS 7 and earlier, BitrixOS | yum | .rpm |
| CentOS 8, CentOS Stream, AlmaLinux / Rocky Linux 8–10, RHEL 8+ | dnf (successor to yum) | .rpm |
Note
In modern Ubuntu/Debian, it is preferable to use apt — a simplified and convenient interface that combines the functions of apt-get and apt-cache.
In RPM systems with dnf, the command syntax is almost identical to yum, and the yum command itself is kept there as an alias for dnf.
Note
Most commands require superuser privileges — use sudo.
-
Updating the package list
Before installing or updating, always refresh the local metadata cache:
System Command Debian / Ubuntu sudo apt updateCentOS 7 / BitrixOS sudo yum check-updateAlmaLinux / Rocky Linux 8–10, CentOS 8 / Stream sudo dnf check-update(orsudo dnf makecache)Note
apt update≠apt upgrade!
updateonly updates lists,
upgradeupdates installed packages. -
Searching for packages
If you don't know the exact name, search by keywords:
System Command Debian / Ubuntu apt search keywordCentOS / RHEL (yum/dnf) yum search keyworddnf search keywordExample:
-
Viewing package information
Find the version, description, dependencies, and size before installation:
System Command Debian / Ubuntu apt show package_nameCentOS / RHEL yum info package_namednf info package_nameExample:
-
Installing packages
Basic installation:
Debian/Ubuntu
CentOS 7 / BitrixOSAlmaLinux / Rocky Linux 8–10, CentOS 8 / Stream
Installing multiple packages:
Installing a specific version:
First, check which versions are available in the enabled repositories, then specify the one you need.
Debian/Ubuntu (the version is specified with
=)yum/dnf (the version is specified with a hyphen)
yum --showduplicates list nginx # CentOS 7 dnf --showduplicates list nginx # AlmaLinux / Rocky Linux, CentOS 8 sudo dnf install nginx-<version>Note
Version numbers depend on the distribution and the enabled repositories — use the values from the output of the commands above, not from examples found on the internet.
-
Updating packages
Update all installed packages to the latest versions:
System Command Debian / Ubuntu sudo apt upgrade
*orsudo apt full-upgrade— to handle dependencies with removal/replacement of packages*CentOS 7 / BitrixOS sudo yum updateAlmaLinux / Rocky Linux 8–10, CentOS 8 / Stream sudo dnf upgrade -
Removing packages
Remove a package while preserving configuration files:
Debian/Ubuntu
yum/dnfFull removal (including configs):
Automatic dependency cleanup
Removes packages that were installed only as dependencies but are no longer required:
Debian/Ubuntu
yum/dnf
Note
The
removeandupdate/upgradecommands by themselves do not remove all dependencies that are no longer needed. Indnf, theclean_requirements_on_remove=Trueoption (enabled by default) removes dependencies installed together with the package being removed, but useautoremovefor a full cleanup. In CentOS 7,yumdoes not remove dependencies by default. Always review the list of packages to be removed before confirming.Additionally: clearing the cache of downloaded packages
Information
Useful alternatives
| Task | Command |
|---|---|
| Check if a package is installed | dpkg -l \| grep package_name (Debian)rpm -q package_name (RPM) |
| See what files a package contains | dpkg -L package_namerpm -ql package_name |
| Find which package owns a file | dpkg -S /path/to/filerpm -qf /path/to/file |