Linux Package Management 5 — Questions and Answers
Question 1: What is the function of `apt-get -f install`?
- Force-installs a package ignoring conflicts
- Fixes broken package dependencies (Correct answer)
- Installs a package from a file path
- Fetches missing package files
Correct answer: Fixes broken package dependencies
`apt-get -f install` (fix-broken) attempts to repair a system with broken dependencies by installing or removing packages as needed.
Question 2: Which command would you use to add a new Flatpak remote repository named 'flathub'?
- flatpak install flathub
- flatpak remote-add --if-not-exists flathub <url> (Correct answer)
- flatpak add-remote flathub <url>
- flatpak repo-add flathub <url>
Correct answer: flatpak remote-add --if-not-exists flathub <url>
`flatpak remote-add` registers a new remote repository, and `--if-not-exists` prevents an error if it's already configured.
Question 3: What does `rpm --rebuilddb` do?
- Reinstalls all packages
- Rebuilds the RPM database from installed package headers (Correct answer)
- Removes corrupted packages
- Re-downloads all RPM package metadata
Correct answer: Rebuilds the RPM database from installed package headers
`rpm --rebuilddb` reconstructs the RPM database files from the installed package headers, used to fix a corrupted database.
Question 4: How do you prevent a specific package from being upgraded with `apt-mark`?
- apt-mark freeze package
- apt-mark hold package (Correct answer)
- apt-mark pin package
- apt-mark lock package
Correct answer: apt-mark hold package
`apt-mark hold package` marks a package so that `apt-get upgrade` and `apt upgrade` skip it.
Question 5: Which `dnf` module command switches a module stream to a different version?
- dnf module change
- dnf module switch-to (Correct answer)
- dnf module enable
- dnf module reset
Correct answer: dnf module switch-to
`dnf module switch-to` changes the active stream of a module (e.g., switching PHP from 7.4 to 8.0) and updates packages accordingly.
Question 6: What is the role of `/etc/yum.repos.d/` directory?
- Stores downloaded RPM packages
- Contains repository definition files for YUM/DNF (Correct answer)
- Holds GPG keys for package verification
- Caches package metadata
Correct answer: Contains repository definition files for YUM/DNF
Each `.repo` file in `/etc/yum.repos.d/` defines a repository that YUM or DNF can use to find and install packages.
Question 7: Which command lists all available versions of a package in APT's cache?
- apt show --all-versions package
- apt-cache policy package (Correct answer)
- apt list --versions package
- dpkg -l package --all
Correct answer: apt-cache policy package
`apt-cache policy package` shows the installed version, candidate version, and all available versions with their repository priorities.
What is the function of `apt-get -f install`?