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.
On a system using apt, which command should be used to update the local package repository index before installing new packages?
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.
Which command in yum can be used to remove a software package and its unused dependencies from a Linux system?
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.
Suppose you want to see which packages have updates available on a system using dnf. Which command would you use?
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.
If you need to determine whether a specific package, such as 'curl', is installed on an apt-based system, which command should you use?
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.
If you want to install a package from a disabled repository using yum, which command-line option should you include?
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.