Linux Admin – more and less Command

Linux Admin - more and less CommandThis topic is about

This topic is about Linux Admin – more and less Command.

Both more and less commands allow pagination of large text files. When perusing large files, it is not always possible to use grep unless we know an exact string to search. So we would want to use either more or less.

Typically, less is the preferred choice, as it allows both forward and backward perusal of paginated text. However, less may not be available on default installations of older Linux distributions and even some modern Unix operating systems.

[root@centosLocal Documents]# grep "192.168" ./pfirewall.log | more 
2016-01-07 15:36:34 DROP UDP 192.168.0.1 255.255.255.255 68 67 328 - - - - -  -  RECEIVE 
2016-01-07 15:36:38 DROP UDP 192.168.0.21 255.255.255.255 68 67 328 - - - - -- - RECEIVE 
2016-01-07 15:36:45 DROP ICMP 192.168.0.24 224.0.0.1 - - -- - - - - -- - - - -   RECEIVE 
2016-01-07 15:37:07 DROP UDP 192.168.0.21 255.255.255.255 68 67 328 - - - -  - - RECEIVE 
2016-01-07 15:37:52 DROP UDP 192.168.0.78 255.255.255.255 68 67 328 - - - -  - - RECEIVE 
2016-01-07 15:37:52 ALLOW UDP 192.168.0.78 255.255.255.255 67 68 0 - - - - -- -  RECEIVE 
2016-01-07 15:37:53 ALLOW UDP 192.168.0.78 224.0.0.252 51571 5355 0 - - - -  - - RECEIVE

Usually less is preferred, because less really offers more than more.

2016-01-07 15:43:53 DROP UDP 192.168.1.73 255.255.255.255 68 67 328 - - - - - -  RECEIVE 
2016-01-07 15:44:17 ALLOW UDP 192.168.1.18 224.0.0.252 54526 5355 0 - - - - - -  RECEIVE 
2016-01-07 15:44:23 DROP UDP 192.168.1.57 255.255.255.255 68 67 328 - - - - - -  RECEIVE 
2016-01-07 15:44:33 DROP UDP 192.168.1.88 255.255.255.255 68 67 328 - - - - - -  RECEIVE 
2016-01-07 15:44:33 ALLOW UDP 192.168.1.4 255.255.255.255 67 68 0 - - - - - - -  RECEIVE 
2016-01-07 15:44:41 DROP UDP 192.168.1.126 255.255.255.255 68 67 328 - - - - - - RECEIVE 
2016-01-07 15:44:43 DROP UDP 192.168.1.112 255.255.255.255 68 67 328 - - - - - - RECEIVE 
2016-01-07 15:44:56 DROP ICMP 192.168.1.240 224.0.0.1 - - 36 - - - - 9 0 -       RECEIVE 
2016-01-07 15:45:57 ALLOW UDP 192.168.1.47 192.168.1.255 138 138 0 - - - - - -      SEND 
2016-01-07 15:49:13 DROP ICMP 192.168.1.241 224.0.0.1 - - 36 - - - - 9 0 -       RECEIVE 
2016-01-07 15:49:38 DROP UDP 192.168.1.68 255.255.255.255 68 67 328 - - - - - -  RECEIVE 
2016-01-07 15:49:38 ALLOW UDP 192.168.1.4 255.255.255.255 67 68 0 - - - - - -    RECEIVE 
2016-01-07 15:49:39 DROP UDP 192.168.1.93 255.255.255.255 68 67 328 - - - - -    RECEIVE 
:

As shown above, when invoked less opens into a new buffer separate from the shell prompt. When trying less, it sometimes may give an error as follows −

bash: less: command not found...

Either use more or install less from the source of the package manager. But less should be included on all modern Linux Distributions and even ported to Unix platforms. Some will even symlink more to less.

In this topic we learned Linux Admin – more and less Command. to know more : Click Here.

This Post Has One Comment

Leave a Reply