Package Managers in Linux: The Basics Explained
Tags: linux, devops, ubuntu
Published: 2023-05-05 03:58:00

## Introduction

Software installation is a crucial aspect of any operating system, and it can differ significantly between different operating systems. In Windows, We install software by downloading installers or installing executable files. On the other hand, Linux manages software differently. It packages software into binaries and libraries. As Linux supports shared dependencies, it's not recommended to download software that has self-contained dependencies. We will see how package managers work and handle dependencies and the advantages of using them for software installation in Linux.

## What is a Software package?

The software package is the bundle of all required files and dependencies and other resources which are required to run the software. For running software smoothly users must have to install all required dependencies. Using the software package, all dependencies are bundled with the application so that users can simply install the package and all files and dependencies will automatically install. This eliminates the need for users to manually search for and install dependencies, which can be time-consuming.

## Why do we need a Package Manager?

The package manager helps to manage the all dependencies of the software which splits across different files and folders. It ensures that the integrity and authenticity of software is maintained. Moreover, package managers can manage and resolve all required dependencies automatically. This means that it takes the hassle out of manually searching for and installing all necessary dependencies. In addition, package managers know where to put binaries and library files in the Linux File System. As a result, it helps to prevent conflicts and confusion over where certain files should be stored.

## APT Package Manager in Linux

A package manager is already installed in every Linux distribution. In Ubuntu, we have an Advanced Packaging Tool – APT as a package manager. To download software from the repository, we use the `apt` command, which is usually listed in the software's guide or documentation. We can run the command sudo `apt install default-jdk` to install Java, which automatically downloads the required files and sets up the system.

The links to the repositories are stored in `/etc/apt/sources.list`, and when we run an `apt` command, Linux finds the appropriate repository link from this list and downloads the software from there. As we need sudo access to run the `apt` command, this helps ensure the security of the system. Overall, APT makes it easy to download and install software in Linux while maintaining the security of the system.

## APT vs APT-GET

APT and APT-GET are both package managers available on Linux distributions such as Ubuntu. APT is newer, more user-friendly, and recommended by Linux distros. APT has more organized commands than APT-GET and also provides detailed information about packages, which makes it easier to manage. APT is faster and more robust in handling errors and conflicts between packages, making it a better choice for most users. Although APT-GET is still widely used, APT is a great choice for those new to Linux or looking for a more efficient and streamlined way to manage their system's packages.

## Alternative Ways to Install Software

In Linux, downloading software using the package manager is the most common and preferred method. There are alternative ways to download software too. Here are the popular 3 methods for downloading software on Linux.

### 1\. Snap package manager

Snap package manager is a popular package manager available in Linux. It allows users to download software in a bundle that contains all the necessary dependencies. The software downloaded using Snap does not share the dependencies. In such cases, the dependencies download more than once, which makes the installation size large. Snap automatically updates the software packages which makes it convenient.

### 2\. Ubuntu software center

Ubuntu software center is Graphical User Interface (GUI) application to download and install software packages with ease. The software center uses Snap in the background, which downloads self-contained dependencies as Snap packages. It simplifies the installation process and takes care of all the necessary. In short, the Ubuntu software center is providing an intuitive user interface to browse and install software from an extensive collection of packages.

### 3\. Add the repo to the official list of repository

When the repo is not officially available in the Ubuntu repos list or on the Ubuntu software center, we can add the repo to the list. The `add-apt-repository` command is used to add a repository to the list of repositories in `/etc/apt/sources.list` and it will be used by `apt install <package-name>` command for installing it.

Personal Package Archives (PPAs) are software packages that are built and maintained by individuals in the community. Anybody can distribute the software using PPAs. Usually, developers use PPAs to provide updates more quickly than official Ubuntu repositories. It is important to be aware that PPAs do not go through the same screening process as the official Ubuntu repository, which means that there is no guarantee of security or quality.

## Conclusion

Using package manager we can easily install, upgrade, and remove software packages. Additionally, package managers ensure compatibility of the software with the operating system. In conclusion, the package manager is a crucial component of Linux that simplifies the software installation and management process with the stability and security of the system.