How to Display File Contents using the Linux CLI

How to Display File Contents using the Linux CLI


Operating Linux from the command line requires files to be inspected non-graphically since there may be no desktop to open them from.




Gain access to the CLI (command line interface) on Linux. Change directories to the file you want to inspect. For example:

cd /root/folderContainingFile

View the files contents with either the cat command, more, less, or vi.

cat file.txt
 more file.txt
 less file.txt
 vi file.txt

Each command has its own advantages. To quit vi, type


The cat tool displays the file as flat output and is non-interactive. This is the simplest of the commands to use.

vi is interactive and has a unique syntax for editing, viewing, or manipulating the files. vi is also different from cat, more, and less because it has file editing features.

less does not read the whole input file when started and can read through files forwards and backwards. more reads through a file only forwards. They both have commands, like vi. less has more features than more. less is faster than more and vi.

More Information:

Type man, then the name of the command to find out more information on each one, from Linux’s man (manual) pages.

For example:
 man cat
 man more
 man less
 man vi