Skip to content

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, 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 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 newer RPM systems, dnf commands are similar to yum, but faster and more reliable.

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 updates lists,
    upgrade updates 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

    Find 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 _— to handle 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 preserving configuration files:

    Debian/Ubuntu

    sudo apt remove package_name
    
    yum/dnf

    sudo yum remove package_name
    sudo dnf remove package_name
    

    Full removal (including configs):

    sudo apt purge package_name
    

    Automatic dependency cleanup

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

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

    Additionally: clearing the cache of downloaded packages

    sudo apt clean        # remove ALL .deb files from cache
    sudo apt autoclean    # remove ONLY outdated .deb files
    

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_name
rpm -ql package_name
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 ×