加入收藏 | 设为首页 | 会员中心 | 我要投稿 网站开发网_马鞍山站长网 (https://www.0555zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

Common Linux log files name and usage--reference

发布时间:2021-01-24 09:04:08 所属栏目:站长百科 来源:网络整理
导读:副标题#e# div id="post-body-7256318887016413630" class="post-single-body post-body" div dir="ltr"If you spend lot of time in Linux environment,it is essential that you know where the log files are located,and what is contained in each and

In the following example,you can view the content of var/log/cron from line number 101 to 110.M – Starting line numberN – Ending line number<div class="block-panel">
Syntax: sed -n M,Np FILENAME$ sed -n 101,110p /var/log/cron

Example 2: Display first N lines of a file using head commandThis example displays only first 15 lines of /var/log/maillog file. Change 15 to 10 to display the first 10 lines of a log file.?<div class="block-panel">
Syntax:?head -n N FILENAME$ head -n 15 /var/log/maillog

Example 3: Ignore last N lines of a file using head commandThis example shows how to ignore the last N lines,and show only the remaining lines from the top of file. The following example will display all the lines of the /var/log/secure except the last 250 lines.<div class="block-panel">
Syntax:?head -n -N FILENAME$ head -n -250 /var/log/secure

Example 4: Display last N lines of the file using tail commandThis example displays only last 50 lines of /var/log/messages file. Change 50 to 100 to display the last 100 lines of the log file.<div class="block-panel">
Syntax:?tail -n N FILENAME$ tail -n 50 /var/log/messages

Example 5: Ignore first N-1 lines of the file using tail commandThis example shows how to ignore the first N-1 lines and show only the remaining of the lines. The following example ignores the 1st four lines of the /etc/xinetd.conf,which contains only the comments.<div class="block-panel">
Syntax:?tail -n +N FILENAME$ tail -n +5 /etc/xinetd.conf?defaults{instances = 60log_type = SYSLOG authprivlog_on_success = HOST PIDlog_on_failure = HOSTcps = 25 30}includedir /etc/xinetd.d

(编辑:网站开发网_马鞍山站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!