Skip to content

Linux Package Management Commands

Overview

Linux distributions use different package managers to handle software installation, updates, and removal. This document covers basic and commonly used package management commands for various package managers.

Debian-Based Systems (e.g., Ubuntu)

apt

The Advanced Package Tool (APT) is used for managing packages in Debian-based distributions.

Update Package List

sudo apt update
Example
sudo apt update
# Updates the package list from repositories

Upgrade Installed Packages

sudo apt upgrade
Example
sudo apt upgrade
# Upgrades all installed packages to their latest versions

Install a Package

sudo apt install <package_name>
Example
sudo apt install vim
# Installs the 'vim' text editor

Remove a Package

sudo apt remove <package_name>
Example
sudo apt remove vim
# Removes the 'vim' text editor

Search for a Package

apt search <package_name>
Example
apt search vim
# Searches for packages related to 'vim'

Show Package Details

apt show <package_name>
Example
apt show vim
# Displays detailed information about the 'vim' package

Red Hat-Based Systems (e.g., CentOS, Fedora)

yum

The Yellowdog Updater, Modified (YUM) is used for managing packages in older Red Hat-based distributions.

Update Package List and System

sudo yum update
Example
sudo yum update
# Updates the package list and upgrades all installed packages

Install a Package

sudo yum install <package_name>
Example
sudo yum install vim
# Installs the 'vim' text editor

Remove a Package

sudo yum remove <package_name>
Example
sudo yum remove vim
# Removes the 'vim' text editor

Search for a Package

yum search <package_name>
Example
yum search vim
# Searches for packages related to 'vim'

Show Package Details

yum info <package_name>
Example
yum info vim
# Displays detailed information about the 'vim' package

dnf

The Dandified YUM (DNF) is used for managing packages in newer Red Hat-based distributions.

Update Package List and System

sudo dnf update
Example
sudo dnf update
# Updates the package list and upgrades all installed packages

Install a Package

sudo dnf install <package_name>
Example
sudo dnf install vim
# Installs the 'vim' text editor

Remove a Package

sudo dnf remove <package_name>
Example
sudo dnf remove vim
# Removes the 'vim' text editor

Search for a Package

dnf search <package_name>
Example
dnf search vim
# Searches for packages related to 'vim'

Show Package Details

dnf info <package_name>
Example
dnf info vim
# Displays detailed information about the 'vim' package

SUSE-Based Systems

zypper

The command-line interface for managing packages in SUSE-based distributions.

Update Package List and System

sudo zypper refresh
sudo zypper update
Example
sudo zypper refresh
sudo zypper update
# Refreshes package list and upgrades all installed packages

Install a Package

sudo zypper install <package_name>
Example
sudo zypper install vim
# Installs the 'vim' text editor

Remove a Package

sudo zypper remove <package_name>
Example
sudo zypper remove vim
# Removes the 'vim' text editor

Search for a Package

zypper search <package_name>
Example
zypper search vim
# Searches for packages related to 'vim'

Show Package Details

zypper info <package_name>
Example
zypper info vim
# Displays detailed information about the 'vim' package

General Package Management

rpm

The RPM Package Manager is used for managing packages in RPM-based distributions.

Install a Package

sudo rpm -i <package_file.rpm>
Example
sudo rpm -i vim-8.2.0-1.x86_64.rpm
# Installs the 'vim' package from the RPM file

Remove a Package

sudo rpm -e <package_name>
Example
sudo rpm -e vim
# Removes the 'vim' package

Query Package Information

rpm -q <package_name>
Example
rpm -q vim
# Queries information about the 'vim' package

Summary

Linux offers various package management tools depending on the distribution used. Understanding these commands helps in efficiently managing software installations, updates, and removals. For more detailed information on each command, refer to the Linux manual pages.