Ubuntu APT history is recorded mainly in /var/log/apt/history.log, which shows package operations such as installations, removals, and upgrades, along with their dates and the command used. For a more detailed record of package-manager activity, check /var/log/dpkg.log; older logs may be compressed and rotated.
What Ubuntu’s APT history records
APT is Ubuntu’s high-level package management system. Commands such as apt install, apt remove, and apt upgrade use APT to resolve dependencies and coordinate package changes. The history log provides a readable account of those transactions, rather than a complete record of every action performed on the computer.
A typical entry in /var/log/apt/history.log includes fields such as:
- Start-Date and End-Date: when the operation began and finished.
- Commandline: the command that started the transaction, when recorded.
- Requested-By: the user ID associated with the request, if available.
- Install, Upgrade, Remove, and Purge: package names and, often, version changes.
This can help answer practical questions: Was a package removed during an upgrade? Which version was installed? Did an APT command run at a particular time? It does not normally record every configuration change made inside an application, nor does it guarantee that a package still exists in Ubuntu’s current repositories.
Find recent APT transactions
Open a terminal and display the current history file:
less /var/log/apt/history.log
Use the arrow keys or Page Up and Page Down to browse, and press q to quit. To print it all, use:
cat /var/log/apt/history.log
For a quick search, grep can locate package names or transaction fields. For example, replace vlc with the package you are investigating:
grep -i -C 4 'vlc' /var/log/apt/history.log
The -C 4 option includes nearby lines, which helps show the transaction surrounding a match. You may need administrator access to read some system logs, depending on file permissions and your system setup. If permission is denied, try sudo less /var/log/apt/history.log; use elevated access only for reading the log, not for commands copied from an untrusted source.
Check older and detailed package logs
Ubuntu rotates logs so they do not grow indefinitely. When the current APT history file is rotated, older records may appear as history.log.1 or as compressed files such as history.log.2.gz. List available APT logs with:
ls -lh /var/log/apt/
Read a compressed history log without unpacking it using zless or zcat:
zless /var/log/apt/history.log.2.gz
Exact rotated filenames vary according to the machine’s log-rotation schedule and how long records have been retained. If you need older information, check all relevant rotated files, not just the current one.
For lower-level details, inspect the dpkg log:
less /var/log/dpkg.log
dpkg is the system that performs many of the actual package installation and removal steps. Its log commonly records individual actions, package names, versions, and timestamps. Rotated files may be named dpkg.log.1 or compressed with a .gz suffix. APT history is often easier for understanding a complete user-requested transaction; dpkg logs can help clarify the individual package changes within it.
Read an entry and understand its limits
Suppose a history entry says that an operation upgraded curl from one version to another and also installed several libraries. That does not necessarily mean you explicitly asked to install every library: APT may have added dependencies to satisfy the requested change. Likewise, a package marked for removal may have been removed as part of resolving another operation.
APT history is not the same as a shell command history. A shell history file may show commands you typed, but it can be incomplete, belong to a particular user, or omit commands run by other tools. APT’s transaction record focuses on package operations. Neither log proves who was physically using the computer, and logs can be deleted, rotated, altered, or absent after a reinstall.
Also, an APT log is not a simple undo file. Reinstalling an old package version may be impossible if that version is no longer available, and reversing an upgrade can cause dependency or security problems. Use the logs to investigate first; plan any rollback carefully and prefer supported recovery procedures.
Common problems and practical checks
- The file is empty or missing: There may not have been any recorded APT transactions yet, the logs may have been rotated or removed, or you may be checking the wrong system. Look in
/var/log/apt/and inspect dpkg logs too. - You cannot read it: Check permissions and, if necessary, use
sudoto view the file. - The package name does not appear: Search case-insensitively and check older rotated logs. Also consider whether the software was installed another way, such as with Snap, Flatpak, or a manually downloaded installer; those actions are not generally recorded as APT package transactions.
- You want to know when a package was installed: Find the relevant transaction in APT history, then compare it with dpkg’s timestamped records. Be careful: an upgrade or reinstall can produce later entries than the package’s original installation.
To preserve useful records for a long time, copy the relevant logs to a secure location before rotation or system replacement. Logs may reveal software choices, usernames, and activity times, so treat saved copies as potentially sensitive.
Frequently Asked Questions
Where is Ubuntu APT history stored?
The main readable transaction log is /var/log/apt/history.log. Detailed package actions are also recorded in /var/log/dpkg.log. Older versions may be in rotated files in the same log directories.
How do I see what APT installed recently?
Open /var/log/apt/history.log and look for the latest transaction’s Install field. Check Upgrade and Remove as well if you want the full set of changes.
Can I see APT history from the terminal?
Yes. Use less /var/log/apt/history.log to browse, grep to search, or zless for a compressed rotated log.
How far back does Ubuntu keep APT history?
There is no fixed duration that applies to every installation. Log rotation settings and system maintenance determine how many records remain; check the rotated files currently present under /var/log/apt/.
Does APT history show Snap or Flatpak installs?
Generally, no. APT history records APT package transactions, not operations performed by separate package-management systems such as Snap or Flatpak. Check the relevant tool’s own records for those installations.