devsetup1-2 Exercise 2: What Is Already Installed? ==================================================== STEP 1: RECORD THE STARTING STATE --------------------------------- For each tool, ask dpkg whether the package is installed. This prints the status line for installed packages and an error for missing ones: for p in build-essential curl wget git vim htop tree unzip zip jq ripgrep \ ca-certificates gnupg pciutils; do if dpkg -s "$p" >/dev/null 2>&1; then echo "installed: $p"; else echo "NOT installed: $p"; fi done | tee ~/before.txt STEP 2: INSTALL THE WHOLE LIST ------------------------------ sudo apt install build-essential curl wget git vim htop tree unzip zip jq ripgrep \ ca-certificates gnupg pciutils Read apt's summary before answering y. It has three lists that answer the question directly: - "The following NEW packages will be installed:" is what actually needed installing. - Packages that were already present do not appear in that list. apt also prints lines such as "git is already the newest version" for tools that were already there. - "0 upgraded, N newly installed" gives the count. Compare the NEW list with ~/before.txt. Every name marked NOT installed there should appear in the NEW list; every name marked installed should not. STEP 3: PRINT THE VERSIONS -------------------------- gcc --version | head -n 1 make --version | head -n 1 curl --version | head -n 1 wget --version | head -n 1 git --version vim --version | head -n 1 htop --version tree --version unzip -v | head -n 1 zip -v | head -n 2 | tail -n 1 jq --version rg --version | head -n 1 gpg --version | head -n 1 lspci --version Note that a few packages (build-essential, ca-certificates) are not commands. build-essential installs gcc and make, and ca-certificates installs data files. Checking the tools they provide is how you verify them. WHY THIS WORKS AS AN ANSWER --------------------------- Recording the starting state first turns "I think it was already there" into evidence. It also previews Chapter 3, where checking before installing becomes a routine habit rather than an exercise.