DNF sta per Dandified YUM è un gestore di pacchetti software per distribuzioni Linux basate su RPM. Viene utilizzato per installare, aggiornare e rimuovere pacchetti nel sistema operativo Fedora/RHEL/CentOS. È il gestore di pacchetti predefinito di Fedora 22, CentOS8 e RHEL8. DNF è la versione di nuova generazione di YUM e intende sostituire YUM nei sistemi basati su RPM. DNF è potente e ha caratteristiche robuste di quelle che troverai in yum. DNF semplifica la gestione di gruppi di pacchetti ed è in grado di risolvere automaticamente i problemi di dipendenza.
In questo tutorial spiegheremo come gestire il pacchetto con DNF su CentOS 8.
Requisiti
- Un server che esegue CentOS 8.
- È stata impostata una password di root sul tuo server.
Installa DNF
Per impostazione predefinita, DNF è preinstallato nel sistema operativo CentOS 8. Se non è installato, puoi installarlo eseguendo il seguente comando:
yum install dnf
Successivamente, puoi controllare la versione di DNF con il seguente comando:
dnf --version
Dovresti vedere il seguente output:
4.0.9 Installed: dnf-0:4.0.9.2-5.el8.noarch at Friday 04 October 2019 05:27:09 AM GMT Built : CentOS Buildsys <[email protected]> at Monday 13 May 2019 07:35:13 PM GMT Installed: rpm-0:4.14.2-9.el8.x86_64 at Friday 04 October 2019 05:20:17 AM GMT Built : CentOS Buildsys <[email protected]> at Saturday 11 May 2019 02:04:19 AM GMT
Elenca i pacchetti installati e disponibili
Puoi elencare tutti i pacchetti installati sul tuo sistema con il seguente comando:
dnf list installed
Dovresti vedere tutti i pacchetti installati nel seguente output:
Installed Packages NetworkManager.x86_64 1:1.14.0-14.el8 @anaconda NetworkManager-config-server.noarch 1:1.14.0-14.el8 @anaconda NetworkManager-libnm.x86_64 1:1.14.0-14.el8 @anaconda NetworkManager-team.x86_64 1:1.14.0-14.el8 @anaconda NetworkManager-tui.x86_64 1:1.14.0-14.el8 @anaconda PackageKit.x86_64 1.1.12-2.el8 @AppStream PackageKit-glib.x86_64 1.1.12-2.el8 @AppStream acl.x86_64 2.2.53-1.el8 @anaconda adcli.x86_64 0.8.2-2.el8 @anaconda at.x86_64 3.1.20-11.el8 @anaconda attr.x86_64 2.4.48-3.el8 @anaconda audit.x86_64 3.0-0.10.20180831git0047a6c.el8 @anaconda audit-libs.x86_64 3.0-0.10.20180831git0047a6c.el8 @anaconda authselect.x86_64 1.0-13.el8 @anaconda authselect-compat.x86_64 1.0-13.el8 @AppStream authselect-libs.x86_64 1.0-13.el8 @anaconda avahi-libs.x86_64 0.7-19.el8 @anaconda basesystem.noarch 11-5.el8 @anaconda
Puoi anche elencare tutti i pacchetti installati e disponibili con il seguente comando:
dnf list
Dovresti vedere il seguente output:
Last metadata expiration check: 4 days, 22:47:10 ago on Friday 04 October 2019 02:14:39 AM EDT. Installed Packages NetworkManager.x86_64 1:1.14.0-14.el8 @anaconda NetworkManager-config-server.noarch 1:1.14.0-14.el8 @anaconda NetworkManager-libnm.x86_64 1:1.14.0-14.el8 @anaconda NetworkManager-team.x86_64 1:1.14.0-14.el8 @anaconda NetworkManager-tui.x86_64 1:1.14.0-14.el8 @anaconda PackageKit.x86_64 1.1.12-2.el8 @AppStream PackageKit-glib.x86_64 1.1.12-2.el8 @AppStream acl.x86_64 2.2.53-1.el8 @anaconda adcli.x86_64 0.8.2-2.el8 @anaconda at.x86_64 3.1.20-11.el8 @anaconda attr.x86_64 2.4.48-3.el8 @anaconda audit.x86_64 3.0-0.10.20180831git0047a6c.el8 @anaconda audit-libs.x86_64 3.0-0.10.20180831git0047a6c.el8 @anaconda authselect.x86_64 1.0-13.el8 @anaconda authselect-compat.x86_64 1.0-13.el8 @AppStream authselect-libs.x86_64 1.0-13.el8 @anaconda avahi-libs.x86_64 0.7-19.el8 @anaconda : :
Puoi anche elencare solo i pacchetti disponibili con il seguente comando:
dnf list available
Dovresti vedere il seguente output:
Last metadata expiration check: 4 days, 22:48:21 ago on Friday 04 October 2019 02:14:39 AM EDT. Available Packages BackupPC.src 4.3.1-2.el8 epel-source BackupPC.x86_64 4.3.1-2.el8 epel BackupPC-XS.src 0.59-3.el8 epel-source BackupPC-XS.x86_64 0.59-3.el8 epel BackupPC-XS-debuginfo.x86_64 0.59-3.el8 epel-debuginfo BackupPC-XS-debugsource.x86_64 0.59-3.el8 epel-debuginfo BackupPC-debuginfo.x86_64 4.3.1-2.el8 epel-debuginfo BackupPC-debugsource.x86_64 4.3.1-2.el8 epel-debuginfo CGSI-gSOAP.src 1.3.11-7.el8 epel-source CGSI-gSOAP.x86_64 1.3.11-7.el8 epel CGSI-gSOAP-debuginfo.x86_64 1.3.11-7.el8 epel-debuginfo CGSI-gSOAP-debugsource.x86_64 1.3.11-7.el8 epel-debuginfo CGSI-gSOAP-devel.x86_64 1.3.11-7.el8 epel
Cerca e installa pacchetto
Puoi cercare qualsiasi pacchetto che desideri installare con il seguente comando:
dnf search httpd
Dovresti vedere il seguente output:
========================================================= Name Exactly Matched: httpd ========================================================= httpd.x86_64 : Apache HTTP Server ======================================================== Name & Summary Matched: httpd ======================================================== centos-logos-httpd.noarch : CentOS-related icons and pictures used by httpd keycloak-httpd-client-install.noarch : Tools to configure Apache HTTPD as Keycloak client python3-keycloak-httpd-client-install.noarch : Tools to configure Apache HTTPD as Keycloak client ============================================================= Name Matched: httpd ============================================================= httpd-devel.x86_64 : Development interfaces for the Apache HTTP server httpd-tools.x86_64 : Tools for use with the Apache HTTP Server httpd-manual.noarch : Documentation for the Apache HTTP server libmicrohttpd.i686 : Lightweight library for embedding a webserver in applications libmicrohttpd.x86_64 : Lightweight library for embedding a webserver in applications httpd-filesystem.noarch : The basic directory layout for the Apache HTTP server =========================================================== Summary Matched: httpd ============================================================ mod_dav_svn.x86_64 : Apache httpd module for Subversion server mod_auth_mellon.x86_64 : A SAML 2.0 authentication module for the Apache Httpd Server
Ora puoi installare il pacchetto httpd con il seguente comando:
dnf install httpd
Per reinstallare il pacchetto httpd, esegui il seguente comando:
dnf reinstall httpd
In alcuni casi, sarà necessario scaricare i pacchetti senza installarli. Puoi scaricare un pacchetto specifico con il seguente comando:
dnf download httpd
Puoi anche vedere i dettagli del pacchetto httpd con il seguente comando:
dnf info httpd
Dovresti ottenere il seguente output:
Last metadata expiration check: 0:01:02 ago on Wednesday 09 October 2019 01:07:23 AM EDT. Available Packages Name : httpd Version : 2.4.37 Release : 11.module_el8.0.0+172+85fc1f40 Arch : x86_64 Size : 1.7 M Source : httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.src.rpm Repo : AppStream Summary : Apache HTTP Server URL : https://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.
Aggiorna i pacchetti di sistema
Innanzitutto, puoi controllare gli aggiornamenti per tutti i pacchetti di sistema sul tuo sistema con il seguente comando:
dnf check-update
Dovresti ottenere il seguente output:
Last metadata expiration check: 0:00:10 ago on Wednesday 09 October 2019 01:10:16 AM EDT. bind-export-libs.x86_64 32:9.11.4-17.P2.el8_0.1 BaseOS bind-libs.x86_64 32:9.11.4-17.P2.el8_0.1 AppStream bind-libs-lite.x86_64 32:9.11.4-17.P2.el8_0.1 AppStream bind-license.noarch 32:9.11.4-17.P2.el8_0.1 AppStream bind-utils.x86_64 32:9.11.4-17.P2.el8_0.1 AppStream bpftool.x86_64 4.18.0-80.7.1.el8_0 BaseOS cockpit.x86_64 185.1-1.el8_0 BaseOS cockpit-bridge.x86_64 185.1-1.el8_0 BaseOS cockpit-system.noarch 185.1-1.el8_0 BaseOS cockpit-ws.x86_64 185.1-1.el8_0 BaseOS epel-release.noarch 8-6.el8 epel epel-release.src 8-6.el8 epel-source iptables.x86_64 1.8.2-9.el8_0.1 BaseOS iptables-ebtables.x86_64 1.8.2-9.el8_0.1 BaseOS iptables-libs.x86_64 1.8.2-9.el8_0.1 BaseOS kernel.x86_64 4.18.0-80.7.1.el8_0 BaseOS kernel-core.x86_64 4.18.0-80.7.1.el8_0 BaseOS kernel-modules.x86_64 4.18.0-80.7.1.el8_0 BaseOS kernel-tools.x86_64 4.18.0-80.7.1.el8_0 BaseOS kernel-tools-libs.x86_64 4.18.0-80.7.1.el8_0 BaseOS
Ora puoi aggiornare tutti i pacchetti installati nel tuo sistema con il seguente comando:
dnf update
Per aggiornare il pacchetto specifico, esegui il comando seguente:
dnf update httpd
Elenca e installa pacchetti di gruppo
Puoi elencare tutti i pacchetti di gruppo con il seguente comando:
dnf grouplist
Dovresti ottenere il seguente elenco:
Last metadata expiration check: 0:03:42 ago on Wednesday 09 October 2019 01:10:16 AM EDT. Available Environment Groups: Server with GUI Minimal Install Workstation KDE Plasma Workspaces Virtualization Host Custom Operating System Installed Environment Groups: Server Installed Groups: Container Management Headless Management Available Groups: .NET Core Development RPM Development Tools Smart Card Support Development Tools Graphical Administration Tools Legacy UNIX Compatibility Network Servers Scientific Support Security Tools System Tools Fedora Packager
Ora, installa il pacchetto di gruppo specifico con il seguente comando:
dnf groupinstall 'System Tools'
Puoi anche aggiornare un pacchetto di gruppo con il seguente comando:
dnf groupupdate 'System Tools'
Elenca archivi
Puoi elencare tutti i repository con il seguente comando:
dnf repolist all
Dovresti vedere il seguente output:
Last metadata expiration check: 0:10:39 ago on Wednesday 09 October 2019 01:10:16 AM EDT. repo id repo name status AppStream CentOS-8 - AppStream enabled: 4,928 AppStream-source CentOS-8 - AppStream Sources disabled BaseOS CentOS-8 - Base enabled: 2,713 BaseOS-source CentOS-8 - BaseOS Sources disabled PowerTools CentOS-8 - PowerTools disabled base-debuginfo CentOS-8 - Debuginfo disabled c8-media-AppStream CentOS-AppStream-8 - Media disabled c8-media-BaseOS CentOS-BaseOS-8 - Media disabled centosplus CentOS-8 - Plus disabled centosplus-source CentOS-8 - Plus Sources disabled cr CentOS-8 - cr disabled *epel Extra Packages for Enterprise Linux 8 - x86_64 enabled: 1,816 *epel-debuginfo Extra Packages for Enterprise Linux 8 - x86_64 - Debug enabled: 1,187 epel-playground Extra Packages for Enterprise Linux 8 - Playground - x86_64 disabled epel-playground-debuginfo Extra Packages for Enterprise Linux 8 - Playground - x86_64 - Debug disabled epel-playground-source Extra Packages for Enterprise Linux 8 - Playground - x86_64 - Source disabled *epel-source Extra Packages for Enterprise Linux 8 - x86_64 - Source enabled: 792 *epel-testing Extra Packages for Enterprise Linux 8 - Testing - x86_64 enabled: 538 *epel-testing-debuginfo Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Debug enabled: 347 *epel-testing-source Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Source enabled: 216 extras CentOS-8 - Extras enabled: 3 extras-source CentOS-8 - Extras Sources disabled fasttrack CentOS-8 - fasttrack disabled
Ora, elenca solo i repository abilitati sul sistema con il seguente comando:
dnf repolist
Dovresti vedere il seguente output:
Last metadata expiration check: 0:12:14 ago on Wednesday 09 October 2019 01:10:16 AM EDT. repo id repo name status AppStream CentOS-8 - AppStream 4,928 BaseOS CentOS-8 - Base 2,713 *epel Extra Packages for Enterprise Linux 8 - x86_64 1,816 *epel-debuginfo Extra Packages for Enterprise Linux 8 - x86_64 - Debug 1,187 *epel-source Extra Packages for Enterprise Linux 8 - x86_64 - Source 792 *epel-testing Extra Packages for Enterprise Linux 8 - Testing - x86_64 538 *epel-testing-debuginfo Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Debug 347 *epel-testing-source Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Source 216 extras CentOS-8 - Extras 3
Rimuovi pacchetti
Puoi rimuovere qualsiasi pacchetto indesiderato dal tuo sistema con il seguente comando:
dnf remove httpd
Quindi, rimuovi le dipendenze indesiderate installate con il pacchetto httpd eseguendo il comando seguente:
dnf autoremove
Puoi pulire tutti i pacchetti memorizzati nella cache con il seguente comando:
dnf clean all
Puoi anche rimuovere il pacchetto di gruppo con il seguente comando:
dnf groupremove 'System Tools'
Conclusione
Nel tutorial sopra, abbiamo imparato come gestire i pacchetti con il comando DNF su CentOS 8. Sentiti libero di chiedermi se hai domande.