Some practical operations for Linux to view the system's logs

Source: Internet
Author: User

Last

LAST,LASTB [Options][username ...] [TTY ...]

-a----The logon host name is displayed in the last column

-d----Convert IP address to host name

-F----File

-F----All logon and logout times

-I.----IP

-N----Quantity

-p----Specified time

-r----Host name not displayed

-S----Displays the specified logon time

-T----displayed to the specified time

-W----Display the user name and domain name in the output

-X----Displays information such as system shutdown, reboot, and execution level changes

See below for all reboots, shutdown logs

Shutdown

History

List all the history records:

[[email protected]Linux] # History

Only the last 10 records are listed:

[[email protected]] # History 10 (note, history and 10 have spaces in between)

Execute the command using the command record number, and execute the 99th command in the history list

[[email protected]] #!99 (! And 99 no spaces in the middle)

Repeat the previous command

[[email protected]] #!!

Executes the last command that starts with RPM (the!?? Represents a string that can be randomly lost, theshell will search forward from the last history command, and the first matching command will be executed. )

[[email protected]] #!rpm

List all history on a per-screen basis:

More

Immediately clears the history of all current historical commands

[[email protected]] #history-C
Cat, tail and watch

System all the logs are under the/var/log to see their own (specific use can be self-check, appendix lists some common logs)

Cat/var/log/syslog et Cat/var/log/*.log
Tail-f

If the log is updated, how to view tail-f in real time/var/log/messages

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

-d means highlighting different places, and-n indicates how many seconds are refreshed.

This instruction does not return directly to the command line, but instead prints the newly added content in the log file in real time,
This feature is very effective for viewing logs. If you want to terminate the output, press CTRL + C.

In addition to more, less,dmesg|more, here does not make a list, because the command too much, the key to see personal preferences and business needs. That's what you're used to.

Linux log file description

/var/log/message system startup information and error log, which is one of the most commonly used logs in Red Hat Linux
/var/log/secure Security-related log information
/var/log/maillog message-related log information
/var/log/cron log information related to timed tasks
/var/log/spooler log information related to UUCP and news devices
/var/log/boot.log Daemon starts and stops related log messages
/var/log/wtmp This log file permanently records each user logon, logoff, and system startup, downtime events


Source: https://www.cnblogs.com/lcword/p/5917398.html

Some practical operations for Linux to view the system's logs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.