Posted: . At: 4:38 PM. This was 1 year ago. Post ID: 17571
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



manage packages on Rocky Linux easily with dnf.


Managing software on Rocky Linux is easy with dnf. This is just like using YUM on Fedora.

The dnf command in Fedora Linux is used as a package manager to install, update, and remove software packages. The following is a list of common options used with the dnf command:

To find a certain package, use this option.

[root@localhost Documents]# dnf search wordpress
Last metadata expiration check: 1:31:49 ago on Mon 06 Feb 2023 14:14:47.
============================================================================================================= Name Exactly Matched: wordpress ==============================================================================================================
wordpress.noarch : Blog tool and publishing platform

This has found the WordPress package I was looking for.

Then it is very easy to install the desired package.

[root@localhost Documents]# dnf install wordpress
Last metadata expiration check: 1:40:41 ago on Mon 06 Feb 2023 14:14:47.
Dependencies resolved.
============================================================================================================================================================================================================================================================
 Package                                                           Architecture                                           Version                                                           Repository                                                 Size
============================================================================================================================================================================================================================================================
Installing:
 wordpress                                                         noarch                                                 6.1.1-1.el9                                                       epel                                                       15 M
Installing dependencies:
 apr                                                               x86_64                                                 1.7.0-11.el9                                                      appstream                                                 123 k
 apr-util                                                          x86_64                                                 1.6.1-20.el9                                                      appstream                                                  94 k
 apr-util-bdb                                                      x86_64                                                 1.6.1-20.el9                                                      appstream                                                  13 k
 httpd                                                             x86_64                                                 2.4.53-7.el9                                                      appstream                                                  48 k
 httpd-core                                                        x86_64                                                 2.4.53-7.el9                                                      appstream                                                 1.4 M
 httpd-filesystem                                                  noarch                                                 2.4.53-7.el9                                                      appstream                                                  15 k
 httpd-tools                                                       x86_64                                                 2.4.53-7.el9                                                      appstream                                                  82 k
 libsodium                                                         x86_64                                                 1.0.18-8.el9                                                      epel                                                      161 k
 libzip                                                            x86_64                                                 1.7.3-7.el9                                                       appstream                                                  62 k
 nginx-filesystem                                                  noarch                                                 1:1.20.1-13.el9                                                   appstream                                                  11 k
 php-common                                                        x86_64                                                 8.0.20-3.el9                                                      appstream                                                 665 k
 php-fpm                                                           x86_64                                                 8.0.20-3.el9                                                      appstream                                                 1.6 M
 php-gd                                                            x86_64                                                 8.0.20-3.el9                                                      appstream                                                  43 k
 php-intl                                                          x86_64                                                 8.0.20-3.el9                                                      appstream                                                 151 k
 php-mbstring                                                      x86_64                                                 8.0.20-3.el9                                                      appstream                                                 471 k
 php-mysqlnd                                                       x86_64                                                 8.0.20-3.el9                                                      appstream                                                 152 k
 php-pdo                                                           x86_64                                                 8.0.20-3.el9                                                      appstream                                                  84 k
 php-pecl-zip                                                      x86_64                                                 1.19.2-6.el9                                                      appstream                                                  54 k
 php-sodium                                                        x86_64                                                 8.0.20-1.el9                                                      epel                                                       34 k
 php-xml                                                           x86_64                                                 8.0.20-3.el9                                                      appstream                                                 133 k
 rocky-logos-httpd                                                 noarch                                                 90.13-1.el9                                                       appstream                                                  24 k
Installing weak dependencies:
 apr-util-openssl                                                  x86_64                                                 1.6.1-20.el9                                                      appstream                                                  15 k
 mod_http2                                                         x86_64                                                 1.15.19-2.el9                                                     appstream                                                 149 k
 mod_lua                                                           x86_64                                                 2.4.53-7.el9                                                      appstream                                                  62 k
 
Transaction Summary
============================================================================================================================================================================================================================================================
Install  25 Packages
 
Total download size: 21 M
Installed size: 86 M
Is this ok [y/N]:

It is also possible to retrieve the command history for dnf. Just run dnf like this.

[root@localhost Documents]# dnf history
ID     | Command line                                                                                                                                                                                          | Date and time    | Action(s)      | Altered
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     9 | install wordpress                                                                                                                                                                                     | 2023-02-06 15:56 | Install        |   25  <
     8 |                                                                                                                                                                                                       | 2023-02-06 14:35 | Reinstall      |    1 >#
     7 | install snapd                                                                                                                                                                                         | 2023-02-06 14:15 | Install        |    3  <
     6 | -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm                                                                                                                     | 2023-02-06 14:14 | Install        |    1 >E
     5 | install gimp                                                                                                                                                                                          | 2023-02-06 14:01 | Install        |   21
     4 | install elrepo-release                                                                                                                                                                                | 2023-02-06 13:54 | Install        |    1
     3 | install mc                                                                                                                                                                                            | 2023-02-06 13:50 | Install        |    1
     2 | update                                                                                                                                                                                                | 2023-02-06 13:41 | I, U           |   78 E<
     1 |

Update all packages on the system to match the online package repositories.

[root@localhost Documents]# dnf distro-sync
Last metadata expiration check: 1:47:37 ago on Mon 06 Feb 2023 14:14:47.
Dependencies resolved.
============================================================================================================================================================================================================================================================
 Package                                                         Architecture                                            Version                                                              Repository                                               Size
============================================================================================================================================================================================================================================================
Upgrading:
 elrepo-release                                                  noarch                                                  9.1-1.el9.elrepo                                                     elrepo                                                   12 k
 
Transaction Summary
============================================================================================================================================================================================================================================================
Upgrade  1 Package
 
Total download size: 12 k
Is this ok [y/N]:

Use the dnf info option to find out detailed information about a certain package available for installation.

[root@localhost Documents]# dnf info vim-common-2:8.2.2637-16.el9_0.3.x86_64
Last metadata expiration check: 1:51:02 ago on Mon 06 Feb 2023 14:14:47.
Installed Packages
Name         : vim-common
Epoch        : 2
Version      : 8.2.2637
Release      : 16.el9_0.3
Architecture : x86_64
Size         : 30 M
Source       : vim-8.2.2637-16.el9_0.3.src.rpm
Repository   : @System
From repo    : AppStream
Summary      : The common files needed by any version of the VIM editor
URL          : http://www.vim.org/
License      : Vim and MIT
Description  : VIM (VIsual editor iMproved) is an updated and improved version of the
             : vi editor.  Vi was the first real screen-based editor for UNIX, and is
             : still very popular.  VIM improves on vi by adding new features:
             : multiple windows, multi-level undo, block highlighting and more.  The
             : vim-common package contains files which every VIM binary will need in
             : order to run.
             :
             : If you are installing vim-enhanced or vim-X11, you'll also need
             : to install the vim-common package.

To display a list of all configured software repositories on your Rocky Linux system, use the repolist option.

[john@localhost Documents]$ dnf repolist
repo id                                                                                                 repo name
appstream                                                                                               Rocky Linux 9 - AppStream
baseos                                                                                                  Rocky Linux 9 - BaseOS
elrepo                                                                                                  ELRepo.org Community Enterprise Linux Repository - el9
epel                                                                                                    Extra Packages for Enterprise Linux 9 - x86_64
extras                                                                                                  Rocky Linux 9 - Extras

This makes dnf very easy to use, once you know how to install and manage software, it is a treat to use.

Print a List of all configured package repositories using Python.

>>> import subprocess
>>> output = subprocess.check_output(['dnf', 'repolist']).decode()
>>> print (output)
repo id           repo name
appstream         Rocky Linux 9 - AppStream
baseos            Rocky Linux 9 - BaseOS
elrepo            ELRepo.org Community Enterprise Linux Repository - el9
epel              Extra Packages for Enterprise Linux 9 - x86_64
extras            Rocky Linux 9 - Extras

That could be very useful. It is a way to run a Linux command in Python and then print the output.

Like this.

>>> output = subprocess.check_output(['ls', '-hula']).decode()
>>> print (output)
total 32K
drwx------. 16 john john 4.0K Feb  6 15:45 .
drwxr-xr-x.  3 root root   18 Feb  6 14:39 ..
-rw-------.  1 john john  264 Feb  6 16:39 .bash_history
-rw-r--r--.  1 john john   18 Nov  2 03:47 .bash_logout
-rw-r--r--.  1 john john  141 Feb  6 13:30 .bash_profile
-rw-r--r--.  1 john john  492 Feb  6 13:30 .bashrc
drwxr-xr-x. 19 john john 4.0K Feb  6 13:30 .cache
drwx------. 17 john john 4.0K Feb  6 13:30 .config
drwxr-xr-x.  2 john john    6 Feb  6 14:03 Desktop
drwxr-xr-x.  2 john john   99 Feb  6 16:35 Documents
drwxr-xr-x.  2 john john    6 Feb  6 14:03 Downloads
drwx------.  4 john john   32 Feb  6 13:30 .local
drwxr-xr-x.  5 john john   54 Oct 30 11:36 .mozilla
drwxr-xr-x.  2 john john    6 Feb  6 14:03 Music
drwxr-xr-x.  2 john john  101 Feb  6 14:04 Pictures
drwxr-xr-x.  2 john john    6 Feb  6 14:06 Public
drwx------.  4 john john   33 Feb  6 16:31 snap
drwx------.  2 john john   25 Feb  6 15:41 .ssh
drwxr-xr-x.  2 john john    6 Feb  6 14:06 Templates
drwxr-xr-x.  2 john john    6 Feb  6 14:03 Videos
-rw-r--r--.  1 john john  658 May 15  2022 .zshrc

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.