Open In App

dnf Command in Linux

Last Updated : 04 Nov, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Linux is a versatile operating system. It has many commands that can change the Linux working functionality of the operating system. Every Linux has a different package manager that helps us to install the software in the Linux operating system. The `dnf` command is a package manager command in Red-based Linux distros for example fedora, Cent OS and RHEL. It stands for "Dandified YUM," where YUM is another package manager commonly used in these distributions.

The syntax for the `dnf` command in Linux:

dnf [...COMMANDS] [...PACKAGES]

Commonly used commands in the 'dnf' package manager tool

Commands

Description

Search

This command helps us to search the package in the repository

install

This command installs the package in your computer system

info

This command returns the information about the package.

list

This command is used to display the list of the packages of certain criteria.

remove

This command removes the installed package from the computer system

upgrade

This command is used to upgrade all packages

history

The 'history' command shows the installed and removed history of the packages.

repolist

This command displays all the available repositories

deplist

This command shows the dependencies of the package.

1. `Search` and `install` the package with dnf command

In this example, we will install tigervnc package in fedora linux. Before installing the package we will search the package.

Command:

dnf search tigervnc

Example:

Image1

Once you find your package use the dnf search command. you can use the `install` command for installing that package in your linux distro. Here's an example of this command.

Command:

dnf install tigervnc

Example:

Image2

2. See the information of the package using the 'info' command

We can see the information about the package using the `info` command. Here's an example of this command.

Command:

dnf info tigervnc

Example:

Image3a

3. List the installed package using the 'list installed' command.

You can see all installed packages using the `dnf` command with the `list` command with the installed parameter. Here, we are using this command with the `head` command. You can use the 'head' command to display only the first few lines of the output

Command:

dnf list installed |  head

Example:

Image4

4. Remove a package using the 'remove' command.

You can remove the package using the 'remove' command in linux. Here's an example of this command.

Command:

sudo dnf remove tigervnc

Example:

Image5

5. Upgrade a Package using the 'upgrade' command.

You can upgrade the package using the `upgrade` command in linux. Here's an example of this command.

Command:

sudo dnf upgrade

Example:

Image6

You can upgrade the specific package using this command.

  sudo dnf upgrade package_name

Here's an example of this command:

Image7

6. View the history installed or remove the package using the 'history' command.

Sometimes It is tedious to write the same command once again. In dnf command solve this problem using the history feature. We can see the history of installing and removing packages using the `dnf` command.

Command:

dnf history

Example:

Image8

7. View the available repository using the 'repolist' command.

The dnf repolist command is used to list the available repositories on your system. It's a helpful command to check which repositories are enabled and what packages are accessible through them. Here's an example of this command.

Command:

sudo dnf repolist

Example:

Image9

8. View the dependencies using the 'deplist' command

The dnf delist command in Linux is used to display the dependency information for a specific package. This command provides a detailed list of dependencies for a package, including both its runtime and build-time dependencies. Here's an example of this command.

Command:

dnf deplist tigervnc

Example:

Image10

Conclusion

In this article, we have learned the `dnf` command. This command is very useful when you are installing and removing the package in Red-hat-based linux distros. Example fedora etc. This command performs many tasks such as installing the package, removing the package, searching the package, updating the software, and much more.


Next Article

Similar Reads

three90RightbarBannerImg
  翻译: