In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "the summary of common commands for Linux to view system logs". In the operation of actual cases, many people will encounter this dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Last
-a display the host name or ip address from where to log in to the system on the last line.
-d specifies the record file. Specifies the record file. Translate the IP address to the host name.
-f specifies the record file.
-n or-sets the number of display columns for the list.
-R does not display the host name or IP address logged in to the system.
-x displays information such as system shutdown, reboot, and change of execution level.
Here's a look at all the restart and shutdown records.
The code is as follows:
Last | grep reboot
Last | grep shutdown
History
List all the history:
The code is as follows:
[zzs@Linux] # history
List only the last 10 records:
The code is as follows:
[zzs@linux] # history 10 (Note, space between history and 10)
Use the command record number to execute the command, and execute the 99 command in the history list
The code is as follows:
[zzs@linux] #! 99 (! There is no space between 99)
Repeat the previous command
The code is as follows:
[zzs@linux] #!!
Execute the last command that starts with rpm (!? Represents a string, this String can be typed at will, Shell will search forward from the last history command, and the first matching command will be executed.)
The code is as follows:
[zzs@linux] #! rpm
List all history on a screen-by-screen basis:
The code is as follows:
[zzs@linux] # history | more
Immediately clear the records of all current history historical commands
The code is as follows:
[zzs@linux] # history-c
Cat, tail and watch
All the logs of the system are read by yourself under / var/log (you can check for specific purposes. Some commonly used logs are listed in the appendix).
The code is as follows:
Cat / var/log/syslog, etc.
Cat / var/log/*.log
Tail-f
If the log is being updated, how to view tail-f / var/log/messages in real time
You can also use watch-d-n 1 cat / var/log/messages
-d indicates different highlights, and-n indicates how many seconds to refresh.
This instruction does not return directly to the command line, but prints new additions to the log file in real time
This feature is very effective for viewing logs. If you want to terminate the output, press Ctrl+C.
In addition, there are more, less, dmesg | more, which will not be listed here, because there are too many commands, and the key depends on personal preferences and business needs. The ones commonly used by individuals are those mentioned above.
Linux log file description
/ var/log/message system information and error log after startup is one of the most commonly used logs in Red Hat Linux
/ var/log/secure security-related log information
/ var/log/maillog Mail-related log information
/ var/log/cron log information related to scheduled tasks
/ var/log/spooler log information related to UUCP and news devices
Log messages related to / var/log/boot.log daemon start and stop
/ var/log/wtmp this log file permanently records the events of each user logging in, logging out, and system startup and downtime
This is the end of the summary of common commands for Linux to view system logs. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.