Home>Article>Operation and Maintenance> How to view the last few lines of the log in Linux

How to view the last few lines of the log in Linux

WBOY
WBOY Original
2022-07-15 15:58:13 12402browse

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".

How to view the last few lines of the log in Linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to view the last few lines of the log in Linux

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 Number of bytes displayed

  • -n Display the last n lines of the file

  • --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

Linux common log files


How to view the last few lines of the log in Linux

Recommended learning:

Linux video tutorial

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Where is vimrc in linux Next article:Where is vimrc in linux