dpkg
the tool beneath aptdpkg is the low-level tool that apt drives. It installs one .deb file you already have, without fetching dependencies, and it is the way to ask "what is installed?" and "which package put this file here?"
apt fetches and resolves; dpkg unpacks and keeps the records.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
The first column is the state, then the name, version, architecture and description.
/usr/bin/ssh came from openssh-client. Useful for finding what to reinstall, or where a strange file came from.
Every path the package created, starting from the root.
--verify compares installed files with what the package shipped. Silence means nothing has been altered.
Switches
A switch changes how the command behaves. These are the ones used day to day; man dpkg lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-i FILE- Install a .deb file.
-r NAME- Remove a package, keeping its configuration.
-P NAME- Purge: remove a package and its configuration.
-l- List installed packages.
-L NAME- List the files a package installed.
-S PATH- Find the package that owns a file.
-s NAME- Show a package’s status and details.
--verify- Check installed files against the package’s records.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
sudo dpkg -i package.debInstalls a downloaded .deb file.
sudo apt install -fFetches the dependencies a dpkg -i left missing.
dpkg -s nginxShows the status and details of one installed package.
dpkg -c package.debLists the files inside a .deb before installing it.
In cybersecurity
A .deb installed by hand skips every check the repositories provide.
Installation scripts inside a .deb execute as root. A package from an untrusted source is a root shell handed to its author.
Software installed with dpkg -i from a download has no repository behind it, so security fixes never arrive unless you fetch them.
"dpkg --verify" lists files that differ from the packaged originals — a quick test for binaries replaced by an intruder.