dnf命令安装

Installation of DNF

DNF in not available in the default repository of RHEL/CentOS 7. However Fedora 22 ships with DNF implemented officially.

To install DNF on RHEL/CentOS systems, you need to first install and enable epel-release repository.

# yum install epel-release
OR
# yum install epel-release -y

Though it is not ethical to use ‘-y‘ with yum as it is recommended to see what is being installed in your system. However if this does not matter you much you may use ‘-y’ with yum to install everything automatically without user’s intervention.

Next, install DNF package using yum command from epel-release repository.

# yum install dnf

After dnf installed successfully, it’s time to show you 27 practical usage of dnf commands with examples that will help you to manage packages in RPM based distribution easily and effectively.

1. Check DNF Version

Check the version of DNF installed on your System.

# dnf --version

Check DNF Version

2. List Enabled DNF Repositories

The option ‘repolist‘ with dnf command, will display all enabled repositories under your system.

# dnf repolist

Check All Enabled Repositories

3. List all Enabled and Disabled DNF Repositories

The option ‘repolist all‘ will print all the enabled/disabled repositories under your system.

# dnf repolist all

List All Enabled/Disabled Repositories

4. List all Available and Installed Packages using DNF

The command “dnf list” will list all the available packages from all the repositories and installed packages on your Linux system.

# dnf list

List All Packages using DNF

5. List all Installed Packages using DNF

While the “dnf list” command shows all the available/installed packages from all the repositories. However, you have the option to list only the installed packages using option “list installed” as shown below.

# dnf list installed

List All Installed Packages

6. List all Available Packages using DNF

Similarly, the “list available” option, will list all the packages available to be installed from all the enabled repositories.

# dnf list available

List Available Packages using DNF

7. Search for a Package using DNF

If incase, you’ve no idea about the package that you want install, in such situation you may use ‘search‘ option with dnf command to search for the package that matches the word or string (say nano).

# dnf search nano

Search Package by Word

8. See what Provides a file/sub-package?

The dnf option “provides” find the name of the package that provides specific file/sub-package. For example, if you would like to find what provides ‘/bin/bash‘ on your system?

# dnf provides /bin/bash

Find File Sub Package

9. Get Details of a Package using DNF

Let’s assume you want to know the information of a package before installing it on the system, you may use “info” switch to get a detailed information about a package (say nano) as below.

# dnf info nano

Check Package Information with DNF

10. Install a Package with DNF

To install a package called nano, just run the below command it will automatically resolve and install all required dependencies for package nano.

# dnf install nano

Install Package using DNF

11. Updating a Package using DNF

You may update only a specific package (say systemd) and leave everything on the system untouched.

# dnf update systemd

Update a Specific Package

12. Check for System Updates using DNF

Check updates for all the system packages installed into the system simply as.

# dnf check-update

Check For System Update

13. Update All System Packages using DNF

You may update the whole system including all the installed packages with following commands.

# dnf update
OR
# dnf upgrade

Update System

14. Remove/Erase a Package using DNF

To remove or erase any unwanted package (say nano), you may use “remove” or “erase” switch with dnf command to remove it.

# dnf remove nano
OR
# dnf erase nano

Remove Package in Linux

15. Remove Orphan Packages using DNF

Those packages that were installed to satisfy dependency may be useless if not being used by other applications. To remove those orphan packages execute the below command.

# dnf autoremove

Remove Orphan Packages

16. Remove Cached Packages using DNF

A lot of time we encounter out-of-date headers and unfinished transactions which results into error while executing dnf. We may clean all the cached packages and headers containing remote package information simply by executing.

# dnf clean all

Remove DNF Cache

17. Get Help on Specific DNF Command

You may get help of any specific dnf command (say clean) just by executing the below command.

# dnf help clean

Get DNF Command Help

18. List all DNF Commands and Options

To list help on all available dnf commands and option simply type.

# dnf help

Get Help on DNF Options

19. View History of DNF

You may call dnf history to look at the list of already executed dnf commands. This way you can be aware of what was installed/removed with time stamp.

# dnf history

Check DNF History

20. List all Group Packages

The command “dnf grouplist” will print all available or installed packages, if nothing is mentioned, it will list all known groups.

# dnf grouplist

List All Group Packages

21. Install a Group Package using DNF

To install a Group of packages bundled together as group package (say Educational Software) simply as.

# dnf groupinstall 'Educational Software'

Install Group Packages

22. Update a Group Package

Let’s update a Group Package (say Educational Software) by executing the below command.

# dnf groupupdate 'Educational Software'

Update Group Package

23. Remove a Group Package

We can remove the group Package (say Educational Software) as.

# dnf groupremove 'Educational Software'

Remove Group Package

24. Install a Package from Specific Repository

DNF makes it possible to install any specific package (say phpmyadmin) from a repo (epel) as simply as,

# dnf --enablerepo=epel install phpmyadmin

Install Package From Specific Repo

25. Synchronize Installed Packages to Stable Release

The command “dnf distro-sync” will provides necessary options to synchronize all installed packages to most recent stable version available from any enabled repository. If no package is selected, all installed packages are synchronized.

# dnf distro-sync

Synchronize Packages to Stable Version

26. Reinstall a Package

The command “dnf reinstall nano” will reinstall an already installed package (say nano).

# dnf reinstall nano

ReInstall Package

27. Downgrade a Package

The option “downgrade” will downgrades the named package (say acpid) to lower version if possible.

# dnf downgrade acpid
Sample Output
Using metadata from Wed May 20 12:44:59 2015
No match for available package: acpid-2.0.19-5.el7.x86_64
Error: Nothing to do.

My observation: DNF does not downgraded the package as it is supposed to. It has also been reported as bug.

转自:http://www.tecmint.com/dnf-commands-for-fedora-rpm-package-management/

转载于:https://my.oschina.net/u/2279209/blog/606909

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值