DNF
DNF é o gerenciador de pacotes do The Fedora Project capaz de consultar informações sobre pacotes, obter pacotes de repositórios, instalar e desinstalar pacotes usando resolução automática de dependências, e atualizar todo o sistema para os pacotes mais recentes disponíveis. O DNF realiza resolução automática de dependências nos pacotes que você está atualizando, instalando ou removendo, e, portanto, é capaz de determinar, obter e instalar automaticamente todos os pacotes dependentes disponíveis. O DNF pode ser configurado com novos repositórios adicionais, ou fontes de pacotes, e também fornece muitos plug-ins que aprimoram e estendem suas capacidades. O DNF é capaz de realizar muitas das mesmas tarefas que o RPM pode; além disso, muitas das opções de linha de comando são semelhantes. O DNF permite o gerenciamento fácil e simples de pacotes em uma única máquina ou em grupos delas.
Gerenciamento seguro de pacotes com pacotes assinados por GPG
DNF provê um controle de pacote seguro pela ativação da verificação de assinatura GPG (Proteção de Privacidade Gnu; também conhecido como GnuGP) nos pacotes GPG assinado se tornando para todos os repositórios de pacotes (fontes de pacotes), ou para repositórios individuais. Quando a assinatura de verificação está ativada, o DNF recusará a instalação de qualquer pacote sem a assinatura GPG com a chave correta para esse repositório. Isso significa que você pode confiar que os pacotes RPM que você baixa e instala no seu sistema são de fontes confiáveis, assim como The Fedora Project e antes não era modificado durante a transferência. Veja Configuring DNF and DNF Repositories para detalhes da ativação da checagem de assinatura com o DNF, ou Checking Package Signatures para mais informações de como funciona com a verificação de assinatura GPG RPM pacotes de geral. |
O DNF também permite configurar facilmente seus próprios repositórios de pacotes RPM para download e instalação em outras máquinas.
Aprender o DNF é um investimento que vale a pena, pois frequentemente é a forma mais rápida de realizar tarefas de administração do sistema e oferece capacidades além das fornecidas pelas ferramentas gráficas de gerenciamento de pacotes do PackageKit.
DNF e privilégios de superusuário
Você precisa ter privilégios de superusuário para usar o comando dnf para instalar, atualizar ou remover pacotes no seu sistema. Todos os exemplos neste capítulo pressupõem que você já obteve privilégios de superusuário usando o comando su ou sudo. |
Verificando e Atualizando Pacotes
Verificando por Atualizações
A maneira mais rápida para atualizar é tentando instalar qualquer atualização disponível usando o comando [command]#dnf da seguinte maneira:
~]# dnf upgrade Última checagem de metadados expirados 1:24:32 atrás na quinta-feira Maio 14 23:23:51 2015 Dependências resolvidas Nada para fazer. Completo!
Note que o dnf upgrade instala apenas as atualizações que podem ser instaladas. Se um pacote não puder ser atualizado, por problemas de dependência, por exemplo, ele será ignorado.
O comando dnf check-update pode ser usado para ver quais pacotes instalados no seu sistema possuem novas versões disponíveis, no entanto, isso não significa que eles podem ser instalados com sucesso. Portanto, esse comando é principalmente útil em scripts e para verificar pacotes atualizados que não foram instalados após executar dnf upgrade.
Por exemplo:
~]# dnf check-update Using metadata from Mon Apr 20 16:34:10 2015 (2:42:10 hours old) python.x86_64 2.7.9-6.fc22 updates python-cryptography.x86_64 0.8.2-1.fc22 updates python-libs.x86_64 2.7.9-6.fc22 updates
Os pacotes na saída acima estão listados como tendo versões atualizadas. A linha no exemplo de saída nos diz:
-
python
— o nome do pacote, -
x86_64
— a arquitetura da CPU para a qual o pacote foi construído, -
2.7.9
— a versão do pacote atualizado, -
6.fc22
— a versão do pacote atualizado, -
updates-testing
— o repositório no qual o pacote atualizado esta alocado.
Atualizando Pacotes
Você pode escolher atualizar o único pacote, múltiplos pacotes, ou todos os pacotes de uma vez. Se qualquer dependência do pacote, ou pacotes, você pode atualizar havendo atualizações disponíveis para eles, então eles são atualizados também.
Para atualizar um único pacote, execute o seguinte comando como root
:
dnf upgrade package_name
Para exemplo de como atualizar pacotes python, digite:
~]# dnf upgrade python Using metadata from Mon Apr 20 16:38:16 2015 (2:42:14 hours old) Dependencies resolved. ================================================================== Package Arch Version Repository Size ================================================================== Upgrading: python x86_64 2.7.9-6.fc22 updates 92 k python-libs x86_64 2.7.9-6.fc22 updates 5.8 M Transaction Summary ================================================================== Upgrade 2 Packages Volume total de download: 5.9 M Isso está certo [y/N]:
Essa saída contém:
-
python.x86_64
— você pode baixar a instalar um novo pacote python. -
python-libs.x86_64
— DNF resolveu o pacote python-libs-2.7.9-6.fc22.x86_64 e sua dependência requerida pelo pacote python. -
O DNF apresenta informação de atualização e então exibe para você como quer que será realizada a atualização; DNF executa interativamente por padrão. Se você já sabe qual transação DNF planeja realizar, você pode usar a opção
-y
para automaticamente responder yes para qualquer questões do DNF (em qual caso executa sem interatividade). No entanto, você deve sempre examinar quais alterações DNF planeja fazer para o sistema, então você pode facilmente realizar um troubleshoot em qualquer problema que possa surgir.Se a transação da errado, você pode ver o histórico de transição do DNF usando o comando dnf history descrito no Working with Transaction History.
Atualizando e instalando kernels com o DNF
DNF sempre instala um novo kernel no mesmo sentido que RPM instala um novo kernel quando você usa o comando rpm -i kernel. Por isso, você não precisa se preocupar com a distinção entre instalando e upgrading um pacote do kernel quando você usa o comando: dnf fará a coisa certa, apesar se você está usando o comando: dnf upgrade ou dnf install. Quando usando o RPM, por outro lado, é importante utilizar o comando rpm -i kernel (que instala a novo kernel) invés de rpm -u kernel (que substitui o kernel atual). Veja Installing and Upgrading Packages para mais informações sobre a instalação e atualização do kernel com RPM. |
Para atualizar todos os pacotes e suas dependências, enter sem nenhum argumento: dnf upgrade
dnf upgrade
Preservando Alterações no Arquivo de Configuração
Você vai inevitavelmente fazer alterações no arquivo de configuração instalado por pacotes conforme você utiliza o sistema Fedora. RPM, que o DNF utiliza para realizar alterações no sistema, provê um mecanismo para garantir sua integridade. Veja Installing and Upgrading Packages para detalhes de como gerenciar alterações nos arquivos de configuração e em todos os pacotes de upgrade.
Pacotes e Grupos de Pacote
Pesquisando Pacotes
Você pode pesquisar todos os pacotes RPM e sumarizar usando o seguinte comando:
dnf search
term…
Adicione all
para corresponder contra descrições e URLs.
dnf search all
term…
Esse comando exibe uma lista de cada termo que combina. Por exemplo, para listar todos os pacotes que combina com “meld” ou “kompare”, digite:
~]# dnf search meld kompare Loaded plugins: langpacks, presto, refresh-packagekit ============================ N/S Matched: meld =============================== meld.noarch : Visual diff and merge tool python-meld3.x86_64 : HTML/XML templating system for Python =========================== N/S Matched: kompare ============================= komparator.x86_64 : Kompare and merge two folders Name and summary matches only, use "search all" for everything.
Listando Pacotes
dnf list e comandos relacionados provê informação sobre pacotes, grupos de pacote, e repositórios.
Toda a lista de comandos DNF’s permitidos você pode filtrar os resultados adicionando um ou mais glob expressions como argumentos. Expressões glob são um trechos normais de caracteres que contém um ou mais caracteres curinga * (que expande para combinar caracteres múltiplas vezes) e ? (que expande para combinar com qualquer caracteres).
Filtrando resultados com expressões glob
Seja cuidadoso para escapar das expressões glob quando passar os argumentos para o comando dnf, do contrário o shell Bash irá interpretar essas expressões como pathname expansions, e uma passe em potencial todos os arquivos no diretório atual que combina o glob com DNF. Para ter certeza que as expressões glob foram passadas para o DNF de fato, ou não:
DNF apenas pesquisa nomes de pacotes quando está usando expressões glob. Para pesquisar por uma versão de pacote, inclua o dash e parte do número de versão dessa forma: ~]# dnf list kernel*-4* Last metadata expiration check performed 2:46:09 ago on Thu May 14 23:23:51 2015. Installed Packages kernel.x86_64 4.0.0-1.fc22 @System kernel.x86_64 4.0.2-300.fc22 @System kernel-core.x86_64 4.0.0-1.fc22 @System kernel-core.x86_64 4.0.2-300.fc22 @System [output truncated] Veja Listing all ABRT addons and plug-ins using glob expressions e Listing available packages using a single glob expression with escaped wildcard characters para um exemplo de uso de ambos esses métodos. |
- dnf list glob_expression…
-
Listas de informação sobre pacotes instalados e disponíveis combinando todas as expressões glob.
Exemplo 1. Listando todos os complementos e plug-ins ABRT usando expressões globPacotes com vários complementos ABRT e plug-ins que começam com “abrt-addon-”, ou “abrt-plugin-”. Para listar esses pacotes, digite o seguinte no terminal:
~]# dnf list abrt-addon\* abrt-plugin\* Last metadata expiration check performed 0:14:36 ago on Mon May 25 23:38:13 2015. Installed Packages abrt-addon-ccpp.x86_64 2.5.1-2.fc22 @System abrt-addon-coredump-helper.x86_64 2.5.1-2.fc22 @System abrt-addon-kerneloops.x86_64 2.5.1-2.fc22 @System abrt-addon-pstoreoops.x86_64 2.5.1-2.fc22 @System abrt-addon-python.x86_64 2.5.1-2.fc22 @System abrt-addon-python3.x86_64 2.5.1-2.fc22 @System abrt-addon-vmcore.x86_64 2.5.1-2.fc22 @System abrt-addon-xorg.x86_64 2.5.1-2.fc22 @System abrt-plugin-bodhi.x86_64 2.5.1-2.fc22 @System Available Packages abrt-addon-upload-watch.x86_64 2.5.1-2.fc22 fedora
- dnf list all
-
Listar todos os pacotes instalados e disponíveis.
Exemplo 2. Listando todos os pacotes instalados e disponíveis~]# dnf list all Last metadata expiration check performed 0:21:11 ago on Mon May 25 23:38:13 2015. Installed Packages NetworkManager.x86_64 1:1.0.2-1.fc22 @System NetworkManager-libnm.x86_64 1:1.0.2-1.fc22 @System PackageKit.x86_64 1.0.6-4.fc22 @System PackageKit-glib.x86_64 1.0.6-4.fc22 @System aajohan-comfortaa-fonts.noarch 2.004-4.fc22 @System abrt.x86_64 2.5.1-2.fc22 @System [output truncated]
- dnf list installed
-
Para listar todos os pacotes instalados no seu sistema. A coluna mais a direita na lista de saída é o repositório de cada pacote que foi recuperado.
Exemplo 3. Listando os pacote instalados usando uma expressão glob de aspas duplasPara listar todos os pacotes que foram instalados que começam com “krb” seguindo por exato um caractere e uma hífen, digite:
~]# dnf list installed "krb?-*" Last metadata expiration check performed 0:34:45 ago on Mon May 25 23:38:13 2015. Installed Packages krb5-libs.x86_64 1.13.1-3.fc22 @System krb5-workstation.x86_64 1.13.1-3.fc22 @System
- dnf list available
-
Lista de todos os pacotes disponíveis em todos os repositórios habilitados.
Exemplo 4. Listando pacotes disponíveis usando uma única expressão glob com escape de caracteres curingaPara listar todos os pacotes disponíveis com nomes que contenham “gstreamer” e também “plugin”, execute o seguinte comando:
~]# dnf list available gstreamer\*plugin\* Last metadata expiration check performed 0:42:15 ago on Mon May 25 23:38:13 2015. Available Packages gstreamer-plugin-crystalhd.i686 3.10.0-8.fc22 fedora gstreamer-plugin-crystalhd.x86_64 3.10.0-8.fc22 fedora gstreamer-plugins-bad-free.i686 0.10.23-24.fc22 fedora gstreamer-plugins-bad-free.x86_64 0.10.23-24.fc22 fedora gstreamer-plugins-bad-free-devel.i686 0.10.23-24.fc22 fedora gstreamer-plugins-bad-free-devel.x86_64 0.10.23-24.fc22 fedora [output truncated]
- dnf group list
-
Listar todos os grupos de pacote.
Exemplo 5. Listando todos os grupos de pacote~]# dnf group list Loaded plugins: langpacks, presto, refresh-packagekit Setting up Group Process Installed Groups: Administration Tools Design Suite Dial-up Networking Support Fonts GNOME Desktop Environment [output truncated]
- dnf repolist
-
Listar o ID de repositório, nome, e número dos pacotes que provê cada repositório ativado.
Exemplo 6. Listando repositórios ativados~]# dnf repolist Last metadata expiration check performed 0:48:29 ago on Mon May 25 23:38:13 2015. repo id repo name status *fedora Fedora 22 - x86_64 44,762 *updates Fedora 22 - x86_64 - Updates 0
- dnf repository-packages repo_id list
-
Listar pacotes de um repositório especificado.
Exemplo 7. Listando pacotes de um único repositório~]# dnf repository-packages fedora list [option] Last metadata expiration check performed 1:38:25 ago on Wed May 20 22:16:16 2015. Installed Packages PackageKit.x86_64 1.0.6-3.fc22 @System PackageKit-glib.x86_64 1.0.6-3.fc22 @System aajohan-comfortaa-fonts.noarch 2.004-4.fc22 @System [output truncated]
A ação padrão é listar todos os pacotes disponíveis e instalados de um repositório especificado. Adicione a opção
available
ouinstalled
para listar somente os pacotes disponíveis ou instalados de um repositório especificado.
Exibindo Informação de Pacote
Para exibir informação sobre um ou mais pacotes, use o comando da seguinte maneira:
dnf info package_name…
Por exemplo, para exibir informação sobre o pacote abrt, digite:
~]# dnf info abrt Last metadata expiration check: 1:09:44 ago on Tue May 31 06:51:51 2016. Installed Packages Name : abrt Arch : x86_64 Epoch : 0 Version : 2.8.1 Release : 1.fc24 Size : 2.2 M Repo : @System From repo : updates-testing Summary : Automatic bug detection and reporting tool URL : https://abrt.readthedocs.org/ License : GPLv2+ Description : abrt is a tool to help users to detect defects in applications and : to create a bug report with all information needed by maintainer to fix it. : It uses plugin system to extend its functionality.
O comando dnf info package_name é similar ao comando rpm -q --info package_name, mas provê informação adicional, o nome do repositório DNF do pacote RPM que foi instalado (olhe para From repo:
na linha de saída). O comando dnf info exibe somente os pacotes disponíveis mais recentes se houver uma nova versão disponível de uma ja instalada. O comando dnf repoquery pode exibir todos os pacotes instalados e disponíveis.
Para exibir informação sobre todos os pacotes disponíveis, ambos instalados e disponíveis de um repositório, use o o comando da seguinte maneira:
dnf repoquery package_name --info
Por exemplo, para exibir informação sobre o pacote abrt, digite:
~]# dnf repoquery abrt --info Last metadata expiration check: 1:01:44 ago on Tue May 31 06:51:51 2016. Name : abrt Version : 2.8.1 Release : 1.fc24 Architecture: x86_64 Size : 2318452 License : GPLv2+ Source RPM : abrt-2.8.1-1.fc24.src.rpm Build Date : 2016-05-25 08:54 Packager : Fedora Project URL : https://abrt.readthedocs.org/ Summary : Automatic bug detection and reporting tool Description : abrt is a tool to help users to detect defects in applications and to create a bug report with all information needed by maintainer to fix it. It uses plugin system to extend its functionality.
Veja a instrução de uso do dnf repoquery para mais opções:
~]$ dnf repoquery -h
usage: dnf [options] COMMAND
output truncated
Instalando Pacotes
DNF permite você de instalar ambos, um único pacote e múltiplos pacotes, assim como um grupo de pacote de sua escolha.
Para instalar um único pacote e todas as suas dependências não instaladas, entre com o comando da seguinte forma:
dnf install package_name
Você também pode instalar múltiplos pacotes simultaneamente inserindo seu nome como argumentos:
dnf install package_name package_name…
Se você está instalando pacotes em um sistema multilib, assim como máquinas AMD64 ou Intel64, você pode especificar a arquitetura do pacote, assim que esteja disponível em um repositório ativado, por pacote com nome appending .arch. Por exemplo, para instalar o pacote sqlite2 para i586
, digite:
~]# dnf install sqlite2.i586
Você pode utilizar e expressões glob para uma rápida instalação de múltiplos pacotes com nomes similares:
~]# dnf install audacious-plugins-\*
Em adicional para nomes de pacote e expressões glob, você pode também informar nomes de arquivos ao dnf install. Se você conhece o nome do binário que você quer instalar, mas se não sabe o nome do pacote, você pode inserir o nome do caminho ao dnf install:
~]# dnf install /usr/sbin/named
dnf then searches through its package lists, finds the package which provides /usr/sbin/named
, if any, and prompts you as to whether you want to install it.
Encontre qual pacote pertence ao arquivo
Se você sabe e quer instalar o pacote que contém o binário ~]# dnf provides "*bin/named" Using metadata from Thu Apr 16 13:41:45 2015 (4:23:50 hours old) bind-32:9.10.2-1.fc22.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server Repo : @System dnf provides "*/file_name" encontrará todos os pacote que contém file_name. |
Um grupo de pacote é similar a um pacote: isso não é útil por si só, mas pode estar instalando um conjunto de grupos de dependência de pacotes que servem a um propósito em comum. Um grupo de pacote possui um nome e um groupid (GID). O comando dnf group list -v lista os nomes de todos os grupos de pacote, e depois de cada um dele, há um um groupid em parênteses. O groupid é sempre o termo no último par de parênteses, assim como kde-desktop-environment
, no exemplo a seguir:
~]# dnf -v group list kde\* cachedir: /var/cache/dnf/x86_64/22 Loaded plugins: builddep, config-manager, copr, playground, debuginfo-install, download, generate_completion_cache, kickstart, needs-restarting, noroot, protected_packages, Query, reposync, langpacks initialized Langpacks plugin DNF version: 0.6.5 repo: using cache for: fedora not found deltainfo for: Fedora 22 - x86_64 not found updateinfo for: Fedora 22 - x86_64 repo: using cache for: updates-testing repo: using cache for: updates not found updateinfo for: Fedora 22 - x86_64 - Updates Using metadata from Thu Apr 16 13:41:45 2015 (4:37:51 hours old) Available environment groups: KDE Plasma Workspaces (kde-desktop-environment)
Você pode instalar um grupo de pacote informando se nome de grupo completo (sem a parte do groupid) para group install:
dnf group install group_name
Multi-word names must be quoted.
Você pode também instalar por groupid:
dnf group install
groupid
Você pode até mesmo passar o groupid ou um nome entre aspas para o comando install, se você preceder com um @-symbol (que fala para o dnf que você quer realizar um group install):
dnf install
@group
Por exemplo, o seguinte é uma alternativa, mas uma maneira equivalente para estar instalando o grupo KDE Plasma Workspaces
:
~]# dnf group install "KDE Plasma Workspaces" ~]# dnf group install kde-desktop-environment ~]# dnf install @kde-desktop-environment
Removendo Pacotes
Similarmente a instalação de pacote, DNF permite você desinstalar (remover em RPM e terminologia DNF) ambos pacotes individualmente e um grupo de pacote.
Para desinstalar um pacote em particular, e também qualquer pacote que o dependa, execute o seguinte comando como 'root':
dnf remove package_name…
Assim conforme você instala múltiplos pacotes, você pode remover várias de uma vez adicionando mais nomes de pacotes ao comando. Por exemplo, para remover totem, rhythmbox, e sound-juicer, digite o seguinte no terminal:
~]# dnf remove totem rhythmbox sound-juicer
Similar to install, remove can take these arguments:
-
nomes de pacote
-
expressões glob
-
listas de arquivos
-
fornece pacotes
Removendo um pacote quando outros pacotes o dependem
DNF is not able to remove a package without also removing packages which depend on it. This type of operation can only be performed by RPM, is not advised, and can potentially leave your system in a non-functioning state or cause applications to misbehave and terminate unexpectedly. For further information, refer to Uninstalling Packages in the RPM chapter. |
Você pode remover um grupo de pacotes usando sintaxe congruente com a sintaxe install:
dnf group remove
group
dnf remove
@group
The following are alternative but equivalent ways of removing the KDE Plasma Workspaces
group:
~]# dnf group remove "KDE Plasma Workspaces" ~]# dnf group remove kde-desktop-environment ~]# dnf remove @kde-desktop-environment
Working with Transaction History
The dnf history command allows users to review information about a timeline of DNF transactions, the dates and times on when they occurred, the number of packages affected, whether transactions succeeded or were aborted, and if the RPM database was changed between transactions. Additionally, this command can be used to undo or redo certain transactions.
To display a list of all transactions, as root
, either run dnf history with no additional arguments, or enter the following command:
dnfhistory
list
To display only transactions in a given range, use the command in the following form:
dnf history list start_id..end_id
You can also list only transactions regarding a particular package or packages. To do so, use the command with a package name or a glob expression:
dnf history list glob_expression…
For example, the list of first five transactions may look as follows:
~]# dnf history list 1..4 Using metadata from Thu Apr 16 13:41:45 2015 (5:47:31 hours old) ID | Login user | Date a | Action | Altere ------------------------------------------------------------------------------- 4 | root <root> | 2015-04-16 18:35 | Erase | 1 3 | root <root> | 2015-04-16 18:34 | Install | 1 2 | root <root> | 2015-04-16 17:53 | Install | 1 1 | System <unset> | 2015-04-16 14:14 | Install | 668 E
The dnf history list command produces tabular output with each row consisting of the following columns:
-
ID
— an integer value that identifies a particular transaction. -
Login user
— the name of the user whose login session was used to initiate a transaction. This information is typically presented in theFull Name <username>
form, however sometimes the command used to perform the transaction is displayed. For transactions that were not issued by a user (such as an automatic system update),System <unset>
is used instead. -
Date and time
— the date and time when a transaction was issued. -
Action(s)
— a list of actions that were performed during a transaction as described in Possible values of the Action(s) field. -
Altered
— the number of packages that were affected by a transaction, possibly followed by additional information.
[options="header"] |
Action |
Abbreviation |
Description |
|
|
At least one package has been downgraded to an older version. |
|
|
At least one package has been removed. |
|
|
At least one new package has been installed. |
|
|
At least one package has been marked as obsolete. |
|
|
At least one package has been reinstalled. |
|
|
At least one package has been updated to a newer version. |
Apart from reviewing the transaction history, the dnf history command provides means to revert or repeat a selected transaction. To revert a transaction, type the following at a shell prompt as root
:
dnfhistory
undo
id
To repeat a particular transaction, as root
, run the following command:
dnfhistory
redo
id
Both commands also accept the last
keyword to undo or repeat the latest transaction.
Note that both dnf history undo and dnf history redo commands merely revert or repeat the steps that were performed during a transaction, and will fail if the required packages are not available. For example, if the transaction installed a new package, the dnf history undo command will uninstall it and also attempt to downgrade all updated packages to their previous version, but the command will fail if the required packages are not available.
Configuring DNF and DNF Repositories
The configuration file for DNF and related utilities is located at /etc/dnf/dnf.conf
. This file contains one mandatory [main]
section, which allows you to set DNF options that have global effect, and may also contain one or more [repository]
sections, which allow you to set repository-specific options. However, it is recommended to define individual repositories in new or existing .repo
files in the /etc/yum.repos.d/
directory. The values you define in individual [repository]
sections of the /etc/dnf/dnf.conf
file override values set in the [main]
section.
This section shows you how to:
-
set global DNF options by editing the
[main]
section of the/etc/dnf/dnf.conf
configuration file; -
set options for individual repositories by editing the
[repository]
sections in/etc/dnf/dnf.conf
and.repo
files in the/etc/yum.repos.d/
directory; -
use DNF variables in
/etc/dnf/dnf.conf
and files in the/etc/yum.repos.d/
directory so that dynamic version and architecture values are handled correctly; -
add, enable, and disable DNF repositories on the command line; and,
-
set up your own custom DNF repository.
Setting [main] Options
options] The /etc/dnf/dnf.conf
configuration file contains exactly one [main]
section, and while some of the key-value pairs in this section affect how dnf operates, others affect how DNF treats repositories.
You can add many additional options under the [main]
section heading in /etc/dnf/dnf.conf
.
A sample /etc/dnf/dnf.conf
configuration file can look like this:
[main] gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=true
The following are the most commonly-used options in the [main]
section:
debuglevel
=value-
…where value is an integer between
0
and10
. Setting a higherdebuglevel
value causes dnf to display more detailed debugging output.debuglevel=0
disables debugging output, anddebuglevel=2
is the default. exclude
=package_name more_package_names-
This option allows you to exclude packages by keyword during installation and updates. Listing multiple packages for exclusion can be accomplished by quoting a space-delimited list of packages. Shell globs using wildcards (for example,
*
and?
) are allowed. gpgcheck
=value-
…where value is one of:
0
— Disable GPG signature-checking on packages in all repositories, including local package installation.1
— Enable GPG signature-checking on all packages in all repositories, including local package installation.gpgcheck=1
is the default, and thus all packages' signatures are checked.If this option is set in the
[main]
section of the/etc/dnf/dnf.conf
file, it sets the GPG-checking rule for all repositories. However, you can also setgpgcheck=value
for individual repositories instead; you can enable GPG-checking on one repository while disabling it on another. Settinggpgcheck=value
for an individual repository in its corresponding.repo
file overrides the default if it is present in/etc/dnf/dnf.conf
.For more information on GPG signature-checking, refer to Checking Package Signatures.
installonlypkgs
=space separated list of packages-
Here you can provide a space-separated list of packages which dnf can install, but will never update. See the dnf.conf(5) manual page for the list of packages which are install-only by default.
If you add the
installonlypkgs
directive to/etc/dnf/dnf.conf
, you should ensure that you list all of the packages that should be install-only, including any of those listed under theinstallonlypkgs
section of dnf.conf(5). In particular, kernel packages should always be listed ininstallonlypkgs
(as they are by default), andinstallonly_limit
should always be set to a value greater than2
so that a backup kernel is always available in case the default one fails to boot.
installonly_limit
=value-
…where value is an integer representing the maximum number of versions that can be installed simultaneously for any single package listed in the
installonlypkgs
directive.The defaults for the
installonlypkgs
directive include several different kernel packages, so be aware that changing the value ofinstallonly_limit
will also affect the maximum number of installed versions of any single kernel package. The default value listed in/etc/dnf/dnf.conf
isinstallonly_limit=3
, and it is not recommended to decrease this value, particularly below2
. keepcache
=value-
…where value is one of:
0
— Do not retain the cache of headers and packages after a successful installation. This is the default.1
— Retain the cache after a successful installation.
For a complete list of available [main]
options, refer to the [MAIN] OPTIONS
section of the dnf.conf(5) manual page.
Setting [repository] Options
options] The [repository]
sections, where repository is a unique repository ID such as my_personal_repo
(spaces are not permitted), allow you to define individual DNF repositories.
The following is a bare-minimum example of the form a [repository]
section takes:
[repository] name=repository_name baseurl=repository_url
Every [repository]
section must contain the following directives:
name
=repository_name-
…where repository_name is a human-readable string describing the repository.
- parameter=repository_url
-
…where parameter is one of the following:
baseurl
,metalink
, ormirrorlist
;…where repository_url is a URL to a directory containing a
repodata
directory of a repository, a metalink file, or a mirror list file.-
If the repository is available over HTTP, use:
http://path/to/repo
-
If the repository is available over FTP, use:
ftp://path/to/repo
-
If the repository is local to the machine, use:
file:///path/to/local/repo
-
If a specific online repository requires basic HTTP authentication, you can specify your user name and password by prepending it to the URL as
username:password@link
. For example, if a repository on http://www.example.com/repo/ requires a username of “user” and a password of “password”, then thebaseurl
link could be specified ashttp://user:password@www.example.com/repo/
.Usually this URL is an HTTP link, such as:
baseurl=http://path/to/repo/releases/$releasever/server/$basearch/os/
Note that DNF always expands the
$releasever
,$arch
, and$basearch
variables in URLs. For more information about DNF variables, refer to Using DNF Variables.
-
To configure the default set of repositories, use the enabled
option as follows:
enabled
=value-
…where value is one of:
0
— Do not include this repository as a package source when performing updates and installs.1
— Include this repository as a package source.Turning repositories on and off can also be performed by passing either the
--set-enabled repo_name
or--set-disabled repo_name
option to the dnf command, or through theAdd/Remove Software
window of the PackageKit utility.
Many more [repository]
options exist. For a complete list, refer to the [repository] OPTIONS
section of the dnf.conf(5) manual page.
Using DNF Variables
Variables can be used only in the appropriate sections of the DNF configuration files, namely the /etc/dnf/dnf.conf
file and all .repo
files in the /etc/yum.repos.d/
directory. Repository variables include:
$releasever
-
Refers to the release version of operating system which DNF derives from information available in RPMDB.
$arch
-
Refers to the system’s CPU architecture. Valid values for
$arch
include:i586
,i686
andx86_64
. $basearch
-
Refers to the base architecture of the system. For example, i686 and i586 machines both have a base architecture of
i386
, and AMD64 and Intel64 machines have a base architecture ofx86_64
.
Viewing the Current Configuration
To list all configuration options and their corresponding values, and the repositories, execute the dnf config-manager command with the --dump
option:
~]$ dnf config-manager --dump ============================= main ====================================== [main] alwaysprompt = True assumeno = False assumeyes = False bandwidth = 0 best = False bugtracker_url = https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dnf cachedir = /var/cache/dnf/x86_64/22 [output truncated]
Adding, Enabling, and Disabling a DNF Repository
Setting [repository Options] describes various options you can use to define a DNF repository. This section explains how to add, enable, and disable a repository by using the dnf config-manager command.
To define a new repository, you can either add a [repository]
section to the /etc/dnf/dnf.conf
file, or to a .repo
file in the /etc/yum.repos.d/
directory. All files with the .repo
file extension in this directory are read by DNF, and it is recommended to define your repositories here instead of in /etc/dnf/dnf.conf
.
DNF repositories commonly provide their own .repo
file. To add such a repository to your system and enable it, run the following command as root
:
dnf config-manager --add-repo repository_url
…where repository_url is a link to the .repo
file.
To add a repository located at http://www.example.com/example.repo, type the following at a shell prompt:
~]# dnf config-manager --add-repo http://www.example.com/example.repo adding repo from: http://www.example.com/example.repo
To enable a particular repository or repositories, type the following at a shell prompt as root
:
dnf config-manager --set-enabled
repository…
…where repository is the unique repository ID. To display the current configuration, add the --dump
option.
To disable a DNF repository, run the following command as root
:
dnf config-manager --set-disabled
repository…
…where repository is the unique repository ID. To display the current configuration, add the --dump
option.
Recursos adicionais
.Documentação Instalada
-
dnf(8)
— The DNF command reference manual page. -
dnf.conf(8)
— DNF Configuration Reference manual page.
- https://dnf.readthedocs.org/en/latest/index.html
-
A wiki do DNF contém mais documentação.
Want to help? Learn how to contribute to Fedora Docs ›