Updated April 18, 2023
Introduction to Linux More Command
In the Linux operating system, the more command is used to view or read the larger file size on the command prompt. The more command is also allowing the end-userto to scroll down and scroll up the output page. Primarily this utility was written by Eric Shienbrood and UC Berkeley.
more [options] file [...]
- more: Using the more keyword in the command | syntax. It will take the set of arguments as an option and file name and display complete screen output.
- option: We can provide the different flags as an option to the more command.
- file: Input file name.
How does Linux More Command Work?
In Linux, the more command is used to view the large file size. Generally, it is useful to see the log files. More command is displaying a complete screen view of the file. In Linux, we are one more command related to more command i.e. less command both the command having different features and use.
In more command, we can operate the display screen via keyboard keys also. Below are the shortcut keys to use in more command.
- Enter Key: It is used to scroll down the page line by line
- b key: It is used to going to the backward page of the output
- Space bar key: It is used to going to the next page of the output
- / key: It will be useful if we need to search any string
Examples to Implement Linux More Command
Following are the examples of linux command are given below:
1. More Command with “-d” option
The more command, we can guide or help the user to navigate in more command console or output window. We need to use the “-d” option in the more command.
Note: If the user will press the wrong key, then kindly press “h” key for the help.
more -d /var/log/messages
Explanation: We are reading the log files from the Linux filesystem (/var/log/messages). As per the above more command, we are reading the file with the “-d” option. On the output window, we are able to see the navigation instruction for the end-user (using “h” key).
2. More Command with “-f” option
In Linux more command, if we are using the “-f” option in the command then the option does not wrap the long text or lines and display as the same.
more -f /var/log/messages
Explanation: While using the “-f” option in more command is similar to normal more command only but it is not warping the long lines and display the output as it is.
3. More Command with “-p” option
In more command, it will clear the screen and display the output in the fresh window. We need to use the “-p” option in the more command.
more -p /var/log/messages
Explanation: We are able to list down the number of files in “/var/log/” directory and getting the number of log files in it (refer the screenshot 1 (a)). But we need an output to start with the fresh screen then we can use the “-p” option with move command (refer the screenshot 1 (b)).
4. More Command with “-c” option
In more command, the output pages will display in the same area by overlapping the previous display output page. We need to use the “-c” option in the more command.
more -c /var/log/messages
Explanation: As per the above command, we are analysing the message log file “/var/log/messages”. The output pages will display in the same scope of the area by overlapping the previous display output page. To display a similar end result, we need to use the “-c” option with more command.
5. More command with “-s” option
In the Linux More command, there is the facility to remove or delete the unwanted space present in the file. We need to use the “-c” option in the more command.
more -s /var/log/messages-20200504
Explanation: As per the above command, we are using a specific date log file (/var/log/messages-20200504) to read the data. In the same file, there are many spaces available in the file (refer the screenshot 2 (a)). Now we need an output to omit the unwanted spaces form the input file. We are using the “-s” option in the more command to remove the unwanted spaces form the input file (refer the screenshot 2 (b)).
6. More command with ajump command
In more command, we can directly jump to the number of the line that we need to. There is no need to check the number of records line by line. We need to specify the line number in the more command.
more +2000 /var/log/messages-20200428
Explanation: As per the above more command, we are using the specific log file (/var/log/messages-20200428). The total number of records in the same file is 3242 (refer the screenshot 3 (a)). If we need to go to record number 2000 it will be more difficult to go record by record. In more command, we are having the facility to directly move to record number 2000 (refer the screenshot 3 (b)).
We have seen the uncut concept of “Linux More Command” with the proper example, explanation, and command with different outputs. The more command is used to read the files that are in large in size. Number of times the normal text editor will not able to read the large file size then more command is useful.
We hope that this EDUCBA information on “Linux More Command” was beneficial to you. You can view EDUCBA’s recommended articles for more information.