1. dnf command to install package and it’s dependencies
You can use this command to install the latest version of a package and its dependencies.
dnf install package_name
2. dnf command to remove a package and its dependencies
To remove an installed package and its dependencies, you can use the following command.
# dnf remove package_name
3. Update a package and its dependencies with dnf command
This command allows you to update any installed packages and their dependencies to the latest versions.
# dnf update package_name
You can use this command without any arguments to update every package on the system.
# dnf update
4. dnf command to upgrade a package and its dependencies
This command has similar function like update
command, which is upgrading a package and its dependencies to the newest version.
# dnf upgrade package_name
Using this command without package as an argument upgrades all the installed packages on the system.
# dnf upgrade
5. dnf command to check available updates for installed rpms
You can check the updates available for the installed packages and their dependencies in your system.
# dnf check-update
6. List all the packages with dnf command
This commands lists all the packages (installed and available for installation) for RPM-based Linux distribution.
# dnf lsit
7. dnf command to get list of only installed packages
# dnf list installed
8. dnf command to search a package in available repositories
This command allows you to search a specific package by using the word. If the word matches with the name or summary of the package, it will print the result.
# dnf search [words]
9. dnf command to get list of specific package
You can also get the list of a specific package by passing the package name as an argument. But make sure you have the exact package name or else this command will not work and may return Error: No matching Packages to list
# dnf list package_name
10. Get information of package with dnf command
With this command, you can view the detailed information of every package available in the repositories. This command expects the exact package name.
# dnf info package_name
11. dnf command to reinstall a package and its dependencies
Sometimes, there may come errors when using a certain package. Instead of removing it and install again, you can directly reinstall a package and its dependencies.
# dnf reinstall package_name
12. dnf command to download package instead of installing
You can also download package instead of installing it in the system. To do so, you can use --downloadonly
option and you can specify the download directory using --downloaddir=<DIR_PATH>
option.
# dnf install package_name --downloadonly --downloaddir=DIR_PATH
13. List currently enabled repositories with dnf command
To print the list of all enabled repositories, you can use the following command.
# dnf repolist
OR
# dnf repolist enabled
14. List currently disabled repositories with dnf command
To get the list of all disabled repositories, you can use the disabled option.
# dnf repolist disabled
15. dnf command to list all repositories
You can also list all the repositories that are configured on your system.
# dnf repolist all
16. Enable specific repository for runtime execution with dnf command
You can install a package from a specific repository using --enablerepo
option. It can also enable a disabled repository to install a package.
# dnf install package_name --enablerepo=repo_name
OR
You can disable all the repositories and use only a single repository using:
# dnf install package_name -disablerepo=* --enablerepo=repo_name
For Example, I will install vsftpd
package using appstream
repo only and will disable all other repository.
17. Disable specific repository for runtime execution with dnf command
--disablerepo
allows you to disable repository for runtime execution. It restricts the dnf to install a package from that repository. If the package is not available in other enabled repositories, you may not be able to install the package.
# yum install package_name --disablerepo=repo_name
For example, here I was having some issues with appstream
repo so I have temporarily disabled it for this command and using other repos to install the package. But you should know that this command will only work if the provided package is part of a different repository. If any of the dependent package are part of the disabled repo, then the package installation will fail.
18. Find which rpm package provides a specific file
You can use this command to find out which packages contain a specific file.
# dnf provides file_name
OR
# dnf whatprovides file_name
For Example, let us try to find the rpm which provides us the python3
binary:
dnf provides python3
To get the complete list of files by the name python3
, you can use regex with dnf command.
dnf provides */python3
19. List package’s dependencies and what packages provide them
You can use deplist
# dnf deplist package_name
For Example, to get the list of dependent rpms required to install nmap
package we can use the following command:
dnf deplist nmap
20. List all group packages with dnf command
Group package is the collection of multiple packages in a certain group. You can use the following command to list all the available groups for your system.
# dnf grouplist
21. dnf command to install a group package
When you install a group package, all the packages inside the group will be installed. To install a group package, you can use this command.
# dnf install group_package
22. dnf command to remove group package
When you remove a group package, all the packages belonging to that group will also be removed.
# dnf remove group_package
23. Update a group package using dnf command
To update an installed group package in your system, you can use this command.
# update groupupdate group_package
24. View the history of all dnf commands executed in the node
You can use this command to view the information of what has happened in the past execution of dnf command.
# dnf history
25. dnf command to undo and redo changes
You can undo and redo the changes made by dnf command execution. You will need a transaction id which you can get from history command.
To undo the change, you can use:
# dnf undo transaction_id
To redo the change, you can use:
# dnf history redo transaction_id
26. dnf command to undo all the transactions after the specified transaction
You can also use rollback command with dnf to undo all the transactions after the specified transactions. For example, if you have 15 transactions in the history and you specify the transaction id 10, it will undo all the transactions after 10 i.e. 11, 12, 13, 14, 15.
# dnf hisroty rollback transaction_id
27. dnf command to clean all the caches
To remove all the caches stored by dnf, you can use the following command.
# dnf clean all
Sample Output:
~]# dnf clean all
35 files removed
It also removes repository metadata. Due to which, when you run dnf command next time, it downloads all the metadata.
28. Enter the dnf shell using dnf command
You can use the interactive dnf shell where you can execute all of the dnf commands.
# dnf shell
---------
No hay comentarios:
Publicar un comentario