DNF: Difference between revisions

DNF
No edit summary
Add display title
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
;Did Not Finish
{{DISPLAYTITLE:dnf}}
:no, that's a status for someone who pulls out of a Disc Golf tournament.


[[wp:DNF (software)]] is the successor to [[Yum]] - a package manager for .rpm-based Linux distributions. In RHEL, and by extension, AlmaLinux and Rocky Linux, yum is an alias for dnf. (So you're using dnf even if you think you're using yum.) dnf has been around since 2013 and became default in 2015
What does DNF stand for?
;Did Not Finish?
:No, that's a status for someone who drops out of a Disc Golf tournament.


https://dnf.readthedocs.io/en/latest/command_ref.html
[[wp:DNF (software)|DNF (software)]] is the successor to [[Yum]] - a package manager for .rpm-based Linux distributions.  


The Rocky Linux wiki has info on their repositories and also version policy https://wiki.rockylinux.org/rocky/repo/#version-policy
In RHEL, and by extension, AlmaLinux and Rocky Linux, yum is an alias for dnf. So you're using '''dnf''' even if you think you're using yum! dnf has been around since 2013 and became default in 2015.


;Reclaim space from DNF caches
== Docs ==
See <code>man dnf.conf</code>
 
DNF [https://dnf.readthedocs.io/en/latest/command_ref.html Command Reference]
 
The Rocky Linux wiki has info on their package repositories and also version policy https://wiki.rockylinux.org/rocky/repo/#version-policy
 
== Commands Cheatsheet ==
 
=== Reclaim space from DNF caches ===
:sudo dnf clean dbcache
:sudo dnf clean dbcache
:sudo dnf clean packages
:sudo dnf clean packages
:sudo dnf clean all
:sudo dnf clean all


;How to Install a Specific Version of a software package:
=== How to Install a Specific Version of a software package ===
:
:sudo dnf list installed elasticsearch
:sudo dnf list installed elasticsearch
:sudo dnf list elasticsearch --showduplicates
:sudo dnf list elasticsearch --showduplicates
Line 25: Line 36:
:sudo dnf versionlock list
:sudo dnf versionlock list


https://dnf-plugins-core.readthedocs.io/en/latest/versionlock.html
=== List all installed packages from a given repo ===
<code>dnf repo-pkgs epel list installed</code>
or
<code>repoquery -a --repoid=REPONAME</code>
 
=== More DNF commands ===
<code>dnf repolist</code> - shows your package repositories
<code>dnf repoinfo</code> - shows greater detail about your package repositories
<code>dnf list</code> - shows all '''installed''' and '''available''' packages (and where they came from)
<code>dnf list --available</code> - add the qualifier to specify
<code>dnf list --installed</code>
 
 
== DNF with Ansible ==
The <code>dnf config-manager</code> and <code>crb</code> are helper utilities so that one does not have to edit the <tt>/etc/yum.repos.d/*.repo</tt> files directly. (Most files there are installed by packages and never need edits.)
 
One option for repo is <code>skip_if_unavailable</code>
 
If using [[Ansible]] for configuration management, there's no reason you can't manage your package repositories with [[YAML]]
 
Put a task like below in a playbook and populate <code>repositories_thirdparty</code>. The play will ensure the repo definitions and the configuration is now '''GitOps''' friendly.
 
<syntaxhighlight lang="yaml">
- name: Define third-party repositories
  ansible.builtin.yum_repository:
    name:            "{{ item.name }}"
    file:            "{{ item.file | default(omit) }}"
    description:    "{{ item.description }}"
    mirrorlist:      "{{ item.mirrorlist | default(omit) }}"
    baseurl:        "{{ item.baseurl | default(omit) }}"
    metalink:        "{{ item.metalink | default(omit) }}"
    cost    :        "{{ item.cost | default(omit) }}"
    failovermethod:  "{{ item.failovermethod | default(omit) }}"
    gpgkey:          "{{ item.gpgkey | default(omit) }}"
    metadata_expire: "{{ item.metadata_expire | default(omit) }}"
    exclude:        "{{ item.exclude | default(omit) }}"
    gpgcheck:        "{{ item.gpgcheck | default(true) }}"
    repo_gpgcheck:  "{{ item.repo_gpgcheck | default(omit) }}"
    enabled:        "{{ item.enabled | default(false) }}"
    skip_if_unavailable: "{{ item.skip_if_unavailable | default(omit) }}"
  when: lookup('vars', 'use_' + item.id)
  loop: "{{ repositories_thirdparty }}"
  loop_control:
    label: "{{ item.name }}"
</syntaxhighlight>
 
 
== More ==
 
* https://dnf-plugins-core.readthedocs.io/en/latest/versionlock.html
* https://unix.stackexchange.com/questions/403181/how-to-pin-a-package-in-dnf-fedora explains the difference between 'exclude' and 'versionlock'
* https://docs.fedoraproject.org/en-US/quick-docs/dnf/#exclude-package
 
<br />


[[Category:System Administration]]
[[Category:System Administration]]
[[Category:Packages]]
[[Category:Packages]]
[[Category:RedHat]]
[[Category:RedHat]]