51

I have no root access on my machine at work, but I have sudo permission to use sudo yum (and only yum).

Recently I accidentally installed a faulty repository (dropbox), and now I'd like to remove it. Since I have no write access to the yum.repos.d directory, manually editing or removing the repo file is out of the question.

I know you can install repos using yum (it's what I did), but can you remove a repo using yum?

Using Scientific Linux 6.

By the way, I know I can yum --disablerepo= to ignore the problematic repo. But I would like to remove it for good, because it's also causing problems with the graphical package manager (it keeps popping up notifications saying the updates couldn't be retrieved).

Malabarba
  • 2,009
  • 3
  • 15
  • 14

6 Answers6

46

In order to remove the actual yum repository rather than just to disable it, you have to find the package and remove it.

rpm -qa | grep epel

Sample outputs:

epel-release-5-4
yum remove epel-release-5-4
yum clean all
lese
  • 2,716
  • 5
  • 19
  • 30
Vadim Sluzky
  • 2,443
  • 4
  • 16
  • 5
  • 4
    Not all yum repositories are added via RPM packages. – cherdt Mar 01 '18 at 16:12
  • found with grep and remove by : yum remove {name} solved my problem. thank's – Abbas Torabi May 16 '20 at 07:17
  • For us, the `yum clean all` line above was required, because even though we had removed the repo we cared about, yum was still trying to install versions of packages from the removed repo. – Scott Feb 15 '22 at 17:31
36

you can remove the repo with yum-config-manager but not with yum:

yum-config-manager --disable repository
yum-config-manager --add-repo http://www.example.com/example.repo

EDIT: you need some way of running this as root (ie. sudo)

h3rrmiller
  • 13,095
  • 5
  • 31
  • 41
  • Ok, thanks. I'll wait around a bit more, but I might just boot up a live CD and remove the repo file. I didn't want to "hack" anything =P, but it's for a good reason. – Malabarba Nov 02 '12 at 12:44
  • 1
    if your sudoers line is just `yum` (and not the full path) you could copy /bin/bash to your working directory, prepend `.` to your PATH (`export PATH=.:$PATH`) and `sudo yum` that will fork a bash with root privs for you – h3rrmiller Nov 02 '12 at 14:09
17

You may be able to go into /etc/yum.repos.d/ and remove the file corresponding to the repository.

Dovev Hefetz
  • 279
  • 2
  • 3
2

You can temporarily remove/disable a yum repo by adding the --disablerepo=(reponame) to your yum line.

yum --disablerepo=some-repository install some-package

Unfortunately, that's the only way to do it with yum/sudo

Mark Cohen
  • 1,352
  • 9
  • 12
2

On RedHat if you are (well you must be) using YUM then, look under:

/etc/yum.repos.d/

Whatever repos you have are there, I would move the one you don't need into another directory (I don't usually like to delete incase).

Cheers

H

Heider Sati
  • 121
  • 2
-2

Feel free to correct me if i am wrong. If you do sudo you are basically doing it as root or administrator basically equivalent as a run as admin level command for the windows only types.

The temporary way to do it, but do i trust whole heartedly there will never ever run into an issue with something weird caching bugging out not at all. something like yum --disablerepo=some-repository install some-package could work but see below.

I would suggest rm or copy the actual file corresponding to the repo to another dummy directory or even temporarily creating a new directory just for this ocasion with a mkdir command. directory where it is useless. Potentially could be a safe enough thing to try to use to avert any type of caching issue that may be cause by temporarily disabling that directory.

Then again this is based on preference i guess. I just prefer the safe route and keeping file integrity over ima just run this command and hope it works.

  • 2
    this didn't adress problem of not beeing root and editing files in `/etc/yum.repos.d` – Archemar May 04 '22 at 15:09
  • If he can run Sudo he should be able to do anything root access would allow on the most part. Super user do command. He might have to check if he is on the sudoers file in ETC., If he is authorized to do so that is. If he is not authorized he should shut this topic down. Also so nice to see people trying to downvote someone being nice enough to lend a helping hand. – Benjamin Limback May 05 '22 at 20:18
  • It is common to configure restricted `sudo` access, and this is what has been done here. Their admin has given them the ability to install packages using `yum` and has restricted their use of `sudo` to only this single command. This is made clear in the first line of the question. – Kusalananda May 06 '22 at 16:13
  • I do not presume things In IT nor should anyone else. It is obvious that he may or may not be authorized to be doing what he is doing or that they may or may not have something external to sudo such as a pbrun way of doing things. Start from the basics and dont assume. – Benjamin Limback May 09 '22 at 00:26