DNF: Difference between revisions
(Created page with ";Did Not Finish :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...") |
mNo edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
;Did Not Finish | What does DNF stand for? | ||
: | ;Did Not Finish? | ||
:No, that's a status for someone who drops out of a Disc Golf tournament. | |||
[[wp:DNF (software)]] is the successor to [[Yum]] - a package manager for .rpm-based Linux distributions. | [[wp:DNF (software)|DNF (software)]] is the successor to [[Yum]] - a package manager for .rpm-based Linux distributions. | ||
https://dnf.readthedocs.io/en/latest/command_ref.html | 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. | ||
== 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 packages | |||
:sudo dnf clean all | |||
=== How to Install a Specific Version of a software package === | |||
: | |||
:sudo dnf list installed elasticsearch | |||
:sudo dnf list elasticsearch --showduplicates | |||
:sudo dnf remove elasticsearch kibana | |||
:sudo dnf erase elasticsearch kibana | |||
:sudo dnf list installed elasticsearch | |||
:sudo dnf install dnf-command(versionlock) | |||
:sudo dnf search ansible | |||
:sudo dnf list ansible | |||
:sudo dnf versionlock add ansible | |||
:sudo dnf versionlock list | |||
=== 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]] |
Latest revision as of 13:05, 10 December 2024
What does DNF stand for?
- Did Not Finish?
- No, that's a status for someone who drops out of a Disc Golf tournament.
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.
Docs[edit | edit source]
See man dnf.conf
The Rocky Linux wiki has info on their package repositories and also version policy https://wiki.rockylinux.org/rocky/repo/#version-policy
Commands Cheatsheet[edit | edit source]
Reclaim space from DNF caches[edit | edit source]
- sudo dnf clean dbcache
- sudo dnf clean packages
- sudo dnf clean all
How to Install a Specific Version of a software package[edit | edit source]
- sudo dnf list installed elasticsearch
- sudo dnf list elasticsearch --showduplicates
- sudo dnf remove elasticsearch kibana
- sudo dnf erase elasticsearch kibana
- sudo dnf list installed elasticsearch
- sudo dnf install dnf-command(versionlock)
- sudo dnf search ansible
- sudo dnf list ansible
- sudo dnf versionlock add ansible
- sudo dnf versionlock list
List all installed packages from a given repo[edit | edit source]
dnf repo-pkgs epel list installed
or
repoquery -a --repoid=REPONAME
More DNF commands[edit | edit source]
dnf repolist
- shows your package repositories
dnf repoinfo
- shows greater detail about your package repositories
dnf list
- shows all installed and available packages (and where they came from)
dnf list --available
- add the qualifier to specify
dnf list --installed
DNF with Ansible[edit | edit source]
The dnf config-manager
and crb
are helper utilities so that one does not have to edit the /etc/yum.repos.d/*.repo files directly. (Most files there are installed by packages and never need edits.)
One option for repo is skip_if_unavailable
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 repositories_thirdparty
. The play will ensure the repo definitions and the configuration is now GitOps friendly.
- 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 }}"
More[edit | edit source]
- 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