Command Line Basics: View Text Files with more

October 4, 2009 by
Filed under: command line, HowTo, linux 

One of the things you may find you want to do often from your command line is to view the contents of a text file. This could be to view the contents of some startup script or just one of your own basic configuration files like .bashrc or .bash_aliases. The command is simple to use. Just type more followed by the file name. Here's an example (assuming you have X installed).

more /usr/lib/X11/config/

You should now see the first screenfull of text in the file displayed on your terminal. To see more of the file, just hit the spacebar, and more will show you the next screenfull of text. You can also move back up the file by pressing the [B] key. (This trick only works when viewing files, it doesn't work on piplined input.) When you've seen enough, you can get back to your command line prompt by pressing the [Q] key.

Pipelining Command Output to more

Another way to use more is when you have a large amount of text output from a command that exceeds the size of your terminal window. Say you want to view the directory listing of a large directory like /etc. This directory can contain a lot of files and require you to scroll up to see the beginning of a listing. No big deal if you're in a graphical log-in session. But what if you're on a terminal log-in session? There is no scroll bar. more to the rescue!

ls -l /etc | more

As you can see, more can be a handy tool to have in your ever expanding command line arsenal.

Affiliate Link

But wait, there's less!

You read that correctly. There's an improved text viewing utility that expands upon the functionality provided by more; the ironically named less. I'll cover that one in another post.


3 Responses to “Command Line Basics: View Text Files with more”

  1. Max Malm says:

    There is a few good reasons why to use less instead of more. For instance; less does not cache the file like more do.

    • Linerd says:

      Max - Thanks for the comment. I didn't know that about the cacheing. I'm only familiar with the differences in how more and less behave for the user.

  2. Story added...

    This story has been submitted to! If you think this story should be read by the free software community, come vote it up and discuss it here:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>