Looking Around

Now that you know how to move from working
directory to working directory, we're going to take
a tour of your Linux system and, along the way,
learn some things about what makes it tick. But
before we begin, I have to teach you some tools
that will come in handy during our adventure. These
are:

The last time the file was modified. If the
last modification occurred more than six months
in the past, the date and year are displayed.
Otherwise, the time of day is shown.

Size

The size of the file in bytes.

Group

The name of the group that has file
permissions in addition to the file's owner.

Owner

The name of the user who owns the file.

File Permissions

A representation of the file's access
permissions. The first character is the type of
file. A "-" indicates a regular (ordinary) file.
A "d" indicates a directory. The second set of
three characters represent the read, write, and
execution rights of the file's owner. The next
three represent the rights of the file's group,
and the final three represent the rights granted
to everybody else. I'll discuss this in more detail
in a later lesson.

less

less is a program that
lets you view text files. This is very handy since
many of the files used to control and configure
Linux are human readable.

What is "text"?

There are many ways to represent information on
a computer. All methods involve defining a
relationship between the information and some
numbers that will be used to represent it.
Computers, after all, only understand numbers and
all data is converted to numeric
representation.

Some of these representation systems are very
complex (such as compressed multimedia files), while
others are rather simple. One of the earliest and
simplest is called ASCII text. ASCII (pronounced
"As-Key") is short for American Standard Code for
Information Interchange. This is a simple encoding
scheme that was first used on Teletype machines to
map keyboard characters to numbers.

Text is a simple one-to-one mapping of
characters to numbers. It is very compact. Fifty
characters of text translates to fifty bytes of
data. Throughout a Linux system, many files are
stored in text format and there are many Linux
tools that work with text files. Even the legacy
operating systems recognize the importance of this
format. The well-known NOTEPAD.EXE program is an
editor for plain ASCII text files.

The less program is
invoked by simply typing:

less text_file

This will display the file.

Controlling less

Once started, less will
display the text file one page at a time. You may
use the Page Up and Page Down keys to move through
the text file. To exit less,
type "q". Here are some commands that less will accept:

Keyboard commands for the less program

Command

Action

Page Up or b

Scroll back one page

Page Down or space

Scroll forward one page

G

Go to the end of the text file

1G

Go to the beginning of the text file

/characters

Search forward in the text file for an
occurrence of the specified
characters

n

Repeat the previous search

h

Display a complete list less commands and options

q

Quit

file

As you wander around your Linux system, it is
helpful to determine what kind of data a file contains before
you try to view it. This is where the file command comes in. file will examine a file and tell you
what kind of file it is.

To use the file program,
just type:

file name_of_file

The file program can
recognize most types of files, such as:

Various kinds of files

File Type

Description

Viewable as
text?

ASCII text

The name says it all

yes

Bourne-Again shell script text

A bash script

yes

ELF 32-bit LSB core file

A core dump file (a program will create
this when it crashes)

no

ELF 32-bit LSB executable

An executable binary program

no

ELF 32-bit LSB shared object

A shared library

no

GNU tar archive

A tape archive file. A common way of
storing groups of files.

no, use tar tvf to
view listing.

gzip compressed data

An archive compressed with gzip

no

HTML document text

A web page

yes

JPEG image data

A compressed JPEG image

no

PostScript document text

A PostScript file

yes

RPM

A Red Hat Package Manager archive

no, use rpm -q to
examine contents.

Zip archive data

An archive compressed with zip

no

While it may seem that most files cannot be
viewed as text, you will be surprised how many can.
This is especially true of the important
configuration files. You will also notice during
our adventure that many features of the operating
system are controlled by shell scripts. In Linux,
there are no secrets!