19

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).

closed as off-topic by roaima, Jeff Schaller, Kusalananda, Eric Renouf, icarus Jan 31 '17 at 15:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – roaima, Jeff Schaller, Kusalananda, Eric Renouf, icarus
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
16

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
0

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

0

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. – Zhenyang Hua Oct 14 '16 at 19:42

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