Remove Packages Without Dependencies Using Yum [2 Methods]

YUM (Yellowdog Updater Modified) is a high-level package management tool primarily used in RedHat-based Linux distributions. Usually, yum handles dependencies automatically when installing or removing a package. But still, there are some options that can remove a package without dependencies using yum if applied wisely. In this tutorial, I’ll show you methods to remove packages without dependencies in many practical cases.

Process Flow Chart of Removing YUM Package without Dependencies

[Distro Used Throughout the Tutorial: RHEL 9.2]2 methods to remove a package without dependency using yum.

What Happens If You Remove Packages Without Dependencies?

If you remove packages without their dependencies in a Linux system, it can lead to various consequences, some of which can be problematic:

  • Loss of Functionality: The removed package may have been a dependency on other software or libraries. So, removing it can cause those dependent applications to malfunction.
  • Broken Dependencies: The removal of a package without its dependencies can result in a system with broken This can make it challenging to install or update other software in the future.
  • Difficulty in Recovery: Restoring the system to its previous state after removing packages without dependencies can be challenging and may require manual intervention to reinstall the parent components.

Therefore, I suggest you always check for dependencies and delete packages with dependencies whenever required.

2 Methods to Remove Package Without Dependencies Using YUM

YUM stands for Yellowdog Updater, Modified which is a tool used for package management in RedHat-based Linux distributions such as RHEL, Fedora and CentOS. Actually, it is a high-level package management tool that can handle dependencies automatically during the installation and removal of a package. In this tutorial, I’ll show you two easy methods of removing a package without dependencies using YUM.

You can read our Comparative Analysis of Methods to distinguish between these two methods and pick the best one for your needs.

1. Using “–noautoremove” to Remove YUM Package Without Dependencies

YUM with the option “remove” is used to uninstall a package. Generally, “yum remove” also removes dependencies while removing a package. But, by adding some more options, it can be set to remove only the specific package without it’s dependencies. Let’s see cases that can be handled by yum remove.

Case 01: Remove a Single Package Without Dependencies in RHEL

Although yum is an automatic package management tool that can handle dependencies, it provides an option –noautoremove to ignore auto-removing the dependencies while removing a package. So, you can take advantage of this option in removing a package without dependencies. I’ll demonstrate this method by removing Firefox. To master this method, follow the steps below:

  1. Open the RHEL/Fedora terminal.
  2. Run this command to see whether Firefox is installed in your system:
    rpm -qa | grep firefox
    EXPLANATION
    • rpm: Uses RPM package manager.
    • -qa: Stands for Query A This is used to query the status of all installed packages.
    • | (Piping Symbol): Transfers the output of a command as the input of the next command.
    • grep: Searches for a keyword or pattern from output in the terminal.
    • firefox: Name of the package that I want to search.

    checking if firefox is installedIf you see this kind of output, it means that Firefox is installed in your system.

    Note: If you don’t see the above output, use the command to install Firefox:

    sudo yum install -y firefox

    Then continue from step

  3. again.
  • Run the below command to remove Firefox:
    sudo yum remove –noautoremove firefox
    EXPLANATION
    • sudo: Enables administrative permissions.
    • yum: Calls yum package management tool.
    • remove: Command to remove a package using yum.
    • –noautoremove: Ignores automatic removal of dependency packages.
    • firefox: Name of the package.
  • Enter the user password if asked.
  • Type Y and press ENTER when the confirmation prompt appears.

    removing firefox without dependencies using yum.The above command will keep the dependencies and remove Firefox from the system.

  • Case 02: Remove Specific Version of a Package Without Dependencies

    Like removing a main package shown in the previous case, yum can also remove a specific version of a package. If you are using multiple versions of the same package, you can remove any one of them. To do that, follow the below steps:

    1. Open the RHEL/Fedora terminal.
    2. Run this command to list all the versions of Google Chrome installed in your system:
      sudo yum --showduplicates list google-chrome-stable
      EXPLANATION
      • sudo: Enables administrative permissions.
      • yum: Calls yum package management tool.
      • –showduplicates: Command to show all the versions available in your system.
      • list: Command for creating a list preview in the terminal.
      • google-chrome-stable: Name of the package.
    3. Type the user password and press ENTER.listing available versions of chromeThe above output indicates I’ve two versions of Google Chrome in my RHEL. Let’s say, I want to remove the package with version number  96.0.4664,45-1 but keep the dependencies. To do that, I have to maintain the following syntax:
      sudo yum remove –noautoremove <package name><hyphen symbol><version number>
      EXPLANATION
      • remove: Command to remove a package using yum.
      • –noautoremove: Ignores automatic removal of dependency packages.
      • <package name>: Name of the package you want to remove.
      • <hyphen symbol>: Add – symbol without SPACE.
      • <version number>: Type the version number of the package without SPACE.

      So, to remove google-chrome-stable package with version number 96.0.4664,45-1, I have to follow the next step.

    4. Run the command:
      sudo yum remove –noautoremove google-chrome-stable-96.0.4664.45-1
    5. Type Y and press ENTER when the confirmation prompt appears.removing specific version of chrome using yumThe above command will keep the dependencies and remove google-chrome-stable package from the system.

    Case 03: Remove Multiple Packages Without Dependencies

    If you want to remove multiple packages from YUM repository, just type the package names separated by SPACE as the following syntax:

    sudo yum remove –noautoremove <package 1> <package 2> …
    EXPLANATION
    • sudo: Grants administrative permissions.
    • yum: Calls YUM package management tool.
    • remove: Command to remove a package using yum.
    • –noautoremove: Ignores automatic removal of dependency packages.
    • <package 1> <package 2>: SPACE-separated name of the package you want to remove.

    For demonstration, I’ll show you how to remove Firefox, Atlas and CopyQ. The below steps guide in a step-by-step procedure:

    1. Open the RHEL/Fedora terminal.
    2. Run the below command:
      sudo yum remove –noautoremove atlas firefox copyq
    3. Enter the user password if asked.removing multiple packages at once without dependencyThe above output shows that yum is removing only the mentioned three packages without any dependencies.

    Method 02: Using “yum setopt” to Remove YUM Package Without Dependencies

    To remove package without dependencies in YUM, use –setopt option to disable the clean_requirements_on_remove option. Here’s how:

    1. Open the RHEL/Fedora terminal.
    2. Run this command to see whether Firefox is installed in your system:
      rpm -qa | grep google
      EXPLANATION
      • rpm: Uses RPM package manager.
      • -qa: Stands for Query A This is used to query the status of all installed packages.
      • | (Piping Symbol): Transfers the output of a command as the input of next command.
      • grep: Searches for a keyword or pattern from output in the terminal.
      • firefox: Name of the package that I want to search.

      checking if google chrome is installedIf you see this kind of output, it means that google-chrome-stable is installed in your system.

      Note: If you don’t see the above output, use the command to install Google Chrome:

      sudo yum install -y google-chrome-stable

      Then continue from step

    3. again.
  • Run the below command to remove google-chrome-stable:
    sudo yum --setopt=clean_requirements_on_remove=0 remove google-chrome-stable
    EXPLANATION
    • sudo: Enables administrative permissions.
    • yum: Calls yum package management tool.
    • –setopt=clean_requirements_on_remove=0:
    • remove: Command to remove a package using yum.
    • google-chrome-stable: Name of the package.
  • Enter the user password if asked.
  • Type Y and press ENTER when the confirmation prompt appears.removing google chrome without dependency using setopt optionThe above command will keep the dependencies and remove Google Chrome from the system.
  • Comparative Analysis of Methods

    I’ve shown two ways to remove packages without dependencies using YUM in RHEL. You might be confused to decide which one suits you the best. Here’s a comparison between the methods provided to give you an overview of the pros and cons.

    Methods Pros Cons
    Method 1
    • Prevents YUM from automatically removing packages that it considers as no longer required.
    • Can remove a specific version if multiple versions are available.
    • You’ll need to manually manage dependencies, which can be time-consuming and error-prone.
    Method 2
    • Allows to configure specific options for individual repositories or packages.
    • It helps ensure that yum maintains system integrity.
    • Can be complex as you need to specify the exact configuration option and understand how it affects YUM.

    Use Method 1 when you want to retain full control over package removal and are prepared to manage dependencies manually. Use Method 2 if you need to customize the behavior of yum for specific repositories or packages. However, this option is generally more suitable for advanced users who understand the configuration options and their implications.

    Common Challenges That May Arise

    Removing a package without its dependencies using yum in RedHat-based Linux distributions can present some challenges. Because, yum is designed to manage dependencies automatically. Here are some common challenges you might encounter in this case:

    A. Breaking Package Integrity

    Challenge: If you remove packages that were initially installed as dependencies, it can lead to a system where certain functionalities are missing or broken.

    Solution: Be sure you understand the implications of removing a package without its dependencies. I suggest you always use the rpm command with caution.

    B. Package Database Conflicts

    Challenge: Removing packages without their dependencies may result in inconsistencies in the package database used by YUM, which can lead to problems when installing or updating other software in the future.

    Solution:  Consider using rpm with the –nodeps option as a last resort and carefully document what you’ve done for future reference.

    C. Manual Cleanup

    Challenge: If you remove packages without their dependencies, you might need to perform manual cleanup for unused dependencies later.

    Solution: It’s important to monitor your system if there is any unusual behavior without the parent package, and then remove the dependencies also.

    Conclusion

    In general, I recommend you avoid forcefully removing packages without dependencies unless you have a strong reason to do so and a clear understanding of the potential consequences. It’s always better to leave the things to package managers. But if you have to do it for a special purpose task, you can follow the above risk-free methods.

    People Also Ask

    How to remove a package in Linux without dependencies?

    If you are using Debian-based Linux such as Ubuntu, you can use APT package manager to remove a package with the command sudo apt remove --no-install-recommends <package name>. But if you are using RedHat-based Linux such as RHEL, CentOS ect, use YUM with the command sudo yum remove –noautoremove <package name>. Replace <package name> with the actual name of the package you want to remove.

    How do I completely remove a package from yum?

    To remove a package completely from yum repository, run this command: sudo yum remove <package name>. Use the actual name of the package instead of <package name>. YUM is designed to remove the dependencies automatically to aid complete removal.

    How to skip dependencies with YUM?

    YUM doesn’t provide to skip all dependencies during the installation. But you can skip specific dependencies using --exclude option in the following syntax: yum install –exclude=<dependency names> <package name>. You have to mention the dependency packages name you want to skip in the place of <dependency names>. On the other hand, to skip dependencies in removing a package, use this command: sudo yum remove –noautoremove <package name>.

    How to remove package with dependencies in Linux?

    By default, yum removes dependencies while removing a package. Run sudo yum remove <package name> command replacing <package name> with the actual name of the package.

    Related Articles


    << Go Back to Dependencies in Linux | Package Management in Linux | Learn Linux Basics

    4.8/5 - (6 votes)
    Ashikur Rahman

    Hello, I’m Ashikur Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation in Computer Science and Engineering from Khulna University of Engineering & Technology (KUET). Also, I’m pursuing my master’s in the same department at Bangladesh University of Engineering & Technology (BUET). I like to learn new technologies, contribute, and share those with others. Here my goal is to provide beneficial and user-friendly articles on Linux distribution for everyone. Read Full Bio

    Leave a Comment