The package database holds records dpkg made at installation. The files on disk live a life of their own.
When dpkg installs a package, it writes to the package database the package's name, version, state and the list of every file it placed in the system. The line Status: install ok installed means the package is installed and configured, with no errors during installation.
After that the record changes only when dpkg itself handles the package — installing, upgrading or removing it. An rm that deletes the program file leaves the database alone. So the file list in the record and the contents of the disk can drift apart.
dpkg -L prints the package file list from the record, while ls checks the disk itself:
The dpkg -L list includes /usr/bin/lab-pkg-report, while ls prints No such file or directory.
You deleted /usr/share/doc/tree/TODO with sudo rm. What will dpkg -L tree print?
-
dpkg -Ldoes not check files and reports no damage: it prints the recorded list. -
The list comes from the database record, and
rmdoes not change it. The missing file stays in the list; onlylschecks the disk.
dpkg -L prints the list from the package record made at installation. Whether the file is on disk is shown by ls -l /usr/share/doc/tree/TODO: No such file or directory.
Key points
- dpkg writes the package state and its file list to the package database.
- Only dpkg operations change the record; deleting a file by hand leaves it alone.
-
dpkg -Lprints the files from the record;lschecks whether they are on disk.