/var/log/alternatives.log: Explanation & Insights
Contains changes made by update-alternatives
The /var/log/alternatives.log
file is a log file in the Linux operating system
that records the history of all the changes made by the update-alternatives
command. The update-alternatives
command
is part of the Debian alternatives system, which is a mechanism for managing multiple versions of a file, or command on
a Debian-based system like Ubuntu.
Importance of /var/log/alternatives.log
The /var/log/alternatives.log
file is crucial because it allows system administrators to keep track of all changes
made to system files via the update-alternatives
command. This log file can be
especially beneficial when troubleshooting issues related to system files, where a previous version of a file or command
might need to be restored.
Understanding the /var/log/alternatives.log File Content
The /var/log/alternatives.log
file contains entries that look something like this:
2022-01-01 12:34:56 update-alternatives 2022: /usr/bin/java: Manual mode link from /usr/bin/java to /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Each entry indicates the date and time of the change, the name of the
command (update-alternatives
), the process ID of
the command, the file that was changed, the mode of the change (manual or automatic), and the new link for the file.
Using the /var/log/alternatives.log File
You can use the cat
, less
, or tail
commands to view the content of the /var/log/alternatives.log
file. For
example, you can use the following command to display the last 10 entries in the log file:
$ tail -n 10 /var/log/alternatives.log
Diagnosing Issues with /var/log/alternatives.log
If you are experiencing system problems and suspect that recent changes to system
files might be the cause, you can use the /var/log/alternatives.log
file to see what changes have been made. If
necessary, you can then use the update-alternatives
command to revert the
changes.
Maintaining the /var/log/alternatives.log File
Like other log files, the /var/log/alternatives.log
file can grow over time and consume a lot of disk space.
Therefore, it is important to regularly archive or clear old entries from the log file. This can be done using
logrotate, a utility for managing log files.
Conclusion
The /var/log/alternatives.log
file is an essential tool for managing and troubleshooting system files on a
Debian-based Linux system. By understanding what this file contains and how to use it, you can maintain the health of
your system and diagnose problems more effectively.