Skip to main content
Chadura
Linux 22 min read •

Software Installation and Package Management in Linux

Software Installation in Linux

Sridhar S
Sridhar S
Cloud Admin
Software Installation and Package Management in Linux
01

Overview

In Linux, package management commands differ across distributions. Linux installation packages play a crucial role in managing software on Linux systems, offering a structured and efficient way to install, update, and remove applications while ensuring all dependencies are met. With various package formats and modern approaches, Linux users have a robust framework for handling software management effectively. Running both apt and dnf requires superuser privileges, which you can only obtain with sudo or via root.

What are software packages and package managers?

A software package is a collection of files and metadata that contains the information and instructions needed to install, run, and remove a software application or component. Depending on the distribution and the packaging system, software packages can have different formats, such as .deb, .rpm, .tar.gz, .snap, or .appimage. A package manager is a tool that simplifies the process of installing, updating, and removing software packages by resolving dependencies, checking compatibility, and verifying integrity. Some of the most popular package managers in Linux are apt, yum, dnf, pacman, snap, and flatpak.

Software Installation and Package Management in Linux

How to use apt to install and remove .deb packages?

Apt is the package manager utilized by Debian-based distributions, such as Ubuntu, Mint, or Kali. It manages .deb packages are compressed archives containing the software's binary files and control files. 

To use apt, you must open a terminal and execute the following commands:

which updates the list of available packages from the repositories;

Bash / Terminal
sudo apt update      

which installs a package by name;

Bash / Terminal
sudo apt install package_name       

which removes a package by name;

Bash / Terminal
sudo apt remove package_name       

which installs a package from a local .deb file;

Bash / Terminal
sudo apt install /path/to/file.deb       

which removes a package and its configuration files.

Bash / Terminal
sudo apt purge package_name       

after run apt update, run [apt list --upgradable] to see upgradable packages, and after that run [apt upgrade] to upgrade all of them. It is interesting to note that "apt" serves as a wrapper for the Debian package manager known as "dpkg". Gaining insight into the historical background of package managers and other tools not only helps understand the inner workings of Linux, but also improves one's skills for effectively addressing any issues that may occasionally arise with these tools.

How to use yum or dnf to install and remove .rpm packages?

Yum and dnf are the package managers used by Red Hat-based distributions, such as Fedora, CentOS, or RHEL. These managers work with .rpm packages, which are compressed archives that contain the binary files and the metadata of the software. 

To use yum or dnf, you need to open a terminal and use certain commands. For example, if you want to update the list of available packages from the repositories, then you should use

Bash / Terminal
sudo yum update   or  sudo dnf update 

If you want to install a package by name, then type in When you install the package using 

sudo apt install package_name and there are sub-packages/dependencies/permissions within the package prompting you to enter "Y/N" in the terminal to continue the installation. 

You can add "-y" (Yes) or "-n" (No) flag at the end of the original command, "sudo apt install package_name -y" to automate that step. 

At times when using 

Bash / Terminal
sudo apt install package_name 

command, there is a lot of output on the terminal which you might not be interested in. 

sudo yum install package_name       

or

Bash / Terminal
sudo dnf install package_name       

To remove a package by name, you can use

sudo yum remove package_name       

or

Bash / Terminal
sudo dnf remove package_name       

If you want to install a package from a local .rpm file, type in

Bash / Terminal
sudo yum localinstall /path/to/file.rpm       

or

Bash / Terminal
sudo dnf localinstall /path/to/file.rpm       

Lastly, if you want to remove a package and its dependencies, use

Bash / Terminal
sudo yum autoremove package_name       

or

Bash / Terminal
sudo dnf autoremove package_name       

How to use Pacman to install and remove .tar.gz packages?

Pacman is the package manager used by Arch-based distributions, such as Manjaro, EndeavourOS, or Arch Linux. It works with .tar.gz packages, which are compressed archives containing the binary files and metadata of the software. To use Pacman, you need to open a terminal and type in certain commands. For instance, to update the list of available packages from the repositories, type in

Bash / Terminal
sudo pacman -Syu       

To install a package by name, use

Bash / Terminal
sudo pacman -S package_name       

To remove a package by name, use

Bash / Terminal
sudo pacman -R package_name       

If you want to install a package from a local .tar.gz file, type in

Bash / Terminal
sudo pacman -U /path/to/file.tar.gz       

To remove a package and its dependencies, use

Bash / Terminal
sudo pacman -Rs package_name       

Pacman is an important tool for managing software on Arch-based distributions, and understanding how to use it is essential.

How to use snap to install and remove snap packages?

Snap is a universal package manager that works across different distributions and platforms with snap packages. These packages are compressed archives that contain the binary files and the isolation layer of the software, and are self-contained and sandboxed, making them have minimal impact on the system. To use snap, you need to open a terminal and use certain commands. For instance, to update the list of available packages from the snap store, you can use

Bash / Terminal
sudo snap refresh       

To install a package by name,

Bash / Terminal
sudo snap install package_name       

should be used, while

Bash / Terminal
sudo snap remove package_name       

is necessary to remove a package by name. Additionally, to install a package from a local .snap file, you can use

Bash / Terminal
sudo snap install /path/to/file.snap and snap list will list the installed snap packages.

How to use flatpak to install and remove .flatpak packages?

Flatpak is a universal package manager that works across different distributions and platforms. It uses .flatpak packages, which are self-contained, compressed archives with the binary files and runtime environment of the software, as well as having minimal impact on the system and running independently of the system libraries. 

To update the list of available packages from the flatpak repositories,

Bash / Terminal
sudo flatpak update       

To install a package by name,

Bash / Terminal
sudo flatpak install package_name       

To remove a package by name

Bash / Terminal
sudo flatpak uninstall package_name       
Bash / Terminal
sudo flatpak install /path/to/file.flatpak       
Sridhar S

Sridhar S

Cloud Admin

Cloud Admin - Chadura Tech Pvt Ltd, Bengaluru

Related Technical Articles

Explore additional architectural breakdowns in Linux.

M

Maya Solutions Architect

Ask about products & scoping →

WhatsApp Direct Help