1.实时监控查看一个文件内容的变化(日志)取消查看ctrl+c
[root@oldboy62-0 ~]# tail -f /var/log/secure
Jun 12 09:59:07 oldboy62-0 sshd[7194]: Server listening on :: port 22.
Jun 12 11:28:50 oldboy62-0 sshd[13659]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.0.0.1 user=root
Jun 12 11:28:50 oldboy62-0 sshd[13659]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root"
2.tail 尾巴 ----查看文件后几行内容
[root@oldboy62-0 ~]# tail /etc/profile
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
3.指定查看文件指定后几行内容(默认查看后十行)
[root@oldboy62-0 ~]# tail -5 /etc/profile
指定查看后5行内容
done
unset i
unset -f pathmunge
export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
4.head 头部 ----查看文件前几行内容
[root@oldboy62-0 ~]# head /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
5.查看文件指定的前几行内容(默认前10行)
[root@oldboy62-0 ~]# head -5 /etc/profile
指定查看前5行内容
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
网友评论