Home >Operation and Maintenance >Linux Operation and Maintenance >How to view the last few lines of the log in Linux
In Linux, you can use the tail command to view the last few lines of the log. This command is used to view the contents of the file. When the parameter of the command is set to "-n", it means that the last specified number of lines of the specified file is displayed. The content, the syntax is "tail -n you need to view the last few lines of the log file".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
The tail command can be used to view the contents of the file. There is a commonly used parameter -f which is often used to view the changing log file.
tail -f filename will display the last content in the filename file on the screen and refresh it continuously. As long as filename is updated, you can see the latest file content.
Command format:
tail [参数] [文件]
Parameters:
-f Loop reading
-q No Display processing information
-v Display detailed processing information
-c
-n
--pid=PID Used with -f to indicate that the process ID and PID are dead End after dropping
-q, --quiet, --silent Never output the header of the given file name
-s, - -sleep-interval=S Used with -f, it means to sleep for S seconds between each iteration
tail -n 50 wx.log
Example: View /var/log/boot.log, only the last line is displayed . Then execute
tail -n 1 /var/log/boot.log
tail -n 1000: display the last 1000 lines
tail -n 1000: start displaying from line 1000, display 1000 lines In the future
head -n 1000: Display the first 1000 lines
##Expand knowledge
The above is the detailed content of How to view the last few lines of the log in Linux. For more information, please follow other related articles on the PHP Chinese website!