cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:command:dnf.html



Linux Command#Software

How to use dnf Command in RHEL

Commands List

Command Objective Example
dnf -h
dnf check check rpm database
It will take a lot of time.
dnf clean all Clean all cached files from any enabled repository.


Repository Setting

Command Objective
dnf repolist ← only enable repository
dnf repolist all
Check Repository
dnf-config-manager Check Configuration
dnf-config-manager --enable REPO_NAME Enable Reposigory
dnf-config-manager --disable-repo REPO_NAME Disable repository
dnf-config-manager --add-repo REPO_URL Add Repository


Searching Packages

Command Objective Example
dnf search STRINGS Find any packages matching a string dnf search mysql
dnf search apache
dnf provides COMMAND/LIBRARY dnf provides nping
dnf provides libstdc++.so.5
dnf provides libgcc_s.so.1
dnf whatprovides XXXXX dnf whatprovides libstdc++.so.5
dnf info PACAGE Check Name, Arch, Version, Release, Description etc dnf info lxc
dnf deplist PACAGE check the dependences of the packages dnf deplist vnc-server
dnf deplist tree
dnf check-update Checks whether updates exist for packages that are already installed on your system.
dnf list Lists all packages that are available in all enabled repositories and all packages that are installed on your system.
You can confirm all rpm version.
dnf list |grep httpd
dnf list available dnf --disablerepo="*" --enablerepo="spp" list available
dnf list extras
dnf list installed It lists all the packages installed on the system.
You can confirm rpm version.
dnf list installed |grep openssh
rpm -qa --last | less
← How to check installed packege order by installed date
dnf list updates It lists the packages you can update
You can confirm rpm version.
dnf list updates |grep openssh


Install, Remove, Update Packages

Command Objective Example
dnf install PACKAGE
dnf -y install PACKAGE
dnf reinstall PACKAGE
dnf localinstall XXXX.rpm
dnf remove PACKAGE
dnf update ← update all packages
dnf update PACKAGE ← update only a package
dnf upgrade upgrade is the same as the update command with the --obsoletes flag set.
dnf download PACKAGE


dnf update and dnf upgrade

dnf update PACKAGE    <- update only a package 
dnf update            <- update all packages
dnf upgrade
  • OS minor version goes up
  • Kernel update is done

upgrade is the same as the update command with the –obsoletes flag set.
dnf update --obsoletes = dnf upgrade
The obsoletes option automatically removes packages that you no longer need.

Default /etc/dnf.conf
obsoletes=1   #Enable obsoletes option

dnf update = dnf upgrade


dnf Groups

Command Objective Example
dnf groups list (RHEL 7-)
dnf groups list hidden
dnf grouplist (- RHEL6)
dnf --noplugins groups list -v
Lists installed groups and groups
dnf groupinfo "GROUPNAME" Displays detailed information about a group.
dnf groupinstall "GROUPNAME" Installs all the packages in a group. dnf groupinstall "X Window System"
dnf groupinstall "GNOME Desktop Environment"
dnf groupremove "GROUPNAME" Removes all the packages in a group.
dnf groupupdate "GROUPNAME" Updates all the packages in a group.


etc

Command Objective Example
dnf history list all
dnf history info N
dnf history list all
dnf history info 8


TIPS

How to Use Proxy

temporary

export http_proxy=http://192.168.0.10:9999/
export https_proxy=http://192.168.0.10:9999/


/etc/dnf.conf

[main]
export http_proxy=http://192.168.0.10:9999/
[main]
proxy=http://xx.xx.xx.xx:8080
proxy_username=username
proxy_password=password


Check Reposistory in all repo files

# grep -E "\[*\]|name|baseurl" /etc/dnf.repos.d/*.repo


How to use only the specific repository

# dnf --disablerepo=* --enablerepo=test-repo repolist
# dnf --disablerepo=* --enablerepo=remi,epel search httpd


References




os/linux/command/dnf.html.txt · Last modified: 2024/04/11 by admin

Page Tools