📜 ⬆️ ⬇️

Yum, cheat sheet



Cheat sheet for working with the package manager Yum (Yellowdog Updater, Modified), which is used in popular Linux distributions: RedHat, CentOS, Scientific Linux (and others). In order to save space, the output of commands is not presented.

Table of contents


Teams
Yum options
Yum-Utils Package
Configuration files
Plugins
Work through a proxy


display commands and options
#yum help 

list of package names from repository
 #yum list 

list of all available packages
 #yum list available 

list of all installed packages
 #yum list installed 

whether the specified package is installed
 #yum list installed httpd 

list of installed and available packages
 #yum list all 

list of packages related to the kernel
 #yum list kernel 

display information about the package
 #yum info httpd 

list of dependencies and required packages
 #yum deplist httpd 

find the package that contains the file
 #yum provides "*bin/top" 

package search by name and description
 #yum search httpd 

 #yum search yum 

get information about available security updates
 #yum updateinfo list security 

list the groups
 #yum grouplist 

display the description and contents of the group
 #yum groupinfo "Basic Web Server" 

installation of the “Basic Web Server” package group
 #yum groupinstall "Basic Web Server" 

group deletion
 #yum groupremove "Basic Web Server" 

Check for available updates
 #yum check-update 

list of connected repositories
 #yum repolist 

information about a specific repository
 #yum repoinfo epel 

package information in the specified repository
 #yum repo-pkgs epel list 

install all packages from repository
 #yum repo-pkgs reponame install 

remove packages installed from repository
 #yum repo-pkgs reponame remove 

create cache
 #yum makecache 

check local rpm database (dependencies, duplicates, obsoletes, provides parameters are supported)
 #yum check 

 #yum check dependencies 

view yum history (list of transactions)
 #yum history list 

viewing information of a specific transaction (installed packages, installed dependencies)
 #yum history info 9 

cancel transaction
 #yum history undo 9 

to repeat
 #yum history redo 9 

Additionally, you can view the log
 #cat /var/log/yum.log 

remove cached packages
 #yum clean packages 

remove all packages and metadata
 #yum clean all 

install package
 #yum install httpd 

package removal
 #yum remove httpd 

upgrade package
 #yum update httpd 

upgrade all packages
 #yum update 

upgrade to a specific version
 #yum update-to 

install from local directory (search / install dependencies will be made from connected repositories)
 #yum localinstall httpd.rpm 

or
 #yum install httpd.rpm 

install from http
 #yum localinstall http://server/repo/httpd.rpm 

roll back to the previous version of the package
 #yum downgrade 

reinstall package (recover deleted files)
 #yum reinstall httpd 

removing unnecessary more packages
 #yum autoremove 

creating local repositories (createrepo is set separately)
 #createrepo 

installation of updates on a schedule (yum-cron is installed separately)
 #yum-cron 

')

Yum options


answer “yes” when prompted,
 -y 

 #yum update -y 

answer “no” when prompted
 --assumeno 

use Yum without plugins
 --noplugins 

or disable specific plugin
 --disableplugin=fastestmirror 

enable plugins that are installed but disabled
 #yum --enableplugin=ps 

enable disabled repository
 #yum update -y --enablerepo=epel 

disable repository
 #yum update -y --disablerepo=epel 

download packages but don't install
(on Centos 7 x86_64 will be downloaded to '/ var / cache / yum / x86_64 / 7 / base / packages /')
 #yum install httpd --downloadonly 


The following commands are available after installing the yum-utils package.


find from which repository package is installed
 #find-repos-of-install httpd 

find processes whose packages are updated and require restart
 #needs-restarting 

request to the repository, find out the dependencies of the package without installing it
 #repoquery --requires --resolve httpd 

synchronize the yum updates repository to the repo1 local directory
 #reposync -p repo1 --repoid=updates 

check the local repository for integrity
 #verifytree URL 

complete transactions
 #yum-complete-transaction 

install the necessary dependencies for building the RPM package
 #yum-builddep 

configuration options and repositories management yum
 #yum-config-manager 

query to the local database yum, displaying information about the package
(the command used, the checksum, the URL from which it was set, etc.)
 #yumdb info httpd 

download rpm packages from the repository
 #yumdownloader 

download src.rpm package from the repository
(a corresponding repository must be enabled, for example, in '/etc/yum.repos.d/CentOS-Sources.repo' on CentOS)
 yumdownloader --source php 


Yum configuration files and their location


Main configuration file
 /etc/yum.conf 

directory with configurations (for example, yum plugins)
 /etc/yum/ 

directory containing information about repositories
 /etc/yum.repos.d/ 


Some options of yum.conf:


Directory where yum stores cache and database files (default is '/ var / cache / yum')
 cachedir=/var/cache/yum/$basearch/$releasever 

Determines whether or not Yum should keep the header and package cache after successful installation. Values: 0 or 1. (default 1)
 keepcache=1 

debug output level. Values: 1-10 (default 2)
 debuglevel=2 

log file (default is '/var/log/yum.log')
 logfile=/var/log/yum.log 

update obsolete packages
 obsoletes=1 

verification of package signatures. Values: 0 or 1 (default 1)
 gpgcheck=1 

inclusion of plugins. Values: 0 or 1 (default 1)
 plugins=1 



Some useful plugins


Adds a command line option to view the changelog before / after updates.
 yum-plugin-changelog 

selects faster repositories from the list of mirrors
 yum-plugin-fastestmirror 

adds the keys, keys-info, keys-data, keys-remove commands that allow you to work with keys.
 yum-plugin-keys 

block specified packages from updating, yum versionlock command
 yum-plugin-versionlock 

add yum verify-all, verify-multilib, verify-rpm commands to check packet checksums
 yum-plugin-verify 


Work Yum through a proxy server


For all users:
add to [main] section in /etc/yum.conf
 proxy="http://server:3128" 

if necessary, specify a password, add
 proxy_proxy_username=user proxy_password=pass 

specify proxy for individual user
 #export http_proxy="http://server:3128" 



I will be glad to any additions and comments.
Additionally read:
 #man yum 

 #man rpm 

Source: https://habr.com/ru/post/301292/


All Articles