Three commands for viewing logs in Linux: 1. To view real-time changing logs, the code is [tail -f filename]; 2. To search for logs near keywords, the code is [cat -n filename |grep " Keyword "]; 3. Enter the edit search.
The operating environment of this tutorial: windows7 system, linux7.3 version, DELL G3 computer. This method is suitable for all brands of computers.
Three commands for viewing logs in Linux:
The first one: View real-time changing logs (more memory intensive)
The most commonly used:
tail -f filename
(default last 10 lines, equivalent to adding parameter -n 10)
Ctrl c
is to exit the tail command
Other situations:
tail -n 20 filename
(Display the last 20 lines of filename)
tail -n 5 filename
(Display the file starting from line 5)
Second type: Search logs near keywords
The most commonly used:
cat -n filename |grep "keyword"
Other situations:
Third method: Enter the edit search:vi(vim)
# Related learning recommendations:
The above is the detailed content of What are the three commands to view logs in Linux?. For more information, please follow other related articles on the PHP Chinese website!