linux System files are usually in /var/log The following is an explanation of the documents that often appear below
/var/log/message --------------------------------------- Information and error log after system startup
/var/log/secure ------------------------------------------ Security related log information
/var/log/maillog ------------------------------------------ Log information related to email
/var/log/cron ---------------------------------------------- Log information related to scheduled tasks
/var/log/spooler ------------------------------------------ And UUCP and news Device related log information
/var/log/boot.log ----------------------------------------- Daemons start and stop related log messages
/var/log/wtmp --------------------------------------------- Permanently record each user login 、 Logout and system startup 、 Downtime Events
/var/run/utmp --------------------------------------------- Record the user information that is currently logging in to the system ;
/var/log/btmp ---------------------------------------------- Log failed login attempts .
Historical record
last | grep reboot ----------------------------------------- Check the restart command
history ------------------------------------------------------- Historical operation
history -c ---------------------------------------------------- Clear all current history immediately
see file
tail -f /var/log/*---------------------------------------------- Check that file in real time
cat /var/log/message ------------------------------------- Look at that file
vi -------------------------------------------------------------- You can either view or change the contents of the file
Linux The system queries the latest restart time command of the machine
last The command not only lists specific users of the session in chronological order from near to far 、 Terminal and host names , You can also list the users who log in at a specified date and time . Each line output to the terminal contains the user name 、 Session terminal 、 Host name 、 When the conversation begins and ends 、 The duration of the conversation .
1. Use last Command to query the most recently logged in user and the time and date of system restart . Input :
$ last reboot View all restart log information
perhaps
last reboot | head -1 Check out the latest one
Check the time and date when the system was last shut down
You can use the following command to display the date and time of the last shutdown :
$ last -x|grep shutdown | head -1
In command ,
-x: Display system shutdown and operation level change information
Here is last Some other options for the command :
$ last
$ last -x
$ last -x reboot
$ last -x shutdown
Check the normal running time of the system
Another order is as follows :
$ uptime -s