linux system log

linux system log

 

linux log file description

/var/log/message Information and error logs after system startup, which is one of the most commonly used logs in Red Hat
Linux /var/log/secure Security-related log information
/var/log/maillog Mail-related log information
/var/log/cron Log information related to scheduled tasks
/var/log/spooler Log information related to UUCP and news devices
/var/log/boot.log Log information related to daemon start and stop
/var/log/ wtmp This log file permanently records each user's login, logout, and system startup and shutdown events

/var/log/lastlog : record the time of the last successful user login, login IP and other information

/var/run/utmp: This log file records information about each user currently logged in. Such as who, w, users, finger, etc. need to access this file

/var/log/btmp : record the user, time and remote IP address of Linux login failures

/var/log/syslog: Only record warning information, often information about system problems, use lastlog to view

 

 

 

 

last

-a Display the host name or ip address from where to log in to the system on the last line.
-d Specifies the log file. Specifies the log file. Convert IP addresses to hostnames.
-f <logfile> Specifies the logfile.
-n <number of displayed columns> or -<number of displayed columns> Sets the number of displayed columns in the list.
-R Do not display the hostname or IP address of the logged in system.
-x Display system shutdown, restart, and execution level changes and other information

See all the restart and shutdown records below

last | grep reboot

last | grep shutdown

history

List all history:

[zzs @ Linux ] # history

List only the last 10 records:

[zzs@linux] # history 10 (Note, there is a space between history and 10)

Use the command record number to execute the command, execute the 99th command in the history list

[zzs@linux] #!99 (no space between ! and 99)

Repeat the previous command

[zzs @ linux] # !!

Execute the last command starting with rpm (!? ? represents a string, this String can be entered at will, Shell will search forward from the last historical command, and the first matching command will be executed.)

[zzs @ linux] #! rpm

List all histories screen by screen:

[zzs@linux]# history | more

Immediately clear the records of all current history commands in history

[zzs @ linux] #history -c

cat,tailwatch

All the logs of the system are under /var/log to see by yourself (the specific purpose can be checked by yourself, and the appendix lists some commonly used logs)

cat / var / log / syslog 等

cat /var/log/*.log

tail -f

How to view tail -f /var/log/messages in real time if the log is updating

You can also use watch -d -n 1 cat /var/log/messages

-d means to highlight different places, -n means how many seconds to refresh.

This command does not directly return to the command line, but prints the newly added content in the log file in real time.

This feature is very effective for viewing logs. If you want to stop the output, just press Ctrl+C.

In addition, there are more, less , dmesg |more, which will not be listed here, because there are too many commands, the key depends on personal preferences and business needs. The ones that are commonly used by individuals are the above

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325950746&siteId=291194637