Prefer `apt install ./package.deb` so Ubuntu can resolve repository dependencies in one transaction. If `dpkg -i` already left packages unpacked or unconfigured, diagnose the exact state, repair it without blind removals, and verify the package database.
An apt or dpkg lock usually means another package operation is already protecting the package database. Do not delete the lock file. Identify the owner, let healthy updates finish, terminate only a genuinely frozen frontend, then complete pending configuration and dependency repair.
Use the package database for installed ownership, repository content indexes for packages not installed, and archive queries for downloaded DEB/RPM files. These inventories describe packaged paths—not every file created later by services, scripts, or users.