46

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

1
  • I also know how to fix the problematic repo. So a way of just overwriting it is also welcome.
    – Malabarba
    Nov 2, 2012 at 11:54

5 Answers 5

42

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
3
  • 4
    Not all yum repositories are added via RPM packages.
    – cherdt
    Mar 1, 2018 at 16:12
  • found with grep and remove by : yum remove {name} solved my problem. thank's May 16, 2020 at 7: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 at 17:31
29

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)

2
  • 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 2, 2012 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 2, 2012 at 14:09
15

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

1
  • Note that the user is only able to use sudo with yum and not with any other commands.
    – Kusalananda
    May 5 at 9:25
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

1
  • 3
    he already established that he knew how to do that (the italicized text at the bottom of his question)
    – h3rrmiller
    Nov 5, 2012 at 21:13
-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.

4
  • 2
    this didn't adress problem of not beeing root and editing files in /etc/yum.repos.d
    – Archemar
    May 4 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. May 5 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 6 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. May 9 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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