Ubuntu and other Debian based system logs every package operation, like installations, updates, and removals in the /var/log/apt directory. You should always check these logs to keep tracks about the packages on your system. This information can be accessed using several methods.
This tutorial will help you with the methods of accessible package update history on your Debian systems.
1. The APT History Log
The APT package management system keeps a log of all the activities in a history file. You can view this file using a text editor or by using the cat command:
cat /var/log/apt/history.log
This command will display the contents of the history.log file, which includes the date, the action performed (install, upgrade, remove), and the names and versions of the packages affected.
If the system has been running for a long time, log rotation might have occurred, and older logs will be archived in the same directory with a .gz extension. You can use zcat or zgrep to read these without explicitly unzipping them:
zcat /var/log/apt/history.log.*.gz
2. The APT Term Log
In addition to the history log, APT also creates a term log which saves a more detailed account of the update process. It save complete transcription of what you would see in the terminal during an update. You can view this file with:
less /var/log/apt/term.log
For older logs:
zless /var/log/apt/term.log.*.gz
3. Using the grep Command
If you are looking for updates to a specific package, grep can be used to filter the logs:
grep "package-name" /var/log/apt/history.log
Replace package-name with the actual name of the package you’re interested in.
4. GUI Methods
For the users with graphical interface, the gnome-system-log tool can be used to view these logs. However, this tool may not be available with default installation. You need to be installed separately.
sudo apt-get install gnome-system-log
Once installed, you can find it in the application menu or start it from the terminal. It provides a user-friendly interface to search and filter through the log files.
5. Using Third-party Tools
There are also third-party tools available that can provide a more structured and user-friendly way to view the update history. One such tool is aptitude, which can be installed using:
sudo apt-get install aptitude
After installing, run aptitude and use its interactive interface to review package histories.
Conclusion
It is essentials to keep track of packages updates specially on production environments. You should add this in weekly maintenance check list and maintain a sheet about all packages that are installed, updated or deleted during this period. This will help you keep you system healthy, secured from unwanted packages and keep your system running smoothly.