linux cat more head tail 查看文本
【摘要】 ECS信息规格:2vCPUs | 4GiB | kc1.large.2镜像:openEuler 20.03 64bit with ARM | 公共镜像 linux cat more head tail 查看文本 cat 查看文本(带行号)# cat ssh_config -n 1 # $OpenBSD: ssh_config,v 1.33 2017/05/07 23:12:57 ...
ECS信息
- 规格:2vCPUs | 4GiB | kc1.large.2
- 镜像:openEuler 20.03 64bit with ARM | 公共镜像
linux cat more head tail 查看文本
cat 查看文本(带行号)
# cat ssh_config -n
1 # $OpenBSD: ssh_config,v 1.33 2017/05/07 23:12:57 djm Exp $
2
3 # This is the ssh client system-wide configuration file. See
4 # ssh_config(5) for more information. This file provides defaults for
5 # users, and the values can be changed in per-user configuration files
6 # or on the command line.
7
8 # Configuration data is parsed as follows:
9 # 1. command line options
10 # 2. user-specific file
11 # 3. system-wide file
12 # Any configuration value is only changed the first time it is set.
13 # Thus, host-specific definitions should be at the beginning of the
14 # configuration file, and defaults at the end.
15
16 # Site-wide defaults for some commonly used options. For a comprehensive
17 # list of available options, their meanings and defaults, please see the
18 # ssh_config(5) man page.
19
20 # Host *
21 # ForwardAgent no
22 # ForwardX11 no
23 # PasswordAuthentication yes
24 # HostbasedAuthentication no
25 # GSSAPIAuthentication no
26 # GSSAPIDelegateCredentials no
27 # GSSAPIKeyExchange no
28 # GSSAPITrustDNS no
29 # BatchMode no
30 # CheckHostIP yes
31 # AddressFamily any
32 # ConnectTimeout 0
33 # StrictHostKeyChecking ask
34 # IdentityFile ~/.ssh/id_rsa
35 # IdentityFile ~/.ssh/id_dsa
36 # IdentityFile ~/.ssh/id_ecdsa
37 # IdentityFile ~/.ssh/id_ed25519
38 # Port 22
39 # Protocol 2
40 # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
41 # MACs hmac-md5,hmac-sha1,umac-64@openssh.com
42 # EscapeChar ~
43 # Tunnel no
44 # TunnelDevice any:any
45 # PermitLocalCommand no
46 # VisualHostKey no
47 # ProxyCommand ssh -q -W %h:%p gateway.example.com
48 # RekeyLimit 1G 1h
49 #
50 # To modify the system-wide ssh configuration, create a *.conf file under
51 # /etc/ssh/ssh_config.d/ which will be automatically included below
52 Include /etc/ssh/ssh_config.d/*.conf
more 每屏显示指定行数的文本
more 可以滚动查看大文本
-5 的意思是 每屏显示5行
向下浏览是 z 或者 space
向上浏览是 b
# more -5 ssh_config
# $OpenBSD: ssh_config,v 1.33 2017/05/07 23:12:57 djm Exp $
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
--More--(15%)
head 查看文本的前10行
# head -n 10 sshd_config
# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
tail -f 循环读取ssh日志
# pwd
/var/log
# tail -f secure
Oct 2 22:52:37 ecs-4eee sshd[21279]: pam_unix(sshd:session): session closed for user root
Oct 2 22:52:37 ecs-4eee sshd[21344]: pam_unix(sshd:session): session closed for user root
Oct 2 22:55:38 ecs-4eee sshd[21438]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 22:55:38 ecs-4eee sshd[21503]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 22:56:33 ecs-4eee sshd[21438]: pam_unix(sshd:session): session closed for user root
Oct 2 22:56:33 ecs-4eee sshd[21503]: pam_unix(sshd:session): session closed for user root
Oct 2 23:09:18 ecs-4eee sshd[21605]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:09:19 ecs-4eee sshd[21670]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:09:27 ecs-4eee sshd[21605]: pam_unix(sshd:session): session closed for user root
Oct 2 23:09:27 ecs-4eee sshd[21670]: pam_unix(sshd:session): session closed for user root
此时再新建一个ssh会话,查看日志输出变化
# tail -f secure
Oct 2 22:52:37 ecs-4eee sshd[21279]: pam_unix(sshd:session): session closed for user root
Oct 2 22:52:37 ecs-4eee sshd[21344]: pam_unix(sshd:session): session closed for user root
Oct 2 22:55:38 ecs-4eee sshd[21438]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 22:55:38 ecs-4eee sshd[21503]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 22:56:33 ecs-4eee sshd[21438]: pam_unix(sshd:session): session closed for user root
Oct 2 22:56:33 ecs-4eee sshd[21503]: pam_unix(sshd:session): session closed for user root
Oct 2 23:09:18 ecs-4eee sshd[21605]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:09:19 ecs-4eee sshd[21670]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:09:27 ecs-4eee sshd[21605]: pam_unix(sshd:session): session closed for user root
Oct 2 23:09:27 ecs-4eee sshd[21670]: pam_unix(sshd:session): session closed for user root
Oct 2 23:10:34 ecs-4eee sshd[21740]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:10:34 ecs-4eee sshd[21805]: pam_unix(sshd:session): session opened for user root by (uid=0)
关闭新建的ssh会话,查看日志输出变化
# tail -f secure
Oct 2 22:52:37 ecs-4eee sshd[21279]: pam_unix(sshd:session): session closed for user root
Oct 2 22:52:37 ecs-4eee sshd[21344]: pam_unix(sshd:session): session closed for user root
Oct 2 22:55:38 ecs-4eee sshd[21438]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 22:55:38 ecs-4eee sshd[21503]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 22:56:33 ecs-4eee sshd[21438]: pam_unix(sshd:session): session closed for user root
Oct 2 22:56:33 ecs-4eee sshd[21503]: pam_unix(sshd:session): session closed for user root
Oct 2 23:09:18 ecs-4eee sshd[21605]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:09:19 ecs-4eee sshd[21670]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:09:27 ecs-4eee sshd[21605]: pam_unix(sshd:session): session closed for user root
Oct 2 23:09:27 ecs-4eee sshd[21670]: pam_unix(sshd:session): session closed for user root
Oct 2 23:10:34 ecs-4eee sshd[21740]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:10:34 ecs-4eee sshd[21805]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 2 23:10:53 ecs-4eee sshd[21740]: pam_unix(sshd:session): session closed for user root
Oct 2 23:10:53 ecs-4eee sshd[21805]: pam_unix(sshd:session): session closed for user root
帮助文档(部分)
# cat --help
Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s) to standard output.
With no FILE, or when FILE is -, read standard input.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank suppress repeated empty output lines
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit
Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/cat>
or available locally via: info '(coreutils) cat invocation'
# more --help
Usage:
more [options] <file>...
A file perusal filter for CRT viewing.
Options:
-d display help instead of ringing bell
-f count logical rather than screen lines
-l suppress pause after form feed
-c do not scroll, display text and clean line ends
-p do not scroll, clean screen and display text
-s squeeze multiple blank lines into one
-u suppress underlining
-<number> the number of lines per screenful
+<number> display file beginning from line number
+/<string> display file beginning from search string match
--help display this help
-V, --version display version
For more details see more(1).
# head --help
Usage: head [OPTION]... [FILE]...
Print the first 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-c, --bytes=[-]NUM print the first NUM bytes of each file;
with the leading '-', print all but the last
NUM bytes of each file
-n, --lines=[-]NUM print the first NUM lines instead of the first 10;
with the leading '-', print all but the last
NUM lines of each file
-q, --quiet, --silent never print headers giving file names
-v, --verbose always print headers giving file names
-z, --zero-terminated line delimiter is NUL, not newline
--help display this help and exit
--version output version information and exit
NUM may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.
Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/head>
or available locally via: info '(coreutils) head invocation'
# tail --help
Usage: tail [OPTION]... [FILE]...
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-c, --bytes=[+]NUM output the last NUM bytes; or use -c +NUM to
output starting with byte NUM of each file
-f, --follow[={name|descriptor}]
output appended data as the file grows;
an absent option argument means 'descriptor'
-F same as --follow=name --retry
-n, --lines=[+]NUM output the last NUM lines, instead of the last 10;
or use -n +NUM to output starting with line NUM
......
学习资料
欢迎各位同学一起来交流学习心得^_^
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)