update: 2021-1 yum -> dnf
hostnamectl; # tested on Virtualization: kvm Operating System: CentOS Linux 8 CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 5.4.11 Architecture: x86-64 ll /usr/bin/yum -> dnf-3
all those yum commands still work with dnf (nice work!)
DNF or Dandified YUM[2][3][4] is the next-generation version of the Yellowdog Updater, Modified (yum), a package manager for .rpm-based distributions. DNF was introduced in Fedora 18 in 2013,[5] it has been the default package manager since Fedora 22 in 2015[6] and Red Hat Enterprise Linux 8.[7] (src)
https://github.com/rpm-software-management/dnf
What is yum?
yum is used under CentOS7, Fedora, RedHat RHEL, Oracle).
It’s written in python and it stands for “Yellowdog Updater, Modified”, as it was originally called “yup”, the package manager for Yellow Dog Linux.
In addition to rpm it provides an “App Store” so to speak – the possibility to search an online repository and download and install packages (like apt) from those repositories provided by volunteers (thanks a lot).
it tries to satisfy dependencies automatically. (install additional packages needed by the package that is supposed to be installed)
yum commands are typically run as
yum <command> <package name/s>
By default, yum will automatically attempt to check all configured repositories to resolve all package dependencies during an installation/upgrade.
The following is a list of the most commonly-used yum commands. For a complete list of available yum commands, refer to man yum.
-
yum install <package name/s>
Used to install the latest version of a package or group of packages. If no package matches the specified package name(s), they are assumed to be a shell glob, and any matches are then installed.
-
yum update <package name/s>
Used to update the specified packages to the latest available version. If no package name/s are specified, then yum will attempt to update all installed packages. If the –obsoletes option is used (i.e. yum –obsoletes <package name/s>, yum will process obsolete packages. As such, packages that are obsoleted accross updates will be removed and replaced accordingly.
-
yum check-update
# list all available repositories yum -v repolist
This command allows you to determine whether any updates are available for your installed packages. (comparable to apt-get update) yum returns a list of all package updates from all repositories if any are available.
-
yum remove <package name/s>
- Used to remove specified packages, along with any other packages dependent on the packages being removed.
-
yum provides <file name>
Used to determine which packages provide a specific file or feature.
-
yum search <keyword>
This command is used to find any packages containing the specified keyword in the description, summary, packager and package name fields of RPMs in all repositories.
-
yum localinstall <absolute path to package name/s>
Used when using yum to install a package located locally in the machine.
src: https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-yum-useful-commands.html
Useful flags
Assume yes for all prompts
--y
Assume no for all prompts
--assumeno
Disable GPG verification
--nogpgcheck
Skip broken packages
Skips packages that whose dependencies can’t be resolved.
--skip-broken
Enable/Disable repository
You can dynamically enable or disable a repository for a single execution.
--disable-repo=[path]
--enable-repo=[path]
Package Management
Installing an RPM package
Installing an RPM package from remote repositories
$ sudo yum install [package-name]
Installing a local RPM package
$ sudo yum install /path/to/vim-1.2.rpm
Installing a specific version of a package
$ sudo yum install gcc-4.0
Removing an RPM package and dependencies
Removes a package and any package it depends on (provided nothing else depends on it).
$ sudo yum remove [package-name]
Note: this will only remove the binaries and libraries, any configuration files will stay intact.
Downgrade a package
This will install the package’s previous version.
$ sudo yum downgrade [package-name]
View a package’s dependencies
$ sudo yum deplist [package-name]
Listing packages
The yum list command can take different arguments:
List all available packages from repositories
$ sudo yum list available
List installed packages
$ sudo yum list installed
List installed and available packages
$ sudo yum list all
List all packages (installed or available) that match a given [package-name], can be a glob
$ sudo yum list [package-name]
$ sudo yum list mysql*
Search for package
This searches for [package-name] across all repositories, also looking inside package descriptions.
$ sudo yum search [package-name]
if that does not return any usefull results try:
# SearchTerm = xclock yum provides */xclock repoquery -q -f */xclock xorg-x11-apps-0:7.7-6.el7.x86_64
btw: if your xclock is not “ticking” you will need to fire it up via command line/bash with the -update 1 (update every 1seconds) parameter…
Upgrade all system packages
$ sudo yum upgrade
This command installs all of the latest versions of each package installed on the system and is, generally, not recommended to be run on production systems.
Reinstall a single package
Sometimes, it’s necessary to force reinstallation of a package.
$ sudo yum reinstall [package-name]
View info for a package
# get infos about NameOfPackage yum info NameOfPackage # get info about package: alternative example: repoquery -i lvm2.x86_64 Name : lvm2 Version : 2.02.180 Release : 10.el7_6.8 Architecture: x86_64 Size : 3110931 Packager : CentOS BuildSystem <http://bugs.centos.org> Group : System Environment/Base URL : http://sources.redhat.com/lvm2 Repository : updates Summary : Userland logical volume management tools Source : lvm2-2.02.180-10.el7_6.8.src.rpm Description : LVM2 includes all of the support for handling read/write operations on physical volumes (hard disks, RAID-Systems, magneto optical, etc., multiple devices (MD), see mdadm(8) or even loop devices, see losetup(8)), creating volume groups (kind of virtual disks) from one or more physical volumes and creating one or more logical volumes (kind of logical partitions) in volume groups. yum info lvm2.x86_64 Installed Packages Name : lvm2 Arch : x86_64 Epoch : 7 Version : 2.02.180 Release : 10.el7_6.8 Size : 3.0 M Repo : installed From repo : updates Summary : Userland logical volume management tools URL : http://sources.redhat.com/lvm2 License : GPLv2 Description : LVM2 includes all of the support for handling read/write operations on : physical volumes (hard disks, RAID-Systems, magneto optical, etc., : multiple devices (MD), see mdadm(8) or even loop devices, see : losetup(8)), creating volume groups (kind of virtual disks) from one : or more physical volumes and creating one or more logical volumes : (kind of logical partitions) in volume groups.
Find which RPM package installs a given file
This command is very handy when it’s not obvious which package needs to be installed to use it.
$ sudo yum provides [file]
yum provides can also take a glob:
$ sudo yum provides "*/bin/vim"
List all dependencies for a given package
$ sudo yum provides [package-name]
Package Groups
Note: yum now has a groups subcommand for group operations, versions before 3.4.x should refer to this document instead.
yum has the concept of “package groups”, groups of related packages that can be installed or uninstalled at once, that don’t necessarily depend on each other.
List all groups
$ sudo yum group list
Install all packages for a group
$ sudo yum group install "Basic Web Server"
Remove all packages for a group
$ sudo yum group remove "Basic Web Server"
Repository Management
List all repositories
$ sudo yum repolist
List all packages for a given [repository]
(Note: yum > 3.4.x only)
$ sudo yum repo-pkgs [repository] list
Install all packages from given [repository]
(Note: yum > 3.4.x only)
$ sudo yum repo-pkgs [repository] install
Remove all packages from a given [repository]
(Note: yum > 3.4.x only)
$ sudo yum repo-pkgs [repository] remove
Update local metadata cache
This is run automatically by yum as needed, but can be refreshed manually with yum makecache
$ sudo yum makecache
When this command is run, all available packages are fetched and re-indexed from the repositories yum knows about.
yum-utils and yumdownloader
In order to download source packages, it’s necessary to install an additional package for yum, called “yum-utils”, which provides a yumdownloader binary, among other things.
yum install yum-utils;
Downloading RPMs
Downloading RPM from remote repositories
$ sudo yumdownloader [package-name
Downloading Source RPMs
$ sudo yumdownloader --source [package-name]
Downloading all dependencies for an RPM
$ sudo yumdownloader --resolve [package-name]
Filtering by architecture
$ sudo yumdownloader --archlist=[arch-list] [package-name]
More
yum-utils adds other useful commands to yum that are too specific to cover here but are still worth looking over at the YumUtils website.
what files are in/come with/provided/belong by/to this package?
if manually downloaded
rpm -qlp /path/to/file.rpm
from repository:
repoquery --list lvm2.x86_64
/etc/lvm
/etc/lvm/archive
/etc/lvm/backup
/etc/lvm/cache
/etc/lvm/cache/.cache
/etc/lvm/lvm.conf
/etc/lvm/lvmlocal.conf
/etc/lvm/profile
/etc/lvm/profile/cache-mq.profile
/etc/lvm/profile/cache-smq.profile
/etc/lvm/profile/command_profile_template.profile
/etc/lvm/profile/lvmdbusd.profile
/etc/lvm/profile/metadata_profile_template.profile
/etc/lvm/profile/thin-generic.profile
/etc/lvm/profile/thin-performance.profile
/run/lock/lvm
/run/lvm
/usr/lib/systemd/system-generators/lvm2-activation-generator
/usr/lib/systemd/system/lvm2-lvmetad.service
/usr/lib/systemd/system/lvm2-lvmetad.socket
/usr/lib/systemd/system/lvm2-lvmpolld.service
/usr/lib/systemd/system/lvm2-lvmpolld.socket
/usr/lib/systemd/system/lvm2-monitor.service
/usr/lib/systemd/system/lvm2-pvscan@.service
/usr/lib/tmpfiles.d/lvm2.conf
/usr/lib/udev/rules.d/11-dm-lvm.rules
/usr/lib/udev/rules.d/69-dm-lvm-metad.rules
/usr/sbin/fsadm
/usr/sbin/lvchange
/usr/sbin/lvconvert
/usr/sbin/lvcreate
/usr/sbin/lvdisplay
/usr/sbin/lvextend
/usr/sbin/lvm
/usr/sbin/lvmconf
/usr/sbin/lvmconfig
/usr/sbin/lvmdiskscan
/usr/sbin/lvmdump
/usr/sbin/lvmetad
/usr/sbin/lvmpolld
/usr/sbin/lvmsadc
/usr/sbin/lvmsar
/usr/sbin/lvreduce
/usr/sbin/lvremove
/usr/sbin/lvrename
/usr/sbin/lvresize
/usr/sbin/lvs
/usr/sbin/lvscan
/usr/sbin/pvchange
/usr/sbin/pvck
/usr/sbin/pvcreate
/usr/sbin/pvdisplay
/usr/sbin/pvmove
/usr/sbin/pvremove
/usr/sbin/pvresize
/usr/sbin/pvs
/usr/sbin/pvscan
/usr/sbin/vgcfgbackup
/usr/sbin/vgcfgrestore
/usr/sbin/vgchange
/usr/sbin/vgck
/usr/sbin/vgconvert
/usr/sbin/vgcreate
/usr/sbin/vgdisplay
/usr/sbin/vgexport
/usr/sbin/vgextend
/usr/sbin/vgimport
/usr/sbin/vgimportclone
/usr/sbin/vgmerge
/usr/sbin/vgmknodes
/usr/sbin/vgreduce
/usr/sbin/vgremove
/usr/sbin/vgrename
/usr/sbin/vgs
/usr/sbin/vgscan
/usr/sbin/vgsplit
/usr/share/doc/lvm2-2.02.180
/usr/share/doc/lvm2-2.02.180/README
/usr/share/doc/lvm2-2.02.180/VERSION
/usr/share/doc/lvm2-2.02.180/WHATS_NEW
/usr/share/doc/lvm2-2.02.180/lvm_fault_handling.txt
/usr/share/licenses/lvm2-2.02.180
/usr/share/licenses/lvm2-2.02.180/COPYING
/usr/share/licenses/lvm2-2.02.180/COPYING.LIB
/usr/share/man/man5/lvm.conf.5.gz
/usr/share/man/man7/lvmcache.7.gz
/usr/share/man/man7/lvmraid.7.gz
/usr/share/man/man7/lvmreport.7.gz
/usr/share/man/man7/lvmsystemid.7.gz
/usr/share/man/man7/lvmthin.7.gz
/usr/share/man/man8/fsadm.8.gz
/usr/share/man/man8/lvchange.8.gz
/usr/share/man/man8/lvconvert.8.gz
/usr/share/man/man8/lvcreate.8.gz
/usr/share/man/man8/lvdisplay.8.gz
/usr/share/man/man8/lvextend.8.gz
/usr/share/man/man8/lvm-config.8.gz
/usr/share/man/man8/lvm-dumpconfig.8.gz
/usr/share/man/man8/lvm-fullreport.8.gz
/usr/share/man/man8/lvm-lvpoll.8.gz
/usr/share/man/man8/lvm.8.gz
/usr/share/man/man8/lvm2-activation-generator.8.gz
/usr/share/man/man8/lvmconf.8.gz
/usr/share/man/man8/lvmconfig.8.gz
/usr/share/man/man8/lvmdiskscan.8.gz
/usr/share/man/man8/lvmdump.8.gz
/usr/share/man/man8/lvmetad.8.gz
/usr/share/man/man8/lvmpolld.8.gz
/usr/share/man/man8/lvmsadc.8.gz
/usr/share/man/man8/lvmsar.8.gz
/usr/share/man/man8/lvreduce.8.gz
/usr/share/man/man8/lvremove.8.gz
/usr/share/man/man8/lvrename.8.gz
/usr/share/man/man8/lvresize.8.gz
/usr/share/man/man8/lvs.8.gz
/usr/share/man/man8/lvscan.8.gz
/usr/share/man/man8/pvchange.8.gz
/usr/share/man/man8/pvck.8.gz
/usr/share/man/man8/pvcreate.8.gz
/usr/share/man/man8/pvdisplay.8.gz
/usr/share/man/man8/pvmove.8.gz
/usr/share/man/man8/pvremove.8.gz
/usr/share/man/man8/pvresize.8.gz
/usr/share/man/man8/pvs.8.gz
/usr/share/man/man8/pvscan.8.gz
/usr/share/man/man8/vgcfgbackup.8.gz
/usr/share/man/man8/vgcfgrestore.8.gz
/usr/share/man/man8/vgchange.8.gz
/usr/share/man/man8/vgck.8.gz
/usr/share/man/man8/vgconvert.8.gz
/usr/share/man/man8/vgcreate.8.gz
/usr/share/man/man8/vgdisplay.8.gz
/usr/share/man/man8/vgexport.8.gz
/usr/share/man/man8/vgextend.8.gz
/usr/share/man/man8/vgimport.8.gz
/usr/share/man/man8/vgimportclone.8.gz
/usr/share/man/man8/vgmerge.8.gz
/usr/share/man/man8/vgmknodes.8.gz
/usr/share/man/man8/vgreduce.8.gz
/usr/share/man/man8/vgremove.8.gz
/usr/share/man/man8/vgrename.8.gz
/usr/share/man/man8/vgs.8.gz
/usr/share/man/man8/vgscan.8.gz
/usr/share/man/man8/vgsplit.8.gz
The Future: DNF
DNF is the next generation of package management for redhat based operating systems. Currently, it exists as a fork of yum 3.4 that use libsolv as its dependency solver. It is currently in use by the Fedora distribution.
CentOS8: dnf manpage dnf.man.txt
Conclusion
Getting more familiar with your package manager’s tools can help you be more productive when finding, installing, and querying packages.
We highly recommend that users of production redhat based systems become familiar with yum and dnf.
You can learn more about the tools mentioned in this blog post by reading the man page: man 8 yum
links: https://blog.packagecloud.io/eng/2015/04/05/yum-cheat-sheet/
where are repositories defined?
ll /etc/yum.repos.d insgesamt 52K drwxr-xr-x. 2 root root 248 22. Mai 15:03 . drwxr-xr-x. 112 root root 8,0K 24. Mai 11:38 .. -rw-r--r--. 1 root root 241 28. Okt 2016 bareos.repo -rw-r--r--. 1 root root 1,7K 29. Nov 19:12 CentOS-Base.repo -rw-r--r--. 1 root root 1,3K 29. Nov 19:12 CentOS-CR.repo -rw-r--r--. 1 root root 649 29. Nov 19:12 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 29. Nov 19:12 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 29. Nov 19:12 CentOS-Media.repo -rw-r--r--. 1 root root 1,3K 29. Nov 19:12 CentOS-Sources.repo -rw-r--r--. 1 root root 2,9K 29. Nov 19:12 CentOS-Vault.repo -rw-r--r--. 1 root root 957 27. Dez 18:37 epel.repo -rw-r--r--. 1 root root 1,1K 27. Dez 18:37 epel-testing.repo cat bareos.repo; # display one example file [bareos_bareos-16.2] name=bareos bareos-16.2 (CentOS_7) type=rpm-md baseurl=http://download.bareos.org/bareos/release/16.2/CentOS_7/ gpgcheck=1 gpgkey=http://download.bareos.org/bareos/release/16.2/CentOS_7/repodata/repomd.xml.key enabled=1 cat CentOS-Base.repo; # display one example file # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
liked this article?
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!