RHA030 - Workbook

advertisement
Welcome to RHA030
Pace Center for Business and Technology
1
Introduction
RHA030 – Computing Essentials
Pace Center for Business and Technology
2
Introduction
RHA030 – Computing Essentials
Audience
Users who are new to Linux and have no prior UNIX or command-line skills, who want to
develop and practice the basic skills to use and control their own Red hat Linux system.
Assumed Knowledge
User-level experience with any computer system, use of mouse, use of menus, use of
any graphical user interface.
Aims
Students will learn to be effective users of Linux systems, acquiring skills and
understanding of command line functions, file systems, users and groups, bash shell,
process management, text editors, network applications, searching and organizing data,
and graphical applications.
Objectives
Upon successful completion of this curse, the student will be a Red Hat Linux user
productive in using and customizing a Red Hat Linux system for common command line
processes and desktop productivity roles.
3
Classroom Environment
• Computers are equipped with Red Hat Enterprise Linux 6
• The setup:
• Instructor computer – Primary classroom server:
• cifs-file-server (Common Internet File System)
• directory-server
• ftp-server
• network-server
• nfs-file-server
• web-server
• Student computers – Red Hat Client Workstations:
• VMWare Player
• A VM for each course RHEL6-030, RHEL6-130, and
RHEL6-230/250
• For this class we will be using the RHEL6-030. The VM has
all the required software to facilitate your learning and
experience of the Red Hat Enterprise Linux OS.
4
Lets Demo The VM - Classroom
Environment
5
Classroom Environment
Virtual Machine
• VMs must be shut down via the normal “System Shutdown” after class
ends to avoid confusion for the next class.
• Do not click “X” on a VM once opened – it will put it in Suspend mode and
will take a very long time when re-opening
• Once you open the VM player via the “Student” account (password =
redhat), you will see three VM options:
RHEL6 030
RHEL6 130
RHEL 230/250
• Select the RHEL6 030
• 030 VM is a preconfigured VM with RHEL already installed; is ready to go
for an 030 class (it has base and student RPMs installed). A suggestion
is to have the students change the view to Full Screen so they don’t get
confused with the double menus on top of the screen (Host and VM)
6
Red Hat Academy Curriculum
Structure
Red Hat Academy curriculum is structured enough to be programmatically managed, but
flexible enough to present information in a manner that promotes effective learning by the
student. The following sections describe the design elements that will become familiar to
users of Red Hat Academy.
7
Red Hat Academy Curriculum
Structure
Red Hat Academy courses draw from our corporate training courses, but greatly
expands the material with many examples and exercises to provide a semester-long
course appropriate for the academic environment.
Courses:
Currently, the following courses are offered through Red Hat Academy, with more to be
offered in the future.
RHA030: Red Hat Enterprise Linux Computing
Essentials (10 workbooks)
RHA130: Red Hat Enterprise Linux Core System
Administration (10 workbooks)
RHA230: Red Hat Enterprise Linux Network
Applications (6 workbooks)
RHA250: Red Hat Linux Security Administration (4
workbooks)
Workbooks:
RHA courses consist of multiple workbooks, which are designed to be a week or two of
material, but vary in length depending on the nature of the material being covered. Each
Workbook consists of multiple Lessons, a Pretest, Lab Test, and Exam.
8
Certifications
Red Hat Certified System Administrator — RHCSA:
(Ready to administer Red Hat Enterprise Linux environments)
Certification program requirements:
•The Red Hat Certified System Administrator (RHCSA) exam consists of one section lasting up to 2.5
hours.
•The certification exam is performance-based, meaning that candidates must perform tasks on a live
system, rather than answering questions about how one might perform those tasks.
•The hands-on nature of this exam make real-world experience a critical facet of preparation.
•RHCSA certifications have a current window for 3 calendar years after they are earned.
Red Hat Certified Engineer — RHCE:
(Be a senior system administrator of Red Hat Enterprise Linux systems)
•RHCE candidates must have earned their RHCSA certification to be eligible to become an RHCE.
•An RHCE exam consists of 1 section lasting up to 2 hours.
•The certification exam is performance-based, meaning that candidates must perform tasks on a live
system, rather than answering questions about how one might perform those tasks.
•The hands-on nature of this exam makes real-world experience a critical facet of preparation.
•RHCEs, who are certified on Red Hat Enterprise Linux 6, will have a current status for 3 calendar
years after it is earned
For additional information about Red Hat Enterprise Linux certifications please go to:
http://www.redhat.com/training/certifications/
9
Questions
Feel free to ask questions
Your Instructor will have three responses:
1. “The answer is…”
2. “We’ll be discussing that in a future unit”
3. “I don’t know, but I will find out”
It’s impossible to know everything, so feel free to share pertinent information as
we go throughout the course since we can all learn from each other
10
.
Logistics
• Security office – at the middle of the hall directly in front of the elevators
• Restrooms (down the hall make a right and its on the left corner of the next hallway)
• Snacks, drinks, places to eat
• Cell phones turned off or set to silent mode
• Computer lab closed after class, but is available for daytime
use if a class is not scheduled; procedure = call 1st to check
11
Class Schedule
Each Saturday, the class will follow this schedule:
Start class
9:00am
Breaks(2x15min)
10:15am & 3:15pm
Lunch
12:30pm
Resume class
1:30pm
Adjourn
5:00pm
12
About Your Course Instructor
Augusto Delgado
• Background and experience
• Education
• Current positions
13
About You and Your Fellow Participants
• Your name
• Current position if presently employed
• Background
• Expectations
14
Practicing Outside of the RHA030 Class
Vulcan Linux Accounts introduction
This is how you will be able to practice Linux commands from home or any internet
connection
15
LET’S GET STARTED
Workbook 1: Quick Tour
Key Concepts
In Linux, user sessions are started by "logging in" to the machine.
To login, you must have already been provided a username and password.
If a Linux machine is running an X server, users may login using the graphical
interface.
Users may login on any of six virtual consoles.
The CTRL+ALT+F2 through CTRL+ALT+F6 key sequences switch between the
six virtual consoles.
The CTRL+ALT+F1 key sequence switches to the default X server.
If a Linux machine supports it, users can login in over the network using a remote
shell.
The who command lists which users are currently logged in, and how they logged
on.
16
Virtual Consoles
Red Hat Enterprise Linux provides six "virtual consoles" that are available
to users physically at the computer. The virtual consoles act like "dumb
terminals". The virtual consoles are accessed using the CTRL+ALT+F2
through CTRL+ALT+F6 key sequences, with one virtual console mapped
to each of the first 6 function keys. (If you are in a graphical environment,
you should know that CTRL+ALT+F1 will return you to it before trying to
switch to a virtual console.)
Virtual Consoles work only on the host not the VMs
17
The X Graphical Environment
When running on modern personal computers, Linux uses a low level program
known as the "X server" to provide the graphics environment. As a user of the
system, you don't interact with the X server directly, but it provides the canvas
for all of the graphical programs that you run.
When the X server starts, usually as part of the system's startup sequence, it
looks for the "first available" virtual console. If you are on a virtual console,
and think that an X server is running on the machine, you can usually switch
to it using the CTRL+ALT+F1 key sequence.
Using the Login Manager: (How to login and out of the graphical environment)
18
Terminals in the Graphical environment
In Red Hat Enterprise Linux, the most commonly used terminal application is
called gnome-terminal. A new gnome-terminal window can be opened by
right-clicking on the desktop background, and choosing the top menu item in
the pop-up menu, "Open in Terminal". Alternately, you may select the
Applications : System Tools : Terminal menu item.
19
Using the who command to determine who's
on the system.
Users can use the who command to determine who is on the system, and how they
logged on. From any terminal, users can type who and hit the RETURN key. They
should see output similar to the following.
The first column lists the users who have logged on, and the last few columns the time
that they logged on. With a little experience, the second column tells where the user
logged on. For the first two users, elvis, and root, tty2 and tty3 refers to virtual consoles
number 2 and 3, respectively. The first entry for blondie on tty1 with the :0, refers to the
X server itself running on the first virtual console, and pts/0 refers to the first terminal
opened within the X server. Without getting too bogged down in the details, we can see
that elvis is logged on the second virtual console, root on the third, and blondie has
logged in using the graphical environment.
20
Logging into a machine over the network
Using the ssh ("secure shell") utility, users can easily log in to remote machines, either in
the same room, or halfway across the world. Assuming the remote machine is
configured to allow remote logins, and the user has an account on the machine,
logging in to a remote machine can be as easy as logging in on a virtual console. In
the following example, elvis will login to a virtual console on the local machine, called
station.redhat.com. He will then use ssh to login to the remote machine
nimbus.example.com, potentially halfway around the world.
Pay careful attention to the shell prompt in the following example. Because Linux users
are often "hopping" from machine to machine using remote shells, the prompt has
been designed to help the user keep straight what machine the shell is running on.
21
Online Exercises
Using multiple virtual consoles:
•
Press CRTL + ATL + F1 (Already shown a demo)
•
Power on VM RHEL6-030
•
Click on “student” account
Password = redhat
Click on “Login”
Applications > System Tools > Terminal
•
Lets change the password for users elvis:
su Password: redhat
passwd elvis
new password = redhat
exit
exit
•
System > Log Out student
•
Click on “elvis” account; password = redhat
•
Finished
22
Chapter 2. The Kernel, Programs, and
Processes
The Linux Kernel
The Linux kernel is an operating system, just as Windows, MacOS, and OS/2 are operating systems. The operating
system is an environment in which programs run, providing mechanisms for programs to interact with the
computer hardware. The kernel lets programs know when a keyboard key was struck, when the mouse moved,
or when a packet destined for the program arrived over the network. The kernel allows programs to access the
harddrive, perhaps to read a configuration files or store data.
Just as it would be difficult to explain what a language is to people who have grown up only knowing about one
language, it is often difficult to explain what an operating system is to people who are new to computers, or who
have only used one operating system. The operating system operates at such a low level, that users don't
interact with it directly, and often don't realize that the programs they are running are using it.
Figure 2.1. The Kernel and Processes
The Kernel and Processes
23
Programs
Programs are files that are stored on a computer's harddrive. A
program is a series of very basic instructions, that tell the
operating system what to do and when to do it in a very detailed
and specific manner. The following might be the instructions
written down in the file /usr/bin/gcalctool
24
Processes
When a user instructs the kernel to run a program, the kernel reads the instructions found in the program file, and
loads them into memory. It then begins performing the instructions. The copy of the program running in
memory is called a process. Note that the same program can be loaded into memory and run more than
once, so that at any point the kernel might be running several processes which are instances of the same
program.
Linux, like most modern operating systems, is a multitasking operating system. This means that the kernel gives the
appearance of running multiple processes simultaneously. In reality, the kernel is running a single process for a
brief amount of time, usually on the order of 50 milliseconds. It then swaps that process out, and swaps in
another one for its 50 milliseconds of action. Eventually, the kernel works its way through all of the processes
and starts over again. The rapid switching from process to process gives the users of the machine the
impression that all of the processes are running simultaneously.
25
Shells
Linux users often use a special type of program, called a shell, to interact with the kernel.
The shell runs within a terminal, issuing a prompt and waiting to be told what to do. A
user then asks the shell to run a program by typing in the name of the program. In the
following example, the user elvis asks the shell to run a simple calendar program
called cal. The shell dutifully executes the program, and reports the program's output
back to the terminal:
26
The ps command
The ps command is commonly used to list processes running on a system. The ps
command, without arguments, shows all of the processes that were started from a
single terminal (or terminal window in a graphical environment). In the following
example, elvis discovers that his terminal currently has two processes running: his
bash shell, and the ps command itself.
The first column shows the process's PID, or Process ID. Every process running on the
system is identified by a unique PID. The second column identifies elvis's terminal,
and the third column reports how much CPU time the process has consumed.
The ps aux command shows a detailed list of all processes that are currently running on
the system.
27
Chapter 3. Examining the Filesystem
Key Concepts
•
The base of the Linux directory tree is a directory named / and referred to as "the root
directory".
•
Absolute file references, such as /home/elvis/lsout.txt, refer to files relative to the root
directory.
•
Relative file references, such as lsout.txt, refer to files relative to a process's current
working directory.
•
The ls command is used to list a directory's contents
•
The cat command is used to examine the contents of a file.
•
Using the > character from the shell's command line, the output of a command can be
redirected from the terminal into a file.
•
A user's home directory is one of the few places where users are able to create new
files.
28
The Naming of Files and Directories
In Linux, information and programs are stored on disks as files. Files are grouped into
directories, which can contain files and other directories. (Other operating systems
often refer to directories as "folders"). This hierarchy of directories containing
directories is often referred to as the "directory tree".
The base of the directory tree is a directory named simply /, and referred to as "the root
directory". Files within the root directory can be referred to as /filename.
In summary, there are always two ways to refer to a file. File references relative to the
root directory always start with a leading /, and are called absolute references. File
references relative to the current working directory start with something other than a /,
and are referred to as relative references.
29
Listing directory contents with ls
From a shell, users use the ls command to list the contents of a directory. (Think of the ls
as a shortening of the verb "list".) In the following example, the user elvis wants to list
the contents of the /etc/sysconfig/rhn directory.
The ls command, when called without arguments (i.e., without specifying a directory),
lists the contents of the shell's current working directory. If using a color terminal, the
ls command also colorizes the filenames to help distinguish which of the directory
contents are regular files (white), and which are directories (blue).
The ls command is a very flexible command that can provide a lot of different information.
It will be discussed in more detail in later lessons.
30
Viewing the contents of a file with cat
While the ls command lists the files contained in a given directory, it does not reveal the
contents of the files. While several commands are available for viewing files, the
simplest command is cat. The cat command, when given a list of files, concatenates
the files to the terminal output. If given one filename, the contents of that single file is
displayed as output.
In the following example, the user elvis wants to view the contents of the /etc/hosts
configuration file.
Note that if you ask cat to display a very long file, or a binary (non text) file, cat
will happily comply. There are more sophisticated commands for browsing large
files, a screen full at a time, which will be introduced later.
31
Redirecting command output to files
When the previous ls and cat commands were performed, their output was displayed on
the terminal. In Linux, most commands which generate text output use a common
Unix concept called the "standard out" stream. By default, this stream is connected to
the terminal. The bash shell allows users to "redirect" the standard out stream to other
locations. For now, we will only learn the simplest case: using the > character to
redirect standard out into a file.
In the following example, the user elvis is again going to list the contents of the
/etc/sysconfig/rhn directory, but redirect the output into a newly created file.
The output of the ls /etc/sysconfig/rhn command was not displayed on the terminal, but
instead placed into the newly created file lsout.txt. elvis next takes a ls of his current
working directory, and sees the newly created file. He then uses the cat command to
observe the contents of the file. In "Unix speak", elvis "redirected the output from the
ls command to the file lsout.txt".
32
Permissions, and a user's home directory.
Notice what happens when elvis tries to redirect output to a file somewhere other than his
shell's current working directory.
The user elvis has encountered another common Unix concept, that of file ownerships
and permissions. elvis tried to create the new file /etc/lsout.txt, but elvis does not have
permissions to create files in the /etc directory.
By default, in Red Hat Enterprise Linux, users are not able to create files just anywhere.
In fact, there are only a few places where files can be created. Every user has a home
directory, where they can create new files (and new subdirectories). Fortunately, when
user's log in to a Linux session, their shell uses their home directory as its current
working directory. By default in Red Hat Enterprise Linux, a user's home directory is
named /home/username, where username is replaced with the user's username.
33
Online Exercises
Chapter 3. Examining the Filesystem
The ls Command
Lab Exercise
Objective: Redirect command output into a newly created file.
Estimated Time: 5 mins.
Specification
Use the ls command to list the contents of the /etc directory, redirecting the output of the
command into a file called lsetc.txt in your home directory.
Deliverables
The file lsetc.txt in your home directory, which contains the output of the command ls
/etc.
Possible Solution
The following command provides a possible solution to this exercise.
[student@station student]$ ls /etc > lsetc.txt
34
Chapter 4. Running Commands
Key Concepts
•
Like any language, the bash shell uses a specific grammar.
•
The first word on any command-line is the name of the program to be run.
•
The behavior of commands can be modified with (usually optional) command line
switches, which always start with one or two hyphens (- or --).
•
Any words that follow the command and any command line switches are called the
arguments to the command.
•
Some command line switches also take arguments.
•
Commands usually support the --help, -h, or -? command line switch, which dumps a
summary of how to use the command.
35
Command Line Grammar
If commands entered on the command line were compared to English sentences, the
commands could be thought of as having verbs, adverbs, and direct objects. The verb
is the command to run, the adverbs are the various command line switches that can
be used to modify the behavior of the command (“quietly”, or “verbosely”), and any
remaining words are the direct objects (what the command is supposed to act on).
Again, as in languages, there are irregularities, and for almost every rule mentioned,
there will be exceptions.
36
Commands
The first word on any command is generally the name of a program that lives as a file
somewhere in the filesystem. [1] For example, the previous lessons used the ps and
who commands. If we want to know which file contains these programs, there is a
program called which which can help us. The which command, followed by the name
of another command, will tell you "which" file is being run.
37
Command Line Switches
Many commands can have their behavior modified by specifying different command line
switches. An easy example is the ls command, which is used to list the contents of a
directory. Consider the following three uses of the ls command, each time listing the
files in the /usr directory:
The first ls command simply lists the contents of the directory. The second ls -s
command, which includes the -s command line switch, gives the sizes of the contents
as well. The third ls -l command gives a "long" listing
38
Short Command Line Switches
Notice that both switches used above, -s and -l, are single letter switches. These are
referred to as "short" command line switches. Sometimes, short command line
switches can also take an argument. For example, the ls command has a -w
command line switch, which specifies how "wide" the output should be, in characters.
Consider the following example.
In this case, the word 40 is not considered an argument to the ls command, but instead it
is an argument to the -w command line switch. (How wide should the output be? 40
characters.) Command line switch arguments simply follow the command line switch.
How do you know which command line switches take arguments and which don't?
The short answer is through experience, but we will soon mention ways to find help as
well.
39
Multiple Short Command Line Switches
More than one command line switch can be used at a time. The multiple command line
switches are simply bunched together, squeezed between the command and any
command arguments. The following example introduces a new -r switch for the ls
command, which reverses the sorting order. Note how it is used along with the -s and
-w switches.
40
Multiple Short Command Line Switches
Often, when using multiple command line switches, users will take advantage of a
shortcut that lets all of the switches be "piled together" onto one hyphen (-), as in the
following example.
All of the single letter switches that don't take an argument, in this case -s and -r, can be
piled together, sharing a single -. If a switch does take an argument, such as -w 40, it
can only share a hyphen if it comes last. That way, its argument can be specified next
on the command line.
41
Long Command Line Switches
In the early days of Unix, all command line switches shared the syntax above. As Unix
evolved, people came to see a need for what are called "long" command line
switches. Rather than single letter switches, long switches are composed of words.
And rather than starting with a leading hyphen, long switches are proceeded by
double hyphens (--). Some commands use only short switches, some commands use
long. Many commands, including ls, handle some of both.
42
Arguments
Compared to command line switches, arguments are easy. Whatever words are left over
on the command line, after the command name and after any command line switches,
are called arguments to the command. What a command expects as arguments, or if
it expects any at all, depend on the command. For example, the ls command, if given
arguments, will treat the arguments as the files or directories to be listed. The ps
command expects no arguments. The cal command takes from zero to two, a
possible month and a possible year to generate the calendar for. Learning what
arguments a program expects, and what it does with its arguments, is part of learning
how to use that command.
43
Getting Help: Usage
How does anyone remember all of these command line switches? They don't. But
experienced Linux users learn how to easily refresh their memories. Most commands
support either the --help long command line switch, or the -h or -? short command
line switches. These switches usually make the command dump a "usage" message,
rather than performing it's normal operation. The usage message contains a summary
of what arguments are expected, what command line switches are supported and
what they do. Note that the usage message generated by the ls command is rather
long, and has been abbreviated in the output below.
44
Chapter 5. Managing Terminals
Key Concepts
•
Various control sequences, such as CTRL+C, CTRL+D, and CTRL+Z, can be helpful
for managing processes from the terminal.
•
A terminal's settings can usually be reset to a sane behavior with the reset command.
•
The bash shell provides tab completion, which can be save a lot of typing when
specifying command or files.
•
Various types of terminals can be distinguished by knowing how Linux refers to
devices.
45
Controlling Terminals
The bash shell, and the terminal it runs on, are the primary tools used by experienced
Linux users. Later in this course, an entire Workbook will be devoted to using the
bash shell's powerful features. This lesson introduces some features shared by
terminals in general, and one feature of the bash shell that is too useful to delay until
later, tab completion.
46
Resetting Terminals
When terminals display information, they usually display one byte at a time. When
computers are handling human readable text, the characters are usually encoded as
an integer byte value using the ASCII format. While a byte can encode up to 256
different values, only a small number of these (about 100) are used for text characters
and punctuation. The others are used to encode control sequences (see below) and
other special conditions.
Sometimes, users accidentally (or intentionally) ask a terminal to display data that is not
encoded as ASCII text, such as an image or an executable. The terminal does the
best job it can, displaying characters for ASCII text, but what often appears to be
random garbage for bytes that refer to control characters. Even worse, the terminal
can end up in an alternate graphics mode, so that even what should be normal ASCII
text looks unreadable.
In these situations, the reset command can restore the terminal to sane behavior.
Usually, when you'd like to use this command, you won't even be able to see yourself
type it. However, if at an unreadable bash prompt, blindly typing reset and followed
by the RETURN key will usually restore the terminal to sane behavior.
47
Terminal control sequences
Linux terminals share a lot in common with their primitive ancestors, teletypes and
"dumb" or vt100-like consoles. These early devices had mechanisms for sending "out
of band" signals, or sequences that signaled some event outside of the normal flow of
typed characters, such as a backspace, a linefeed, an audible bell, or an end of
transmission. Linux terminals, like their predecessors, use the CTRL key to send
these "out of band" signals.
48
Terminal control sequences
The following table summarizes many of the commonly used control sequences that are
shared by all Linux terminals, and their common usage, in alphabetical order.
Following the table, the various control sequences are discussed in order of general
usefulness.
49
Terminal control sequences
CTRL+C = MAKE IT STOP!
CTRL+D = This control sequence is used to send an "End of Transmission" (usually
interpreted as "End of File") to the listening process
CTRL+Z is used to suspend a program, which can later be restored with the fg
("foreground") command.
CTRL+U is commonly used to "wipe" the current line. If you have so mangled a bash
command line that you just want to start over, type CTRL+U. Also, CTRL+U is very
helpful when you mess up while entering a password.
50
Terminal control sequences
CTRL+H serves the exact same role as the BACKSPACE key.
CTRL+L was traditionally used to tell a line printer to eject the current page and start on
the next one
CTRL+Q "thaws" a screen (causing it to become active again) after it has been "frozen"
with a CTRL+S. Although it is only useful after a CTRL+S has been used, it is
introduced first (as the more useful command) because almost no one intentionally
uses CTRL+S. Instead, new Unix users will sometimes accidentally type a CTRL+S,
and not understand why their terminal has gone unresponsive. If your terminal ever
seems dead, try typing a CTRL+Q and see if that fixes it.
51
Identifying terminals
Dating back from it's origins as a terminal server, Unix is obsessed with the concept of a
terminal. Processes are grouped into "sessions" based on which terminal they were
started from. While somewhat outdated, knowing how to recognize terminals can help
in tracking the origins of processes.
As with most other devices, programs interact with terminals at a low level through device
nodes, found within the /dev directory. For example, communication with the first
virtual console uses the device node /dev/tty1. Most processes keep a record of which
terminal they were started from, and user's login sessions are usually associated with
the terminal they are using. When identifying terminals in these situations, the terminal
is referred to by its device node, for example, tty1.
In the following excerpt, elvis is listing the current users on a machine with who, and
listing the current processes running from his terminal with ps. In both cases, the
terminal is specified in the column "TTY".
52
Identifying terminals
53
Terminal Device Names
54
Tab Completion
Tab completion is not really a feature of terminals, but of the bash shell that is usually run
within them. Tab completion could well be the most helpful topic within this lesson.
When typing the names of commands and files, a lot of time and effort can be saved
by learning how to make good use of the TAB key.
When typing the name of a command as the first word of a bash command line, start
typing the command you would like to run, but at some point before you finish the
word, stop and hit the TAB key. One of three things will happen.
1. The rest of the command you were beginning to type magically appears.
2. Part of the command you were typing magically appears, but then bash stops and
beeps at you.
3. bash just beeps at you.
55
Online Exercises
Chapter 5. Managing Terminals
Suspending terminal output
Lab Exercise
Objective: Learn to manage terminal output for long running commands.
Estimated Time: 5 mins.
Specification
Like prince in the example, take a recursive listing of the root directory of the filesystem, using the command ls -R /.
While the output is flowing by, freeze your terminal using the CTRL+S control sequence.
Thaw the terminal using the CTRL+Q control sequence. You should be able to alternately freeze and thaw the
streaming output by using these control sequences.
With the output from the command still flowing, suspend the process with the CTRL+Z control sequence.
Confirm your lab with the process suspended.
Deliverables
A stopped (suspended) ls -R / command.
Cleaning Up
After you have finished confirming your deliverable, restore the suspended process to the foreground with the fg
command. Now cancel it with the CTRL+C control sequence.
56
Chapter 6. Getting Help
Key Concepts
Most commands provide terse summaries when invoked with the -h, -?, or --help
command line switch.
More complete reference information can be found in the "man pages", which are viewed
with the man command.
The man pages have chapters, and the content of a preceding chapter might obscure the
content of a trailing chapter.
More complicated commands are often more fully described in info pages.
In Red Hat Enterprise Linux, any less conventional documentation associated with a
specific package can be found in /usr/share/doc.
The Linux Documentation Project provides a wealth of Linux related documentation.
Red Hat manuals provide documentation specific to the Red Hat Enterprise Linux
distribution.
57
Getting Help
Unix, and Linux in particular, has a tradition that manuals and documentation should not
be kept on a bookshelf, but found within the system, in easy reach of the system's
users. No one remembers every command line switch to the ls command, so most
commands provide terse summaries called "usages" when invoked with the
appropriate command line switches. More complete reference information for most
commands can be found in structured "man" pages and "info" pages. In Red Hat
Enterprise Linux, the /usr/share/doc directory contains less structured documentation
specific to a particular package. Lastly, a wealth of guides and tutorials can be found
at the Linux Documentation Project, or in Red Hat Enterprise Linux documentation
packages.
58
Obtaining Usages with -h, -?, and --help
No one remembers all of the functionality of every command, but experienced Unix users
know how to quickly find the information they are looking for online. The first layer of
help is often provided by commands themselves, in the form of "usages", or short
summaries of syntax that are produced when the command is invoked with the -h, -?,
or --help command line switch. Usages were covered in a previous Lesson, but are
mentioned here again for the sake of completeness.
59
Man Pages
Manual pages, more often abbreviated "man pages", are the traditional source of
reference information of Unix systems. A documentation page for most commands, file
formats, programming calls, and general topics can be viewed using the man
command. For example, man ls generates documentation for the ls command.
The less Pager
Red Hat Enterprise Linux uses the less pager for viewing man pages. When viewing files
(including man pages) in less, navigation is provided by single letter keystrokes:
space is used to view the next page, b is used to go back a page, q is used to quit.
less will be covered in more detail in a later lesson, but the table below summarizes
some of the most useful navigation commands when viewing man pages with less.
60
Man Chapters
Man pages are organized into eight standard chapters, as itemized in the following
tables. Some pages share identical names in different chapters. For example, pages
exist for both the passwd command, found in chapter one on user commands, but
also the /etc/passwd file, found in chapter five on file formats. Unfortunately for the
user trying to find documentation on the /etc/passwd file format, man passwd only
displays the first page it finds, in this case the entry from chapter one. In order to view
the man page from chapter five, the chapter must be explicitly specified, as in man 5
passwd.
61
Keyword Searches, and the -a Switch.
Two switches commonly used with the man command include -k, for performing keyword
searches, and -a, for viewing "all relevant" pages for an argument. The user madonna
is trying to find information on the format for the /etc/passwd file. She has already
discovered that man passwd only produces the man page for the passwd command,
so she uses man -k to perform a keyword search on the word passwd.
62
Info Pages
Man pages are usually designed to provide reference information, not tutorials or help on
general context. Many more complicated commands are more fully documented in
hyperlinked "info" pages. Info pages predate the days of web browsers and clickable
links. Info pages are viewed using either the traditional info command, or Red Hat
Enterprise Linux provides a similar command with an easier interface called pinfo.
Info pages are primarily used by software developed by the GNU project.
The command pinfo, without arguments, will list a table of contents for all installed info
pages. Basic navigation is similar to the less pager. Links among the info pages can
be traversed using the four arrow keys, as outlined in the table below.
63
The /usr/share/doc Directory
One of the design principles behind open source software is often summarized "release
early, release often". When developing software, distribute it as soon as it is useful,
even if it is not yet polished or well documented. By allowing users to use software
early, they can help influence the ongoing design of the software for the better.
Red Hat Enterprise Linux embraces this philosophy, and will include useful, stable
software, even if the software is not formally documented in man pages or info pages.
Often, documentation about how to use newly developed products might be a simple
text file called README hastily thrown together by the developer. Red Hat Enterprise
Linux includes such unstructured, but often still helpful, documentation, within the
/usr/share/doc directory, organized by the Red Hat package that owns the software.
Your mileage will vary about how useful the documentation is for any given package. For
example, elvis discovers that the informal documentation provided for the evince
document viewer is rather skimpy, consisting primarily of the developers' unstructured
ChangeLog and a terse README.
64
More on Documentation
• Red Hat Documentation Guides
• The Linux Documentation Project
• yelp: The Gnome Help Browser
65
Download