Chapter 8. Removing RHEL 9 content

In the following sections, learn how to remove content in Red Hat Enterprise Linux 9 by using DNF:

8.1. Removing installed packages

To remove packages installed on your system by using the dnf remove command, complete the following steps.

Procedure

  • To remove a particular package and all unused dependent packages, use:

    # dnf remove package-name

    Replace package-name with the name of the package.

  • To remove multiple packages and their unused dependencies simultaneously, use:

    # dnf remove package-name-1 package-name-2

    Replace package-name-1 and package-name-2 with the names of the packages.

Note

The dnf command removes a package together with any other dependent packages.

8.2. Removing package groups

To remove a package group either by the group name or the groupID by using the dnf group remove command, complete the following steps.

Procedure

  • To remove a package group by the group name, use:

    # dnf group remove group-name

    Replace group-name with the full name of the group.

  • To remove a package group by the groupID, use:

    # dnf group remove groupID

    Replace groupID with the ID of the group.

8.3. Removing installed modular content

When removing installed modular content, you can remove packages from either a selected profile or the whole stream.

Important

DNF will try to remove all packages with a name corresponding to the packages installed with a profile or a stream, including their dependent packages. Always check the list of packages to be removed before you proceed, especially if you have enabled custom repositories on your system.

8.3.1. Removing packages from an installed profile

When you remove packages installed with a profile, all packages with a name corresponding to the packages installed by the profile are removed. This includes their dependencies, with the exception of packages required by a different profile.

To remove packages from a selected profile, complete the following steps.

Prerequisites

  • The selected profile has been installed by using the dnf module install module-name:stream/profile command or as a default profile by using the dnf install module-name:stream command.
  • You understand modular dependency resolution.

Procedure

  1. Uninstall packages belonging to the selected profile:

    # dnf module remove module-name:stream/profile

    Replace module-name, stream, and profile with the module, stream, and profile you want to uninstall.

    Alternatively, uninstall packages from all installed profiles within a stream:

    # dnf module remove module-name:stream

    These operations will not remove packages from the stream that do not belong to any of the profiles.

  2. Check the list of packages under Removing: and Removing unused dependencies: before you proceed with the removal transaction.

To remove all packages from a selected stream, follow instructions in Section 8.3.2 "Removing all packages from a module stream".

Example 8.1. Removing packages from a selected profile

The following is an example of how to remove packages and their dependencies that belong to the development profile of the nodejs:18 module stream.

Note

The outputs in this example have been edited for brevity. Actual outputs might contain more information than shown here.

  1. Install the nodejs:18 module stream, including all available profiles:

    # dnf module install nodejs:18/*
    (...)
    Dependencies resolved.
    ===================================================================================
    Package          Architecture   Version
      Repository       Size
    ===================================================================================
    Installing group/module packages:
    nodejs           x86_64         1:18.7.0-1.module+el9.1.0+16284+4fdefb2f
      rhel-AppStream   12 M
    nodejs-devel     x86_64         1:18.7.0-1.module+el9.1.0+16284+4fdefb2f
      rhel-AppStream   202 k
    nodejs-nodemon   noarch         2.0.15-1.module+el9.1.0+15718+e52ec601
      rhel-AppStream   762 k
    npm              x86_64         1:8.15.0-1.18.7.0.1.module+el9.1.0+16284+4fdefb2f
      rhel-AppStream   2.2 M
    Installing dependencies:
    brotli           x86_64         1.0.9-6.el9
      rhel-AppStream   314 k
    brotli-devel     x86_64         1.0.9-6.el9
      rhel-AppStream   36 k
    ...
    Installing weak dependencies:
    nodejs-docs      noarch         1:18.7.0-1.module+el9.1.0+16284+4fdefb2f
      rhel-AppStream   7.2 M
    nodejs-full-i18n x86_64         1:18.7.0-1.module+el9.1.0+16284+4fdefb2f
      rhel-AppStream   8.2 M
    Installing module profiles:
    nodejs/common
    nodejs/development
    nodejs/minimal
    nodejs/s2i
    
    Transaction Summary
    ===================================================================================
    Install  31 Packages
    
    Total download size: 36 M
    Installed size: 165 M
    Is this ok [y/N]: y
    (...)
    Complete!
  2. Inspect the installed profiles:

    $ dnf module info nodejs
    ...
    Name             : nodejs
    Stream           : 18 [e] [a]
    Version          : 9010020221009220316
    Context          : rhel9
    Architecture     : x86_64
    Profiles         : common [d] [i], development [i], minimal [i], s2i [i]
    Default profiles : common
    Repo             : rhel-AppStream
    ...
    Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled, [a]ctive

    All profiles are installed as indicated in the output.

  3. Remove packages from the development profile and their dependencies:

    # dnf module remove nodejs:18/development
    (...)
    Dependencies resolved.
    ========================================================================
    Package          Architecture   Version
      Repository       Size
    ========================================================================
    Removing:
    nodejs-devel     x86_64         1:18.7.0-1.module+el9.1.0+16284+4fdefb2f
      @rhel-AppStream  950 k
    Removing unused dependencies:
    brotli           x86_64         1.0.9-6.el9
      @rhel-AppStream  754 k
    brotli-devel     x86_64         1.0.9-6.el9
      @rhel-AppStream  55 k
    ...
    Disabling module profiles:
    nodejs/development
    
    Transaction Summary
    ========================================================================
    Remove  26 Packages
    
    Freed space: 8.3 M
    Is this ok [y/N]: y
  4. Inspect the installed profiles after the removal:

    $ dnf module info nodejs
    ...
    Name             : nodejs
    Stream           : 18 [e] [a]
    Version          : 9010020221009220316
    Context          : rhel9
    Architecture     : x86_64
    Profiles         : common [d] [i], development, minimal [i], s2i [i]
    Default profiles : common
    Repo             : rhel-AppStream
    Summary          : Javascript runtime
    ...
    Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled, [a]ctive

    All profiles except development are currently installed.

8.3.2. Removing all packages from a module stream

When you remove packages installed with a module stream, all packages with a name corresponding to the packages installed by the stream are removed. This includes their dependencies, with the exception of packages required by other modules.

To remove all packages from a selected module stream, complete the following steps.

Prerequisites

  • The module stream has been enabled and at least some packages from the stream have been installed.
  • You understand modular dependency resolution.

Procedure

  1. Remove all packages from a selected stream:

    # dnf module remove --all module-name:stream

    Replace module-name and stream with the module and stream you want to uninstall.

  2. Check the list of packages under Removing: and Removing unused dependencies: before you proceed with the removal transaction.
  3. Optionally, reset or disable the stream.

If you want to remove only packages from a selected profile, follow instructions in Section 8.3.1. "Removing packages from an installed profile".

Example 8.2. Removing packages from the whole stream

The following is an example of how to remove all packages from the nodejs:18 module stream.

Note

The outputs in this example have been edited for brevity. Actual outputs might contain more information than shown here.

  1. Install the nodejs:18 module stream, including all available profiles:

    # dnf module install nodejs:18/*
    (...)
    Dependencies resolved.
    ===================================================================================
    Package          Architecture   Version
      Repository       Size
    ===================================================================================
    Installing group/module packages:
    nodejs           x86_64         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      rhel-AppStream   13 M
    nodejs-devel     x86_64         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      rhel-AppStream   203 k
    nodejs-nodemon   noarch         2.0.15-1.module+el9.1.0+15718+e52ec601
      rhel-AppStream   762 k
    npm              x86_64         1:8.19.2-1.18.10.0.3.module+el9.1.0+16866+0fab0697
      rhel-AppStream   2.2 M
    Installing dependencies:
    brotli           x86_64         1.0.9-6.el9
      rhel-AppStream   314 k
    brotli-devel     x86_64         1.0.9-6.el9
      rhel-AppStream   36 k
    ...
    Installing weak dependencies:
    nodejs-docs      noarch         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      rhel-AppStream   7.3 M
    nodejs-full-i18n x86_64         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      rhel-AppStream   8.2 M
    Installing module profiles:
    nodejs/common
    nodejs/development
    nodejs/minimal
    nodejs/s2i
    Enabling module streams:
    nodejs                        18
    
    Transaction Summary
    ===================================================================================
    Install  31 Packages
    
    Total download size: 37 M
    Installed size: 167 M
    Is this ok [y/N]: y
  2. Remove all packages from the nodejs:18 module stream:

    # dnf module remove --all nodejs:18
    (...)
    Dependencies resolved.
    ===================================================================================
    Package          Architecture   Version
      Repository       Size
    ===================================================================================
    Removing:
    nodejs           x86_64         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      @rhel-AppStream  43 M
    nodejs-devel     x86_64         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      @rhel-AppStream  953 k
    nodejs-docs      noarch         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      @rhel-AppStream  78 M
    nodejs-full-i18n x86_64         1:18.10.0-3.module+el9.1.0+16866+0fab0697
      @rhel-AppStream  29 M
    nodejs-nodemon   noarch         2.0.15-1.module+el9.1.0+15718+e52ec601
      @rhel-AppStream  2.0 M
    nodejs-packaging noarch         2021.06-4.module+el9.1.0+15718+e52ec601
      @rhel-AppStream  41 k
    npm              x86_64         1:8.19.2-1.18.10.0.3.module+el9.1.0+16866+0fab0697
      @rhel-AppStream  6.9 M
    Removing unused dependencies:
    brotli           x86_64         1.0.9-6.el9
      @rhel-AppStream  754 k
    brotli-devel     x86_64         1.0.9-6.el9
      @rhel-AppStream  55 k
    ...
    Disabling module profiles:
    nodejs/common
    nodejs/development
    nodejs/minimal
    nodejs/s2i
    
    
    Transaction Summary
    ===================================================================================
    Remove  31 Packages
    
    Freed space: 167 M
    Is this ok [y/N]: y
  3. Inspect the nodejs module after the removal:

    $ dnf module info nodejs
    ...
    Name             : nodejs
    Stream           : 18 [e] [a]
    Version          : 9010020221009220316
    Context          : rhel9
    Architecture     : x86_64
    Profiles         : common [d], development, minimal, s2i
    Default profiles : common
    ...
    Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled, [a]ctive

    No Node.js module stream is currently installed.

8.4. Additional resources