I'm having problems with yum and I am trying to re-install it. I've download yum.3.2.0-40-el6.centos.noarch.rpm.

When I try:

$ rpm -ivh yum.3.2.0-40-el6.centos.noarch.rpm

I get:

error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)

I tried running su - and I'm getting this error:

-bash: su: command not found`

I get the same "permission denied error" if I try to uninstall yum and force ignore dependencies (without forcing to ignore dependencies, it fails uninstall with a few dependencies).

  • Are you root or using sudo when you run this command? – slm Apr 20 '14 at 22:44
  • @slm, I am not able to get either sudo or su to work (see comment to your answer). Are these the only ways to work as root? – Brian Leach Apr 21 '14 at 16:55
  • What distro is this? – slm Apr 21 '14 at 16:56
  • 2
    what is the output of ls -l /bin/su ? command not found seems like you have bigger issues than mere yum. – Dani_l Nov 10 '15 at 15:41

This error:

error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)

... would appear to be you trying to perform an rpm -ivh ... command as a user other than root.

You'll need to run it like so:

$ sudo rpm -ivh yum.3.2.0-40-el6.centos.noarch.rpm

Also make sure that you're in the directory where you happened to download the yum..rpm file. Perhaps you downloaded as your regular username and are now attempting to install it as root. Note that when you become root you're typically changed directories into /root.

If su - is broken for whatever reason you can also become root like so:

$ sudo -i
  • I am confused on the sudo and su commands. su - gives (see above), and sudo -i gives sudo: unable to stat /etc/sudoers: No such file or directory sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin – Brian Leach Apr 21 '14 at 16:54

Run sudo su before and it works :)

  • 2
    if su - returns "su: command not found", this won't work either. The real problem is why and how /bin/su disappeared. – lgeorget Sep 16 '16 at 6:50
  • it works for me. – Downhillski Oct 14 '16 at 19:42

Try running $ sudo rm /var/lib/rpm/.rpm.lock

Not the answer you're looking for? Browse other questions tagged or ask your own question.