Commands for linux system to view logs
This article mainly explains the "linux system log view command", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "linux system log view command" bar!
Tail command
The tail command uses the illustration:
Examples of common commands:
① dynamically view the latest write log
Tail-f filename.log # cycle to read the latest write log ctrl + c interrupt log display
② dynamically views the latest write log and filters it by keyword
Tail-f filename.log | grep 'keyword' # read the latest write log through the pipe "|" combined with the lookup command ctrl + c interrupt the log display more command
The more command uses the illustration:
Examples of common commands:
① presses the spacebar to view the contents of the file dynamically
More filename.log
Press the space key to display the next screen of the text
Press enter to display only the next line of the text
Press H key: displays a help screen with relevant help information
Press B to display the contents of the previous screen
Press Q: exit the more command.
② is combined with pipeline "|" multiple commands are used together.
More filename.log | grep 'keyword'
③ finds the content before and after keyword
More filename.log | grep 'keyword'-10 lines before B 10 # more filename.log | grep 'keyword'-10 lines before and after C 10 # thank you for reading, the above is the content of "linux system log view command". After the study of this article, I believe you have a deeper understanding of the linux system log view command, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!