How to avoid "yum lock" hassle?

I think it is caused by PackageKit. You have to check for PackageKit and disable it (I assume it is CentOS 7 with systemctl, otherwise you can use service and chkconfig) (as mentioned in comments, the service name is packagekit not packagekitd):

systemctl stop packagekit
systemctl disable packagekit

Another approach (On CentOS/RHEL 6, Fedora 19 or earlier) is to open /etc/yum/pluginconf.d/refresh-packagekit.conf with a text editor, and change enabled=1 to enabled=0.

Or you can completely remove it:

yum remove PackageKit

do the following to solve the problem:

cd /var/run
rm -f yum.pid

you could also update your yum afterward

yum -y update

You can unlock yum by following two simple steps,

1) Run ps aux | grep yum to see which process is locking yum. 2) kill <process_id> to kill the process.

Again run ps aux | grep yum to see if the process is killed or not. Yum will be unlocked after killing the process.

Tags:

Yum

Centos