howtouselinux

5 ways to install package in Linux

Table of Contents

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!

Install Package 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

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 Package with yum command in Linux

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.

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
  • To remove a package with dependencies: yum autoremove <pkg>

 

Install Package 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-get 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. Some of the most common options are listed below:

  • -s: This option is used for simulation mode. It will not actually install or remove any packages, but will show you what would happen if you did.
  • -y: This option is used to automatically answer yes to all questions asked by apt.
  • -q: This option is used to query information about 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-get upgrade package_name.

To remove a package using the apt command, you will need to use the following syntax: apt-get remove package_name.

Install Package 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, you will need to use the following syntax: dnf install package_name.
  • To upgrade a package using the dnf command, you will need to use the following syntax: dnf upgrade package_name.
  • To remove a package using the dnf command, you will need to use the following syntax: dnf remove package_name.

 

Install Package 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!

David Cao
David Cao

Hey there! I am David, a Cloud & DevOps Enthusiast and 18 years of experience as a Linux engineer. I work with AWS, Git & GitHub, Linux, Python, Ansible, and Bash. I am a technical blogger and a Software Engineer, enjoy sharing my learning and contributing to open-source.