Linux less command - scroll back to show text files

Linux less command: scroll back to show text files

Linux less command Function Description

The less command is very similar to the more command in that it can be used to view the contents of a text file, except that the less command allows the user to scroll back.

Linux less command syntax

less [Option] [File]

The meaning of each option in the command is shown in the table.

  • -b Set the size of the buffer
  • -e Automatically leave when the document display is finished
  • -f Force open special files such as peripheral designators, directories and binary files
  • -g Only the last searched keyword is flagged
  • -i Ignore case in search
  • -m Show percentages similar to the more command
  • -N Display the line number of each line
  • -o Save the less output in the specified file
  • -Q No warning tone
  • -s Show consecutive blank lines
  • -S The line is too long to discard the excess
  • -x Display the "tab" key as the specified number of spaces
  • /String: Search "String" function down
  • ?String: Upward search function for "string"
  • n: Repeat the previous search (with / or ?) related)
  • N: Repeat the previous search in reverse (with / or ?) related)
  • b: Turn up a page
  • d: Turn back half a page
  • h: Show help screen
  • Q Exit the less command
  • u Scroll forward half a page
  • y Scroll forward one line
  • Spacebar Scroll down a page
  • Enter key Scroll a line
  • [pagedown] Scroll down one page
  • [pageup] Flip up one page

Linux less command Demo

Rollback to show the contents of the /etc/services file

[root@rhel ~]# less /etc/services
# /etc/services:
# Id: services, v 1.482009/11/11 14:32:31 ovasik Exp
#
# Network services, Internet style
# IANA services version: last updated 2009-11-10
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
#Updated from RFC 1700, ''Assigned Numbers''(October 1994). Not all ports
# are included, only the more common ones.
#
# The latest IANA port assignments can be gotten from
#   http://www.iana.org/assignments/port-numbers
# The Well Known Ports are those from 0 through 1023.
# The Registered Ports are those from 1024 through 49151
# The Dynamic and/or Private Ports are those from 49152 through 65535
#
# Each line describes one service, and is of the form:
#
#service-name port/protocol [aliases...] [#comment]
tcpmux      1/tcp                        #TCP port service multiplexer
tcpmux      1/udp                       #TCP port service multiplexer
rje          5/tcp                        #Remote Job Entry
rje          5/udp                       #Remote Job Entry
echo        7/tcp
echo        7/udp
discard      9/tcp       sink null
discard      9/udp       sink null
systat       11/tcp       users
systat       11/udp      users
daytime     13/tcp
daytime     13/udp
qotd       17/tcp       quote
qotd       17/udp       quote
msp       18/tcp                       #message send protocol
msp       18/udp                       #message send protocol
/etc/services

ps view process information and paginate it with less

ps -ef |less

View command history and display by less paging

[root@localhost test]# history | less
22  scp -r tomcat6.0.32 root@192.168.120.203:/opt/soft
23  cd ..
24  scp -r web root@192.168.120.203:/opt/
25  cd soft
26  ls
…………
Like(1)

Related

Linux Login Logout Command
Linux login commandLinux logout commandLinux nologin commandLinux exit commandLinux sulogin commandLinux rlogin commandLinux poweroff commandLinux ctrlaltdel CommandLinux shutdown commandLinux halt commandLinux reboot commandLinux init commandLinux runlevel commandLinux telinit command
Linux File Management Command
Linux cat commandLinux tac commandLinux nl commandLinux more commandLinux less commandLinux head commandLinux tail commandLinux rev commandLinux fold commandLinux fmt commandLinux expand commandLinux pr commandLinux sort commandLinux uniq commandLinux cut commandLinux comm commandLinux diff commandLinux join commandLinux diff3 commandLinux cmp commandLinux colrm commandLinux paste commandLinux mkdir commandLinux tr commandLinux split commandLinux csplit commandLinux tee commandLinux unexpand commandLinux patch commandLinux awk commandLinux sed commandLinux od commandLinux pwd commandLinux cd commandLinux ls commandLinux dir commandLinux dirs commandLinux touch commandLinux rmdir commandLinux cp commandLinux mv commandLinux rm commandLinux install commandLinux tmpwatch commandLinux file commandLinux du commandLinux wc commandLinux tree commandLinux cksum commandLinux md5sum commandLinux sum commandLinux dirname commandLinux mkfifo Command
Cron Expressions
Cron Expression to Run Every Day at 12 PMUnderstanding Vue Cron ExpressionsUnderstanding JS Cron ExpressionsA Comprehensive Guide to Cron Expressions for Scheduled TasksUnderstanding Linux Cron ExpressionsUnderstanding Quartz Cron ExpressionsCron ExpressionCron Time ExpressionCron Expression ParsingCron Expression: Executing a Task Every SecondCron Expression for Every Minute ExecutionCron Expression to Execute Every 10 MinutesCron Expression: Executing Every HourCron Expression to Execute Once a YearCron Expression: How to Schedule a Task to Run Daily at Midnight?