Yum: Difference between revisions

From Leo's Notes
This page was last edited on 2 November 2020, at 22:39.
m Added categories
Line 1: Line 1:
The Yum package manager has been replaced by DNF.
The Yum package manager has been replaced by DNF.


== Usage ==
==Usage==
{| class="wikitable"
{| class="wikitable"
! Task
!Task
! Command
!Command
|-
|-
| Clean and update repository metadata
|Clean and update repository metadata
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# yum clean all
# yum clean all
# yum update
# yum update
}}
}}
|-
|-
| Install a package by name
|Install a package by name
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# yum install <package>
# yum install <package>
}}
}}
|-
|-
| Remove a package by name
|Remove a package by name
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# yum remove <package>
# yum remove <package>
}}
}}
|-
|-
| Upgrade a package
|Upgrade a package
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# yum update <package>
# yum update <package>
}}
}}
|-
|-
| Search for a package
|Search for a package
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# yum search <package>
# yum search <package>
}}
}}
|-
|-
| Search for a package by provided file
|Search for a package by provided file
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
## To find any package that provides *bin/netcat as a file
## To find any package that provides *bin/netcat as a file
# yum whatprovides \*bin/netcat
# yum whatprovides \*bin/netcat
}}
}}
|-
|-
| List installed packages
|List installed packages
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# rpm -qa
# rpm -qa
}}
}}
|-
|-
| Determine which package provided a file
|Determine which package provided a file
| {{highlight|lang=terminal|code=
|{{highlight|lang=terminal|code=
# rpm -qf <path to file>
# rpm -qf <path to file>
}}
}}
Line 52: Line 52:
Yum repositories are placed in {{code|/etc/yum.repos.d}}. Typically, yum logs will show all actions taken by yum at {{code|/var/log/yum.rpm.log}}.
Yum repositories are placed in {{code|/etc/yum.repos.d}}. Typically, yum logs will show all actions taken by yum at {{code|/var/log/yum.rpm.log}}.


== Excluding Packages ==
==Excluding Packages==
To exclude a package from being installed, use the {{code|-x}} option or add to the {{code|exclude}} attribute in the {{code|/etc/yum.conf}} file.
To exclude a package from being installed, use the {{code|-x}} option or add to the {{code|exclude}} attribute in the {{code|/etc/yum.conf}} file.


Line 77: Line 77:
}}
}}


== Troubleshooting ==
==Troubleshooting==
=== thread.error: can't start new thread ===
===thread.error: can't start new thread===
While attempting to install a package on a VPS, I encountered:
While attempting to install a package on a VPS, I encountered:
{{highlight|lang=terminal|code=
{{highlight|lang=terminal|code=
Line 130: Line 130:
}}
}}


{{Navbox Linux}}[[Category:Linux]]
=== Bad id for repo: My Repo, byte =  N ===
After adding a custom repository, running <code>yum</code> or <code>dnf</code> resulted in this error:
{{Highlight
| code = Bad id for repo: Local EPEL - Everything, byte =  5
Bad id for repo: Local EPEL - Modular, byte =  5
| lang = terminal
}}
The issue here is the space. Replace the spaces with dashes or underscores and try again.
<br />{{Navbox Linux}}
[[Category:Linux]]
[[Category:PackageManagement]]
[[Category:PackageManagement]]

Revision as of 22:39, 2 November 2020

The Yum package manager has been replaced by DNF.

Usage

Task Command
Clean and update repository metadata
# yum clean all
# yum update
Install a package by name
# yum install <package>
Remove a package by name
# yum remove <package>
Upgrade a package
# yum update <package>
Search for a package
# yum search <package>
Search for a package by provided file
## To find any package that provides *bin/netcat as a file
# yum whatprovides \*bin/netcat
List installed packages
# rpm -qa
Determine which package provided a file
# rpm -qf <path to file>

Yum repositories are placed in /etc/yum.repos.d. Typically, yum logs will show all actions taken by yum at /var/log/yum.rpm.log.

Excluding Packages

To exclude a package from being installed, use the -x option or add to the exclude attribute in the /etc/yum.conf file.

The list is separated by a space and supports wildcards. For example:

exclude=cpsc-uml pack* package3
DNF Specific
If you are using dnf such as on CentOS 8, or a recent version of Fedora, you need to add the exclude line in the /etc/dnf/dnf.conf file under the [main] section.

For example:

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
deltarpm=0

exclude=lightdm-webkit2-greeter


Troubleshooting

thread.error: can't start new thread

While attempting to install a package on a VPS, I encountered:

[root@drache ~]# yum install php-mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 309, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 178, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 345, in doCommands
    self._getTs(needTsRemove)
  File "/usr/lib/python2.4/site-packages/yum/depsolve.py", line 101, in _getTs
    self._getTsInfo(remove_only)
  File "/usr/lib/python2.4/site-packages/yum/depsolve.py", line 112, in _getTsInfo
    pkgSack = self.pkgSack
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 661, in 
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 501, in _getSacks
    self.repos.populateSack(which=repos)
  File "/usr/lib/python2.4/site-packages/yum/repos.py", line 232, in populateSack
    self.doSetup()
  File "/usr/lib/python2.4/site-packages/yum/repos.py", line 79, in doSetup
    self.ayum.plugins.run('postreposetup')
  File "/usr/lib/python2.4/site-packages/yum/plugins.py", line 179, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/fastestmirror.py", line 181, in postreposetup_hook
    all_urls = FastestMirror(all_urls).get_mirrorlist()
  File "/usr/lib/yum-plugins/fastestmirror.py", line 333, in get_mirrorlist
    self._poll_mirrors()
  File "/usr/lib/yum-plugins/fastestmirror.py", line 376, in _poll_mirrors
    pollThread.start()
  File "/usr/lib64/python2.4/threading.py", line 416, in start
    _start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

The solution was to disable the fastest mirror plugin by editing /etc/yum/pluginconf.d/fastestmirror.conf and setting enable=0

[main]
enabled=0
verbose=0
socket_timeout=3
hostfilepath=/var/cache/yum/timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook

Bad id for repo: My Repo, byte = N

After adding a custom repository, running yum or dnf resulted in this error:

Bad id for repo: Local EPEL - Everything, byte =   5
Bad id for repo: Local EPEL - Modular, byte =   5

The issue here is the space. Replace the spaces with dashes or underscores and try again.