In Linux, there are multiple ways to install a package. This can be confusing for new users, especially since the commands used to install packages vary depending on the distribution of Linux that you are using.
In this blog post, we will discuss five different ways to install packages in Linux: using the rpm command, using the yum command, using apt command, using dnf command, and using a graphical interface. Let’s get started!
Table of Contents
Install Packages with rpm command in Linux
The rpm command is used to install, upgrade, and remove packages in Red Hat Enterprise Linux, CentOS, Fedora, and other RPM-based distributions. To install a package using the rpm command, you will need to use the following syntax:
rpm -ivh package_name.rpm
Get Your Free Linux training!
Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!Before installing an RPM package, you need to first download the package on your system or provide the URL to the RPM package to the rpm command: sudo rpm -ivh https://example.com/package.rpm
For example, to install the OpenSSH, you would use the following command: rpm -ivh openssh.rpm
The rpm command has a variety of options that you can use to manage packages. Some of the most common options are listed below:
- -i: This option is used to install packages.
- -v: This option is used to view the package information.
- -h: This option is used to display the help menu.
- -U: This option is used to upgrade packages.
- -e: This option is used to remove packages.
Install Packages with yum command in Linux
The low-level rpm command can be used to install packages, but it is not designed to work with package repositories or resolve dependencies from multiple sources automatically.
Yum is a package management tool used in Linux distributions based on Red Hat Enterprise Linux (RHEL), CentOS and Fedora. Yum provides an easy way to install, update, and remove software packages from your system.
You can get a history of transactions performed and work with multiple Red Hat and third-party software repositories.
To use yum, you will need to use the following syntax: yum install package_name
The yum repo is a repository of software packages that can be installed using the yum command. The yum repo is usually located on a server and contains a list of software packages that can be installed on your system.
Software repositories are usually used over the internet and can be accessed by multiple users worldwide.
For example, to install the Firefox web browser, you would use the following command: yum install firefox
One of the most important options that you can use with the yum command is the -y option, which will automatically answer “yes” to all of the questions asked by yum. This can be helpful when you are installing or updating multiple packages at once, as it will save you from having to type “yes” every time a question is asked by yum.
- To see the list of installed packages, you can use the list installed command of YUM: yum list installed
- To see current repos: yum repolist
- To see the package info in repo: yum info <package name>
- To see locally installed info comparison: rpm -qi <package name>
- To remove a single package: yum remove <package name>
Actions of the yum command, such as installation and removal of packages, are logged in the /var/log/yum.log log file.
Install Packages with APT command in Linux
The apt command is used to install, upgrade, and remove packages in Debian and Ubuntu-based distributions.
To install a package using the apt command, you will need to use the following syntax: apt install package_name.
The “apt” command can be used to install software packages from a software repository (such as the “Ubuntu Software Center”). The apt command will first check to see if the software package is available in the repository, and then download and install it on your system.
For example, to install the Firefox web browser in Ubuntu, you would use the following command: apt install firefox
The apt command also has a variety of options that you can use to manage packages.
The apt command can also be used to upgrade software packages that are already installed on your system. To upgrade a package using the apt command, you will need to use the following syntax: apt upgrade package_name.
To remove a package using the apt command, you will need to use the following syntax: apt remove package_name.
Actions of the apt command, such as installation and removal of packages, are logged in the /var/log/dpkg.log log file.
Install Packages with DNF command in Linux
The DNF command (Dandified yum) is the next-generation version of the traditional YUM package manager for RedHat based systems. It is the default package manager for Fedora 22, CentOS8, and RHEL8. It is intended to be a replacement for YUM. It does Package Management using RPM and libsolv (maintained by OpenSUSE).
The dnf command is similar to the yum command, but it has a few new features that make it more efficient and user-friendly. For example, the dnf command can check for dependencies and conflicts before installing a software package.
- To install a package using the dnf command: dnf install package_name.
- To upgrade a package using the dnf command: dnf upgrade package_name.
- To remove a package using the dnf command: dnf remove package_name.
Install Packages with Graphical Interface in Linux
If you are using a Linux distribution that has a graphical interface, such as Ubuntu, you can also install packages using the graphical package manager. To do this, open the package manager and search for the package you want to install. Then, simply click “Install” and the package will be installed on your system.
As you can see, there are multiple ways to install packages in Linux. Which method you use will depend on your distribution of Linux and your personal preferences. Experiment with each method to find the one that works best for you.
If you have any questions about installing packages in Linux, feel free to leave a comment below and we will be happy to help. Thanks for reading!