LCA Package Management & Software Installation 3 — Questions and Answers
Question 1: What does 'dpkg --get-selections' output?
- A list of all packages and their installation states (Correct answer)
- Only explicitly installed packages
- Packages selected for upgrade
- Packages available in the repository
Correct answer: A list of all packages and their installation states
dpkg --get-selections lists all packages known to dpkg along with their current state (install, deinstall, purge, hold).
Question 2: Which zypper command is used to search for a package by name on SUSE Linux?
- zypper search (Correct answer)
- zypper find
- zypper query
- zypper lookup
Correct answer: zypper search
zypper search (or zypper se) searches for packages by name or description in configured repositories.
Question 3: How do you prevent a specific package from being upgraded by apt on a Debian system?
- apt-mark hold <package> (Correct answer)
- apt-mark freeze <package>
- dpkg --lock <package>
- apt pin <package>
Correct answer: apt-mark hold <package>
apt-mark hold prevents a package from being automatically installed, upgraded, or removed by apt.
Question 4: What is the function of the '/var/lib/rpm' directory?
- Stores the RPM package database (Correct answer)
- Stores downloaded RPM packages
- Stores RPM package source files
- Stores RPM build logs
Correct answer: Stores the RPM package database
The /var/lib/rpm directory contains the Berkeley DB database files that track all installed RPM packages.
Question 5: Which dnf command displays the transaction history and allows rollback?
- dnf history (Correct answer)
- dnf log
- dnf transactions
- dnf rollback
Correct answer: dnf history
dnf history shows past transactions and supports undo/redo operations to roll back package changes.
Question 6: What does 'apt-get install --no-install-recommends' do differently from a standard install?
- Installs only required dependencies, skipping recommended packages (Correct answer)
- Installs without asking for confirmation
- Skips optional and suggested packages only
- Installs recommended packages instead of required ones
Correct answer: Installs only required dependencies, skipping recommended packages
The --no-install-recommends flag tells apt to install only mandatory dependencies, not the 'Recommends' listed by the package.
Question 7: Which command rebuilds the RPM database if it becomes corrupted?
- rpm --rebuilddb (Correct answer)
- rpm --rebuild
- rpm -Va --fix
- rpmdb --rebuild
Correct answer: rpm --rebuilddb
rpm --rebuilddb reconstructs the RPM database from the installed package headers, fixing corruption issues.
What does 'dpkg --get-selections' output?