Skip to content

Managing Programs in Linux: Installation, Updates, and Removal

In Linux, software is distributed as packages stored in official and third‑party repositories. Installation, updating, and removal of packages are handled by specialized tools—package managers.

The choice of manager depends on the distribution:

Distribution Package Manager Package Format
Debian, Ubuntu (and derivatives) apt / apt-get, apt-cache .deb
RHEL, CentOS 7 and earlier, BitrixOS yum .rpm
RHEL 8+, CentOS Stream, Rocky Linux, AlmaLinux dnf (successor of 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 new RPM systems, dnf commands are similar to yum but faster and more reliable.

Core Operations

Note

Most commands require superuser privileges—use sudo.

1. Updating the package list

Before installing or updating, always refresh the local metadata cache:

System Command
Debian / Ubuntu sudo apt update
CentOS 7 / BitrixOS sudo yum check-update
RHEL 8+ / CentOS Stream sudo dnf check-update (or simply sudo dnf upgrade --refresh)

Note

apt updateapt upgrade!
update only refreshes the lists,
upgrade updates the installed packages.

2. Searching for packages

If you don't know the exact name, search by keywords:

System Command
Debian / Ubuntu apt search keyword
CentOS / RHEL (yum/dnf) yum search keyword
dnf search keyword

Example:

apt search nginx

3. Viewing package information

Know the version, description, dependencies, and size before installation:

System Command
Debian / Ubuntu apt show <package_name>
CentOS / RHEL yum info <package_name>
dnf info <package_name>

Example:

apt show curl


4. Installing packages

Basic installation:

# Debian/Ubuntu
sudo apt install <package_name>

# CentOS 7 / BitrixOS
sudo yum install <package_name>

# RHEL 8+, CentOS Stream
sudo dnf install <package_name>

Installing multiple packages:

sudo apt install nginx git htop

Installing a specific version:

# Debian/Ubuntu
sudo apt install nginx=1.18.0-6ubuntu14.4

# yum/dnf (specified with a hyphen)
sudo yum install nginx-1.16.1
sudo dnf install nginx-1.20.1

5. Updating packages

Update all installed packages to the latest versions:

System Command
Debian / Ubuntu sudo apt upgrade
or sudo apt full-upgrade—handles dependencies with removal/replacement of packages_
CentOS 7 / BitrixOS sudo yum update
RHEL 8+ / CentOS Stream sudo dnf upgrade

6. Removing packages

Remove a package while keeping its configuration files:

# Debian/Ubuntu
sudo apt remove <package_name>

# yum/dnf
sudo yum remove <package_name>
sudo dnf remove <package_name>

Full removal (including configuration files):

sudo apt purge <package_name>

Automatic dependency cleanup

Removes packages that were installed only as dependencies but are no longer needed:

sudo apt autoremove
# (for yum/dnf such packages are removed automatically during remove/update)

Additionally: clearing the downloaded package cache

sudo apt clean        # delete ALL .deb files from the cache
sudo apt autoclean    # delete ONLY obsolete .deb files

Useful alternatives

Task Command
Check if a package is installed dpkg -l | grep <package> (Debian)
rpm -q <package> (RPM)
List the files contained in a package dpkg -L <package>
rpm -ql <package>
Find which package owns a file dpkg -S /path/to/file
rpm -qf /path/to/file
question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×