All packages and rpm updates use yum. There are times that yum can stop functioning or even lock up your current session. The following are some processes that can perform to try to resolve the issue.
The first couple of scripts will attempt to automate the process and attempt to resolve the problem:
If running the previous commands does not appear to run or leave your session in a locked state, then you may have some environmental lock files that are preventing the usage yum as intended. If they exist, they would be located in the path /var/lib/rpm/ :
ls -lah /var/lib/rpm/
drwxr-xr-x. 2 root root 4.0K Apr 25 11:01 .
drwxr-xr-x. 38 root root 4.0K Apr 25 11:01 ..
-rw-r--r-- 1 root root 6.6M Apr 25 11:01 Basenames
-rw-r--r-- 1 root root 20K Apr 25 11:01 Conflictname
-rw-r--r--. 1 root root 0 Sep 18 2017 .dbenv.lock
-rw-r--r-- 1 root root 4.6M Apr 25 11:01 Dirnames
-rw-r--r-- 1 root root 40K Apr 25 11:01 Group
-rw-r--r-- 1 root root 52K Apr 25 11:01 Installtid
-rw-r--r-- 1 root root 160K Apr 25 11:01 Name
-rw-r--r-- 1 root root 32K Apr 25 11:01 Obsoletename
-rw-r--r-- 1 root root 107M Apr 25 11:01 Packages
-rw-r--r-- 1 root root 3.1M Apr 25 11:01 Providename
-rw-r--r-- 1 root root 512K Apr 25 11:01 Requirename
-rw-r--r--. 1 root root 0 Sep 18 2017 .rpm.lock
-rw-r--r-- 1 root root 248K Apr 25 11:01 Sha1header
-rw-r--r-- 1 root root 140K Apr 25 11:01 Sigmd5
-rw-r--r-- 1 root root 24K Apr 25 11:01 Triggername
The lock files usually have a format of a '.' at the start of the file and end with '.lock.' You will rename or move these files so they will no longer make an impact:
#make a directory to move the files to
mkdir -vp /root/cptechs/
#move the files to that directory to save the files as a backup
mv -v /var/lib/rpm/.dbenv.lock /root/cptechs/
mv -v /var/lib/rpm/.rpm.lock /root/cptechs/
Once the files are moved, there usually some previous running transactions that would be left behind. You want to clean those up.
yum clean all
And lastly, rebuild the RPM database to ensure that the data is current
You will be able to confirm yum is running by performing the following command: