Sort out some common commands for Linux to view system logs.

Source: Internet
Author: User

Sort out some common commands for Linux to view system logs.

Organize common commands for viewing system logs in Linux

Last

-A displays the host name or IP address from which to log on to the system in the last line.
-D specifies the record file. Specifies the record file. Converts an IP address to a host name.
-F <Record File> specifies the record file.
-N <display columns> or-<display columns> sets the number of columns displayed in the list.
-R does not display the host name or IP address used to log on to the system.
-X: displays information such as system shutdown, reboot, and change of execution level.

The following describes all restart and shutdown records.

last | grep rebootlast | grep shutdown


History

List all history records:

[zzs@Linux] # history

Only the last 10 records are listed:

[Zzs @ linux] # history 10 (Note: there are spaces between history and 10)

Use the Command record number to execute the command and execute the 99th commands in the History List

[Zzs @ linux] #! 99 (! There is no space in the middle of "and" 99)

Repeat the previous command

[zzs@linux] #!!

Run the last command starting with rpm (!? ? It indicates a String, which can be input at will. Shell searches forward from the last historical command, and the first matched command will be executed .)

[zzs@linux] #!rpm

List all history records on a screen:

[zzs@linux]# history | more

Clear all history commands of history now

[zzs@linux] #history -c

Cat, tail, and watch

All the system logs are read by yourself under/var/log (you can check the specific usage, and the appendix lists some common logs)

Cat/var/log/syslog and other cat/var/log/*. log


Tail-f

If the log is being updated, how can I view tail-f/var/log/messages in real time?

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

-D indicates the highlight of different places, and-n indicates the number of seconds to refresh.

This command does not directly return the command line, but prints newly added content in the log file in real time,
This feature is very effective for viewing logs. To terminate the output, 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 is personal preferences and business needs.

Linux Log File description

/Var/log/message information and error logs after the system is started. It is one of the most common logs in Red Hat Linux.
/Var/log/secure security-related log information
/Var/log/maillog and mail-related log information
/Var/log/cron log information related to scheduled tasks
/Var/log/spooler logs related to UCP and news Devices
/Var/log/boot. log daemon starts and stops related log messages
/Var/log/wtmp this log file permanently records the logon, logout, and system startup and shutdown events of each user.



Additional reading

Collect and collect articles on common Linux commands

1 Linux curl introduction (1)

2. detailed introduction to the-path-prune parameter in the Linux find command

How to Use the locate command in 3Linux to search for a specified file

Summary of how to view memory usage in 4 Linux

How to set the 5CentOS DVD as the default yum source for software download and installation in the DVD

6 Linux tar command Tar Time Stamp in the Future solution

7. How to sort Arrays Using awk text processing tools in Linux

8. How to set a fixed IP address in CentOS 6.5

9Linux Regular Expression User Guide

10Linux system wget command for downloading files

11 Linux ps command practice

12. Functions of the df command you do not know in Linux

1320 Linux Command Interview Questions and answers

144 most popular Linux platform open-source Editor

Solution to errors in using direction keys in the 15Ubuntu text editor vi

Summary of Common commands for viewing system logs in 16Linux

How to Improve the copy efficiency of large files in 17Linux to save time

18what command is used in Linux to view port usage?

19Linux text search tool grep Usage Details

20 Linux xargs command

Eight Methods for counting the number of file rows using 21Shell scripts

22 solve the problem of disconnecting after an ssh Login, the idle time is too long

23 centos user-related commands

24grep: How to ignore filtering. svn directories and how to ignore multiple directories

25 centos user-related commands

26 solve the problem of disconnecting after an ssh Login, the idle time is too long

27 Apache and PHP hidden version information

28. 14 useful examples of the sort command in Linux (1)

Example of 2914 Linux grep commands

3011 Linux terminal commands that surprised you

31 how to quickly clear files in linux and unix

View the real-time traffic of the NIC in 32Centos

335 classic and interesting Linux Command Line skills

34 how to use Linux Ctrl + Z

Introduction to 3512 linux Process Management commands

36. How to Use the tar command to compress and decompress files in Linux

37Linux 7 commands used to browse Web pages and download files

38Linux: Practical commands for creating chat servers and removing redundant software packages

39. usage of the md5sum command in Linux

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.