Linux - EN - LPI exam 101 prep - GNU and UNIX commands.pdf

(337 KB) Pobierz
LPI exam 101 prep:
GNU and UNIX commands
Junior Level Administration (LPIC-1) topic 103
Skill Level: Introductory
Ian Shields
(ishields@us.ibm.com)
Senior Programmer
IBM
15 Nov 2005
In this tutorial, Ian Shields continues preparing you to take the Linux Professional
Institute® Junior Level Administration (LPIC-1) Exam 101. In this third of five
tutorials, Ian introduces you to the Linux® command line and several GNU and UNIX
commands. By the end of this tutorial, you will be comfortable using commands on a
Linux system.
Section 1. Before you start
Learn what these tutorials can teach you and how you can get the most from them.
About this series
The
Linux Professional Institute
(LPI) certifies Linux system administrators at two
levels:
junior level
(also called "certification level 1") and
intermediate level
(also
called "certification level 2"). To attain certification level 1, you must pass exams 101
and 102; to attain certification level 2, you must pass exams 201 and 202.
developerWorks offers tutorials to help you prepare for each of the four exams. Each
exam covers several topics, and each topic has a corresponding self-study tutorial
on developerWorks. For LPI exam 101, the five topics and corresponding
developerWorks tutorials are:
Table 1. LPI exam 101: Tutorials and topics
LPI exam 101 topic
Topic 101
developerWorks tutorial
LPI exam 101 prep (topic
Tutorial summary
Learn to configure your
GNU and UNIX commands
© Copyright IBM Corporation 1994, 2005. All rights reserved.
Page 1 of 83
developerWorks®
ibm.com/developerWorks
101):
Hardware and architecture
system hardware with Linux.
By the end of this tutorial, you
will know how Linux
configures the hardware found
on a modern PC and where to
look if you have problems.
Topic 102
LPI exam 101 prep:
Get an introduction to Linux
Linux installation and package
installation and package
management
management. By the end of
this tutorial, you will know how
Linux uses disk partitions, how
Linux boots, and how to install
and manage software
packages.
LPI exam 101 prep:
GNU and UNIX commands
(This tutorial). Get an
introduction to common GNU
and UNIX commands. By the
end of this tutorial, you will
know how to use commands
in the bash shell, including
how to use text processing
commands and filters, how to
search files and directories,
and how to manage
processes.
Coming soon
Coming soon
Topic 103
Topic 104
Topic 110
LPI exam 104 prep:
Linux, filesystems, and FHS
LPI exam 110 prep:
The X Window system
To pass exams 101 and 102 (and attain certification level 1), you should be able to:
• Work at the Linux command line
• Perform easy maintenance tasks: help out users, add users to a larger
system, back up and restore, and shut down and reboot
• Install and configure a workstation (including X) and connect it to a LAN,
or connect a stand-alone PC via modem to the Internet
To continue preparing for certification level 1, see the
developerWorks tutorials for
LPI exam 101.
Read more about the
entire set of developerWorks LPI tutorials.
The Linux Professional Institute does not endorse any third-party exam preparation
material or techniques in particular. For details, please contact
info@lpi.org.
About this tutorial
Welcome to "GNU and UNIX commands", the third of five tutorials designed to
prepare you for LPI exam 101. In this tutorial, you learn how to use GNU and UNIX
GNU and UNIX commands
Page 2 of 83
© Copyright IBM Corporation 1994, 2005. All rights reserved.
ibm.com/developerWorks
developerWorks®
commands.
is organized according to the LPI objectives for this topic. Very roughly, expect more
questions on the exam for objectives with higher weight.
Table 2. GNU and UNIX commands: Exam objectives covered in this tutorial
LPI exam objective
1.103.1
Work on the command line
Objective weight
Weight 5
Objective summary
Interact with shells and
commands using the
command line. This objective
includes typing valid
commands and command
sequences, defining,
referencing and exporting
environment variables, using
command history and editing
facilities, invoking commands
in the path and outside the
path, using command
substitution, applying
commands recursively through
a directory tree and using man
to find out about commands.
Apply filters to text streams.
This objective includes
sending text files and output
streams through text utility
filters to modify the output,
using standard UNIX
commands found in the GNU
textutils package.
Use the basic UNIX
commands to copy, move, and
remove files and directories.
Tasks include advanced file
management operations such
as copying multiple files
recursively, removing
directories recursively, and
moving files that meet a
wildcard pattern. This
objective includes using
simple and advanced wildcard
specifications to refer to files,
as well as using find to locate
and act on files based on type,
size, or time.
Redirect streams and connect
them in order to efficiently
process textual data. Tasks
include redirecting standard
input, standard output, and
standard error, piping the
output of one command to the
input of another command,
using the output of one
1.103.2
Process text streams using
filters
Weight 6
1.103.3
Perform basic file
management
Weight 3
1.103.4
Use streams, pipes, and
redirects
Weight 5
GNU and UNIX commands
© Copyright IBM Corporation 1994, 2005. All rights reserved.
Page 3 of 83
developerWorks®
ibm.com/developerWorks
command as arguments to
another command, and
sending output to both stdout
and a file.
1.103.5
Create, monitor, and kill
processes
Weight 5
Manage processes. This
objective includes knowing
how to run jobs in the
foreground and background,
bringing a job from the
background to the foreground
and vice versa, starting a
process that will run without
being connected to a terminal,
and signaling a program to
continue running after logout.
Tasks also include monitoring
active processes, selecting
and sorting processes for
display, sending signals to
processes, killing processes,
and identifying and killing X
applications that did not
terminate after the X session
closed.
Manage process execution
priorities. Tasks include
running a program with higher
or lower priority, determining
the priority of a process, and
changing the priority of a
running process.
Manipulate files and text data
using regular expressions.
This objective includes
creating simple regular
expressions containing
several notational elements. It
also includes using regular
expression tools to perform
searches through a filesystem
or file content.
Edit text files using vi. This
objective includes vi
navigation, basic vi nodes,
inserting, editing, deleting,
copying, and finding text.
1.103.6
Modify process execution
priorities
Weight 3
1.103.7
Search text files using regular
expressions
Weight 3
1.103.8
Perform basic file editing
operations using vi
Weight 1
Prerequisites
To get the most from this tutorial, you should have a basic knowledge of Linux and a
working Linux system on which you can practice the commands covered in this
tutorial. Sometimes different versions of a program will format output differently, so
your results may not always look exactly like the listings and figures in this tutorial.
GNU and UNIX commands
Page 4 of 83
© Copyright IBM Corporation 1994, 2005. All rights reserved.
ibm.com/developerWorks
developerWorks®
Section 2. Using the command line
This section covers material for topic 1.103.1 for the Junior Level Administration
(LPIC-1) exam 101. The topic has a weight of 5.
In this section, you learn about the following topics:
• Interacting with shells and commands using the command line
• Valid commands and command sequences
• Defining, referencing, and exporting environment variables
• Command history and editing facilities
• Invoking commands in the path and outside the path
• Using command substitution
• Applying commands recursively through a directory tree
• Using man (manual) pages to find out about commands
This section gives you a brief introduction to some of the major features of the bash
shell, with an emphasis on the features that are important for certification. But the
shell is a very rich environment, and we encourage you to explore it further. Many
excellent books are devoted to UNIX and Linux shells and the bash shell in
particular.
The bash shell
The
bash
shell is one of several shells available for Linux. It is also called the
Bourne-again shell,
after Stephen Bourne, the creator of an earlier shell (/bin/sh).
Bash is substantially compatible with sh, but provides many improvements in both
function and programming capability. It incorporates features from the Korn shell
(ksh) and C shell (csh), and is intended to be a POSIX-compliant shell.
Before we delve deeper into bash, recall that a
shell
is a program that accepts and
executes commands. It also supports programming constructs allowing complex
commands to be built from smaller parts. These complex commands, or
scripts,
can
be saved as files to become new commands in their own right. Indeed, many
commands on a typical Linux system
are
scripts.
Shells have some
builtin
commands, such as
cd, break,
and
exec.
Other
commands are
external.
Shells also use three standard I/O
streams:
GNU and UNIX commands
© Copyright IBM Corporation 1994, 2005. All rights reserved.
Page 5 of 83
Zgłoś jeśli naruszono regulamin