《Linux 系列》- 常用命令- 文件浏览命令]

Linux文件查看命令详解
本文详细介绍了Linux系统中常用的文件查看命令,包括cat、more、less及tail等命令的使用方法与应用场景。通过这些命令,用户可以高效地浏览、监控和分析文件内容。

cat命令 :适合查看少量信息的文件

操作: cat file1
快捷查看当前文件的内容

[root@localhost ~]# cat initial-setup-ks.cfg 
#version=RHEL7
# X Window System configuration information
xconfig  --startxonboot

# License agreement
eula --agreed
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Run the Setup Agent on first boot
firstboot --enable

more命令

分页显示文件内容
操作: more file1
Enter :向下n行,默认1行
空格键:向下滚动一屏 或 Ctrl + F
B:返回上一屏 或 Ctrl + B
q:退出more

[root@localhost ~]# more initial-setup-ks.cfg 
#version=RHEL7
# X Window System configuration information
xconfig  --startxonboot

# License agreement
eula --agreed
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Run the Setup Agent on first boot
firstboot --enable
# System services
services --enabled="chronyd"
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

ignoredisk --only-use=sda
# Network information
network  --bootproto=dhcp --device=eno16777736 --ipv6=auto --activate
network  --bootproto=dhcp --hostname=localhost.localdomain
--More--(50%)


less -mN命令 :使用于大量数据的查看

分页显示文件内容,并标注行号
操作: less -mN file1
快捷键同 more命令

[root@localhost ~]# less -mN initial-setup-ks.cfg 

      1 #version=RHEL7
      2 # X Window System configuration information
      3 xconfig  --startxonboot
      4 
      5 # License agreement
      6 eula --agreed
      7 # System authorization information
      8 auth --enableshadow --passalgo=sha512
      9 # Use CDROM installation media
     10 cdrom
     11 # Run the Setup Agent on first boot
     12 firstboot --enable


tail :适合看日志

可以快速查看文件后x行的内容
操作: tail -10 file1

[root@localhost ~]# tail -10 initial-setup-ks.cfg 
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@print-client
@x11
chrony

%end

 

转载于:https://my.oschina.net/kimisme/blog/1606867

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值