view - Linux Command - Unix Command

Use 'view' to open a text file in Vim's read-only mode

Most Linux distributions support a shell command called view. This command invokes the Vim text editor in read-only mode. It's functionally the same as executing:

Vim is a powerful text editor with a complex syntax that's often intimidating for people unfamiliar with it. The nano editor works just as well, but with an easier syntax.

Go-to-Market Planning
Getty Images / Thomas Barwick

Viewing Files in Linux

Although Vim competently displays files, as invoked by view, other common Linux shell commands also present some or all of a text file.

Use the head command to show the beginning of the file. Include a switch specifying a number to show a specific number of lines from the beginning of a file. For example, to show the first five lines of magnum_opus.txt, enter:

$head -

Conversely, use tail to show you the last 10 lines of a file. Run tail with the -f switch to print new lines every time a file gets written at the end of it—for example, with log files.

To view the entire contents of a file, use the less command. With this utility, use the arrow keys to go back and forth one line at a time or the space or B keys to go forward or backward by one screen. Press Q to quit the utility.