If you work in Linux, you must know about package management in Linux. Package management helps install and maintain the software system. Apart from installing and maintaining the software system, package management also helps update software instances and probably remove them as well. If any specific package requires precise resources like a shared library or any other package, then it is said to have a dependency. The latest package management systems are capable of providing dependency resolution methods to check if the package is installed. Basically, package management is the way to get any application, service, library, and package onboarded on the Linux system or offboarded from the Linux system. It is a must to know about package management in Linux to work in it. Let’s explore package management in Linux.
We have created this post to strengthen your knowledge of package management in Linux. We will start from basic: what is a package, repositories, and popular packages, and all the way up to how to determine which package is right for your Linux distribution.
What Are the Packages?
Packages are developed to combat the complexity associated with the data file. Packages can collect various data files together into a single and easily accessible file to make sure that it remains easily portable. The package systems are developed around the process collection of package files, and petrified is referred to as an archive file containing the compiled binaries and other resources.es.
The packages also provide convenience while storing and easily compress the file to limit their storage space. Binaries in packages are also precompiled according to the sane defaults chosen by the developer. Packages also input meta-data like software name, description, the version number of the software, and list of essential dependencies required by the software to run.
Various instances of Linux have developed their package manager formats, and some of the highly concerned ones are-
- ..Deb: this package format is utilized by Ubuntu. Debian, Linux Mint, and various other derivatives in the same segment.
- .rmp: this format was initially known as Red Hat package manager, and it is utilized by Red Hat, Fedora, SUSE, and various other distributions
- .tar.xz: the Arch Linux uses this package format, and it is just compressed tarball
What Are Software Repositories?
Software repository refers to a centralized collection and listing of available software (packages) for the corresponding system or any other repository system which has been configured successfully to use. For example, for searching in a repository for any specific package, Arch Linux with Airman.
What Are the Popular Package Managers?
Package managers are used to interacting with the software repositories. Let us go through some of the package managers –
- RPM Package Manager (Red-Hat Package Manager): RPM Package Manager is a program for installing, uninstalling, and managing software packages in Linux. The “RPM” part of this term comes from.rpm, which is the default extension for files used by the program.
- Debian-based package manager: It uses. Deb packages and can be easily managed by the tool called dpkg. It was designed to maintain the packages available locally effectively. This project package is commissioned with another package called Deity, to improve user experience.
- Arch-based package managers: Arch Linux utilizes a package manager known as Pacman, and unlike .rpm or .deb, Pacman uses a traditional tarball with the help of LZMA2 compression (tar.xz). This utility enables the packages to be smaller as compared to the other compressed archives.
How to Identifying Compatible Packages for Your Linux Distribution?
Linus OS is traditionally involved with coders and programmers as a reliable operating system. However, it is continually attempting to be attractive to the masses. The LINUX operating system comes in multiple forms known as distros or flavors. The reason behind this factor is that it is configurable, and different platforms tend to develop the same interest. They also support cloud-based applications, which may usually run through a browser. It has a variety of ranges, especially for bundled software. Linux OS is customizable, and it has specific functions that are far beyond and standard Mac or Windows utility. There are multiple concerns for which it is essential to determine which Linux distro can work best for you. Like
- Do you require GUI familiar with Windows
- What about security
- Typing commands or clicking the icons
Identifying Which One Is Right
There are multiple packages, desktop managers, and distribution systems out of which you have to choose the right distribution system. To find the compatible package, invest time into downloading and trying out multiple distros. You can start this with the top 10 systems and then try them one by one.
The compatible packages in Linux distro are-
- Arch Linux: Arch Linux package uses pkg.tar.xz , and it also has its manager known as Pacman. It also does not have a graphical installer where the actual installation process is done with the help of a terminal.
- Gentoo Linux: Gentoo Linux package is based upon the portage package management system, and it can be a little difficult to install. But the ultimate advantage is that software can be built for specific hardware.
- Slackware Linux: it is the oldest Linux distribution system that is also used today, and it doesn’t have a package manager in it where all the system administrator compiles all the software.e.
- Graphical user involvement: The graphical user interface or desktop environment is displayed on the monitor, and it is how the actual system looks. Some of the popular tests of managers in this segment are Cinnamon, XFCE, KDE, LXDE, Gnome, and a lot more.
- KDE: This system was initially created in the year 1996, and it has probably the most advanced features in the market. KDE, by default, includes multiple applications required by most of the users to access compatible desktop environments. Some popular package management distributions used in this segment are- OpenSuse, Slackware, Linux Mint, Kubuntu, and Mageia.
- Gnome: This package management system is developed by the community. And especially for the community, It can easily be expanded as per the requirement with the help of its plugin. Genome also doesn’t require various resources. And, it is a great choice for old hardware. The prominent distribution systems used in Gnome are- Debian, OpenSuse, Fedora, and CentOs.
Installing, Updating, Removing Repositories, Dependencies, and Packages
Even if the software is not packaged for any operating system officially. The developer or vendor will offer the package files for its download. In this case, you can easily use the retrieved files with your web browser or Via ‘curl’ on the command line. Once the package is established on the targeting system, then it can be installed with a single command.
On Debian systems, ‘dpkg’ can handle individual package files. If the package has unmet dependencies, then ‘gdebi can also be used to retrieve the file from official repositories. On Fedora and CentOS systems, ‘yum’ and ‘dnf’ can be used to install the individual files, and it can also bundle required dependencies. The different system has their different command lines, which are mentioned below:
- Debian / Ubuntu: sudo dpkg’ -i package.deb, sudo apt-get install -y gdebi && sudo gdebi package.deb (installation andusing’gdebi’ to install package.deb while retrieving any other missing dependencies)
- CentOS: sudo yum install package.rpm
- Fedora: sudo dnf install package.rpm
- FreeBSD packages: sudo pkg add package. txz, Sudo pkg add -f package. txz (install package even if it is installed)
Without any package system, it is tough to make sure that the entire installed software system on the machine remains updated. It also is essential to track the upstream changes and other security notifications for packages. The package manager can solve small troubles or other problems that you may encounter while updating software. Upgrading the package can introduce various changes and require manual configuration. You have to read usr/ports/UPDATING before upgrading with ‘portmaster. Some of the systems and their commands are mentioned below.
sudo apt-get upgrade.
Only upgrade the installed packages whenever possible
Sudo apt -get dist- upgrade
It may add or remove the packages to satisfy the dependencies
Sudo apt upgrade
Like apt-get upgrade
Sudo apt full -upgradeLike apt- get dist -upgrade
Sudo yum update
Sudo dnf upgrade
Sudo pkg upgrade
You can use less’ to view the updated notes for the ports (use Arrow keys to scroll and press q whenever you want to quit)Cd/ usr/ports/ports-mgmt/portmaster && sudo make install && sudo postmaster -a
Install ‘postmaster’ and then use it to install the ports
Updatingpackage index: The package index is a database of all the available packages from repositories, and it is defined in /etc/apt/sources list file. It is also defined in /etc/apt/sources.list.d directory of the repository, and to update the local package index with all the latest modifications in the repository, you have to type: Sudo apt update
Upgrading packages: Gradually, with time, the updated versions of dependencies are packages installed on your system, which can also become available from package repositories. to upgrade your system, you have to initially upgrade the package index (mentioned above) and then type- Sudo apt upgrade
Removal of the repositories or packages is a straightforward process, and to remove any installed version, you have to type
sudo apt remove nmap
To remove multiple packages, you have to specify if they are installed or removed and then separate them by spaces.
Apt-get is a command-line tool, and it is used interactively. This command is issued with scripts, and passing any basic command syntax of the tools remains the same. While adding the purge option to apt remove instantly configuration files. All the actions of apt commands like installation for removal of the packages, dependencies for repositories are log in /var/log/dpkg log log file.
Finding Which Package Installed Which File:
Most of the time, before the installation, it becomes crucial to know the belongings of the package file or its location. There are a variety of ways in which you can find out which package is installed or belongs to a file.
Apt file to find out the package providing file:
The APT file can index the contents of the package and files available in repositories and allow you to search for all the packages. You can use this to search inside DEB packages installed in your system as well as for the packages which are not in your machine but they are available to install from repositories.
- The Apt file cannot check for the package that provides the file in case you download the package and install it without a repository. This package needs to be present in the repositories for the file to be able to find it.
- The Apt file might not be on your system, and to install it on the Linux distribution systems, you have to use the command-
Sudo apt install apt-file
To update the database, you have to use
Sudo apt-file update
Dpkg to Find the Package Providing File:
This can be used to find the files belonging to a package, and it is faster to use as compared to the former. Dpkg can actively search for the files belonging to installed packages, but if you are looking for a file that’s not installed in your machine, then you have to use apt-file.
To use dpkg to find installed packages providing the file address, you have to run it with (-S or –search) flag, which is also followed by the file name you wish to see if the package belongs to.
For example, find out the package, Cairo.h belongs to (using dpkg )Similar to Apt-file, this also shows multiple packages having files containing the name you have searched. You have to provide the full path of the file to gain access to the package containing the specific name. For example-
There are some commands through which you can easily find out which package is on a particular file. Some steps that you have to follow are:
- First, open the terminal application with Ctrl +Alt + t
- Now you have to type this command to find which package can provide /use/bin/passed file
Dpkg -S /usr/bin/passed
- Use the Apt file package for searching the utility-
Apt-file search vim
Find the package providing fileYou can easily search for the filename from the installed packages list using the command (dpkg -S). For example, to find the package name /bin/Is you have to enter-
$ dpkg -S /bin/Is
The options like -S or -search actively search for the entered file name from installed packages and by adding the below mentioned coming you can obtain further details regarding the status of the file name for the package.
$ dpkg -S coreutils
Dpkg query command
The dpkg query command is a powerful tool that can show the status information regarding the packages listed in the database of dpkg. The option -S search for the filename from all the installed packages and standard shell wild-chars can be utilized in the same pattern. This command cannot list additional files developed by the maintenance scripts also it will not list any of its alternatives.
We hope this post would help you explore package management in Linux. Thanks for reading this post. Visit our social media page on Facebook, LinkedIn, Twitter, Telegram, Tumblr, & Medium and subscribe to receive updates like this.