Linux Package Management: apt, yum u0026 dnf Quiz Quiz

Explore key commands and best practices for managing packages using apt, yum, and dnf on Linux systems. This quiz assesses your understanding of installing, updating, and removing software efficiently across popular Linux distributions.

  1. Updating Package Repositories

    On a system using apt, which command should be used to update the local package repository index before installing new packages?

    1. apt-get clean
    2. apt upgrade
    3. apt update
    4. apt install

    Explanation: The correct command to update the local package repository index is 'apt update'. This ensures that your system knows about the latest available package versions. 'apt install' is used to install packages, not to update the index. 'apt-get clean' only removes downloaded package files from the cache and does not affect package information. 'apt upgrade' upgrades installed packages but does not refresh the package lists, so it should not be used alone before installation.

  2. Removing Unused Packages

    Which command in yum can be used to remove a software package and its unused dependencies from a Linux system?

    1. yum erase
    2. yum autoremove
    3. yum uninstall
    4. yum remove

    Explanation: 'yum autoremove' removes a package along with any dependencies that were installed with it and are no longer needed. 'yum remove' deletes specified packages but may leave unneeded dependencies installed. 'yum uninstall' is not a valid command in yum, and 'yum erase' performs a similar action to 'yum remove' but still may leave orphaned dependencies.

  3. Checking for Package Updates with dnf

    Suppose you want to see which packages have updates available on a system using dnf. Which command would you use?

    1. dnf list updates
    2. dnf upgrade
    3. dnf update
    4. dnf search updates

    Explanation: 'dnf list updates' displays all packages for which updates are available, allowing you to review them before proceeding. 'dnf upgrade' and 'dnf update' both start the actual process of updating packages rather than just listing them. 'dnf search updates' is not a valid dnf command, and would result in an error.

  4. Querying Installed Packages with apt

    If you need to determine whether a specific package, such as 'curl', is installed on an apt-based system, which command should you use?

    1. apt show curl
    2. apt-get search curl
    3. apt-cache install curl
    4. apt list --installed curl

    Explanation: 'apt list --installed curl' shows if 'curl' is among the installed packages. 'apt-get search curl' searches for the package in the repository lists but doesn't confirm if it is installed. 'apt show curl' displays package details, regardless of installation. 'apt-cache install curl' is not a valid command for checking installation status.

  5. Handling Disabled Repositories in yum

    If you want to install a package from a disabled repository using yum, which command-line option should you include?

    1. --enablerepo
    2. --use-repo
    3. --with-disabled
    4. --repo-enable

    Explanation: The '--enablerepo' option is used with yum to temporarily enable a disabled repository for a specific operation, such as installing a package. '--with-disabled' and '--use-repo' are not valid yum options and will result in errors. '--repo-enable' is a commonly confused but incorrect form of the correct flag.