In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the tail command". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how to use the tail command.
The tail command writes the file to standard output from the specified point. Using the-f option of the tail command, you can easily view the changing log file. Tail-f will display the last content on the screen and not only refresh it, so that you can see the latest file contents.
How to use the tail command
Use the tail command to view the yum.log log file and display the last 10 lines. By default, tail displays the last 10 lines of your asking price:
[root@localhost] # tail / var/log/yum.logMay 26 15:22:08 Installed: pytalloc-2.1.16-1.el7.x86_64May 26 15:22:08 Updated: libwbclient-4.10.4-11.el7_8.x86_64May 26 15:22:08 Installed: samba-libs-4.10.4-11.el7_8.x86_64May 26 15:22:08 Updated: samba-common-libs-4.10.4-11.el7_8.x86_64May 26 15:22:08 Updated: samba-client-libs-4.10.4-11.el7_8.x86_64May 26 15:22:08 Updated: libsmbclient-4.10.4-11.el7_8.x86_64May 26 15:22:08 Installed: libarchive-3.1.2-14.el7_7.x86_64May 26 15:22:09 Installed: samba-client-4.10.4-11.el7_8.x86_64May 26 17:22:44 Installed: lm_sensors-libs- 3.4.0-8.20160601gitf9185e5.el7.x86_64May 26 17:22:44 Installed: sysstat-10.1.5-19.el7.x86_64 how to display the specified number of rows
Use the-n command to display the specified number of lines, or you can omit the letter n and use only-and numbers (there is no space between the numbers and -).
For example: view the user you created, and view the last two lines of the / etc/passwd file:
[root@localhost] # tail-2 / etc/passwdbob:x:1000:1001::/home/bob:/bin/bashuser01:x:1001:1002::/home/user01:/bin/bash
How to monitor file changes in real time
If you need to monitor changes to the contents of the file, use the-f option. This option is useful for monitoring log files. For example, to display the last 10 lines of the / var/log/nginx/error.log file and monitor for updates to the file:
[root@localhost] # tail-f / var/log/messages
To exit, press Ctrl+C to exit.
View multiple files
If multiple files are provided as input to the tail command, it displays the last ten lines of each file. The following example uses the tail command to display the last two lines of the / etc/passwd and / etc/shadow files:
[root@localhost ~] # tail-n 2 / etc/passwd / etc/shadow== > / etc/passwd / etc/shadow $6 $qPoy4v75 $jzkBdrR.1L5G1sIs34GXRWa43fej.CLgaWKO9WRGkYcrUSVmVBGfcmOjn1Kc8FgcwVv2abac7t/m3crt2Vu8G.:18335:0:99999:7:::
The tail command is used with other commands
For example, to monitor the apache access log file in real time and display the line containing the IP address 192.168.43.157, you can use:
[root@localhost] # tail-f / var/log/httpd/access_log | grep 192.168.43.157192.168.43.157-- [28/May/2020:14:56:31 + 0800] "GET / HTTP/1.1" 403 4897 "-" curl/7.29.0 "192.168.43.157-- [28/May/2020:14:56:41 + 0800]" GET / HTTP/1.1 "403 4897"-"curl" / 7.29.0 "192.168.43.157-- [28/May/2020:14:56:41 + 0800]" GET / HTTP/1.1 "403 4897"-"curl/7.29.0" 192.168.43.157-[28/May/2020:14:56:41 + 0800] "GET / HTTP/1.1" 403 4897 "-" curl/7.29.0 "so far I believe you have a better understanding of "how to use the tail command", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.