8.1 Viewing Text Files

A _text file_ is simply a normal file that happens to contain

human-readable text. There’s nothing special about it otherwise. The

other kind of file, a binary file, is meant to be interpreted by the

computer.

You can view either kind of file with the less file pager if you

have it installed (install it if you haven’t, it’s quite useful).

Type less

/etc/profile to view a sample text file. Notice that you can read

/the

characters even if their meaning is obscure. Type less /bin/ls to

view a binary file. As you can see, the ls program is not meant to

be read by humans.

Sometimes, you’ll find files that end with .gz. These files may be

viewed with zless; you can run it like so:

zless /usr/doc/ae/changelog.Debian.gz

Tip: zless is great for viewing documentation, which is often

shipped in .gz form.

The difference between the two kinds of files is purely a matter of

what they contain, unlike in some other systems (such as DOS and

MacOS), which actually treat the files differently.

Text files can contain shell scripts, documentation, copyright

notices, or any other human-readable text.

Incidentally, this illustrates the difference between _source code_

and _binary executables_. /bin/ls is a binary executable you can

download from Debian, but you can also download a text file that

tells the computer how to create /bin/ls. This text file is the

source code. Comparing /bin/ls to /etc/profile illustrates how

important source code is if someone wants to understand and modify a

piece of software. Free software provides you or your consultants

with this all-important source code.

Debian GNU/Linux : Guide to Installation and Usage · 第 115 / 193 题