In Linux, you can verify system restarts and view reboot history using various commands and log files. Here are some methods to check and verify system restarts:
- Using the
lastCommand:Thelastcommand displays a list of system login entries and system shutdown/reboot times. To view reboot history, run:last rebootThe output will show a list of system reboot times, who initiated the reboot, and from which terminal or IP address it occurred.
- Checking System Logs:System logs contain information about system events, including reboots. The
/var/log/messagesor/var/log/syslogfile typically contains reboot information. You can usegrepto filter the relevant entries:grep 'reboot' /var/log/messagesorbashCopy codegrep 'reboot' /var/log/syslogThis will display lines indicating system reboots along with timestamps.
- Using the
uptimeCommand:Theuptimecommand provides information about system uptime, including the current time, how long the system has been up, and the number of logged-in users. The load average values can also give you an idea if the system recently restarted:uptimeIf the system uptime is low, it suggests a recent restart.
- Checking the
/var/log/wtmpFile:The/var/log/wtmpfile contains a record of all logins and logouts, including system reboots. You can use thelastcommand with the-foption to view this file:last -f /var/log/wtmpThis will display a more detailed history of logins, logouts, and reboots.
- Using Audit Logs (if configured):If you have the auditd service configured and running, it may log system events, including reboots, in
/var/log/audit/audit.log. You can use theausearchandaureportcommands to search for and report on reboot events in the audit log.
These methods should help you verify system restarts and identify when and why they occurred. The choice of method may depend on your specific needs and the availability of logs on your system.