一、作用

查看文件的开头部分的内容,默认为 10行

二、选项

  • -(n/数字) 指定显示开通多少行
  • -c<数目> 显示的字节数

三、实例

  1. [root@xxxx:~ ]# head -6 /etc/passwd
  2. root:x:0:0:root:/root:/bin/bash
  3. bin:x:1:1:bin:/bin:/sbin/nologin
  4. daemon:x:2:2:daemon:/sbin:/sbin/nologin
  5. sync:x:5:0:sync:/sbin:/bin/sync
  6. mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
  7. ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
[root@localhost dir]# head -c 1000  /var/log/messages 
Jun  5 07:00:57 localhost journal: Runtime journal is using 8.0M (max allowed 90.9M, trying to leave 136.4M free of 901.6M available → current limit 90.9M).
Jun  5 07:00:57 localhost kernel: Initializing cgroup subsys cpuset
Jun  5 07:00:57 localhost kernel: Initializing cgroup subsys cpu
Jun  5 07:00:57 localhost kernel: Initializing cgroup subsys cpuacct
Jun  5 07:00:57 localhost kernel: Linux version 3.10.0-1062.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Wed Aug 7 18:08:02 UTC 2019
Jun  5 07:00:57 localhost kernel: Command line: BOOT_IMAGE=/vmlinuz-3.10.0-1062.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=zh_CN.UTF-8
Jun  5 07:00:57 localhost kernel: Disabled fast string operations
Jun  5 07:00:57 localhost kernel: e820: BIOS-provided physical RAM map: