Insights Technical Hub How to Display File Contents using the Linux CLI

How to Display File Contents using the Linux CLI

Introduction:

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

Requirements:

Linux

Procedure:

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, moreless, or vi.

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

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

:q

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 catmore, 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 viless has more features than moreless 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

Let's make your job easier

Sign up to get insightful content