Professional Documents
Culture Documents
Preview: Comptia Linux+ Certification Powered by Lpi
Preview: Comptia Linux+ Certification Powered by Lpi
Preview: Comptia Linux+ Certification Powered by Lpi
EV
IE
CompTIA Linux+
Certification
Powered by LPI
Instructors Edition
Charles G. Blum
Josh Pincus
Dan Quackenbush
Tim Poulsen
Copyeditor:
Ken Maher
Cliff Coryea
IE
Keytester:
No part of this work may be reproduced, transcribed, or used in any form or by any meansgraphic, electronic, or
mechanical, including photocopying, recording, taping, Web distribution, or information storage and retrieval
systemswithout the prior written permission of the publisher.
For more information, go to www.axzopress.com.
Trademarks
EV
Disclaimers
We reserve the right to revise this publication and make changes from time to time in its content without notice.
The logo of the CompTIA Authorized Quality Curriculum (CAQC) program and the status of this or other training
material as Authorized under the CompTIA Authorized Quality Curriculum program signifies that, in CompTIAs
opinion, such training material covers the content of CompTIAs related certification exam.
The contents of this training material were created for the CompTIA Linux+ Powered by LPI exams (LX0-101 and
LX0-102), covering CompTIA certification objectives that were current as of April 2010.
PR
Introduction
Topic A:
Topic B:
Topic C:
Topic D:
Contents
v
1-1
IE
Using Linux
2-1
3-1
EV
System administration
4-1
5-1
PR
Application management
6-1
System configuration
7-1
8-1
ii
System maintenance
9-1
Networking
10-1
IE
11-1
12-1
EV
Security
13-1
Web environment
14-1
15-1
PR
16-1
A-1
iii
Course summary
S-1
I-1
PR
EV
IE
Index
G-1
Glossary
PR
EV
IE
iv
Introduction
IE
EV
PR
course.
vi
IE
We believe strongly in the instructor-led class. For many students, having a thinking,
feeling instructor in front of them will always be the most comfortable way to learn.
Because the students focus should be on you, our manuals are designed and written to
facilitate your interaction with the students, and not to call attention to manuals
themselves.
We believe in the basic approach of setting expectations, then teaching, and providing
summary and review afterwards. For this reason, lessons begin with objectives and end
with summaries. We also provide overall course objectives and a course summary to
provide both an introduction to and closure on the entire course.
Our goal is your success. We encourage your feedback in helping us to continually
improve our manuals to meet your needs.
EV
Manual components
Appendix
Course summary
Glossary
Index
PR
Table of contents
The table of contents acts as a learning roadmap for you and the students.
Introduction
The introduction contains information about our training philosophy and our manual
components, features, and conventions. It contains target student, prerequisite,
objective, and setup information for the specific course. Finally, the introduction
contains support information.
Introduction
vii
Units
Units are the largest structural component of the actual course content. A unit begins
with a title page that lists objectives for each major subdivision, or topic, within the unit.
Within each topic, conceptual and explanatory information alternates with hands-on
activities. Units conclude with a summary comprising one paragraph for each topic, and
an independent practice activity that gives students an opportunity to practice the skills
theyve learned.
The conceptual information takes the form of text paragraphs, exhibits, lists, and tables.
The activities are structured in two columns, one telling students what to do, the other
providing explanations, descriptions, and graphics. Throughout a unit, instructor notes
are found in the left margin.
Appendices
IE
EV
This section provides a text summary of the entire course. It is useful for providing
closure at the end of the course. The course summary also indicates the next course in
this series, if there is one, and lists additional resources students might find useful as
they continue to learn about the software.
Glossary
The glossary provides definitions for all of the key terms used in this course.
Index
PR
The index at the end of this manual makes it easy for you and your students to find
information about a particular software component, feature, or concept.
viii
Manual conventions
Item
Description
Italic text
Bold text
Code font
IE
Instructor note/icon
Weve tried to keep the number of elements and the types of formatting to a minimum
in the manuals. We think this approach aids in clarity and makes the manuals more
classically elegant looking. But there are some conventions and icons you should know
about.
Longer strings of
code will look
like this.
Instructor notes.
EV
Keycaps like e
Warning icon.
Tip icon.
PR
Setup icon.
Projector icon.
Introduction
ix
Hands-on activities
Do it!
A-1:
Heres how
1 Open Sales
Heres why
IE
The hands-on activities are the most important parts of our manuals. They are divided
into two primary columns. The Heres how column gives short directions to the
students. The Heres why column provides explanations, graphics, and clarifications.
To the left, instructor notes provide tips, warnings, setups, and other information for the
instructor only. Heres a sample:
EV
For these activities, we have provided a collection of data files designed to help students
learn each skill in a real-world business context. As students work through the activities,
they will modify and update these files. Of course, students might make a mistake and
therefore want to re-key the activity starting from scratch. To make it easy to start over,
students will rename each data file at the end of the first activity in which the file is
modified. Our convention for renaming files is to add the word My to the beginning
of the file name. In the above activity, for example, students are using a file called
Sales for the first time. At the end of this activity, they would save the file as My
sales, thus leaving the Sales file unchanged. If students make mistakes, they can start
over using the original Sales file.
PR
In some activities, however, it might not be practical to rename the data file. Such
exceptions are indicated with an instructor note. If students want to retry one of these
activities, you will need to provide a fresh copy of the original data file.
PowerPoint presentations
Each unit in this course has an accompanying PowerPoint presentation. These slide
shows are designed to support your classroom instruction while providing students with
a visual focus. Each presentation begins with a list of unit objectives and ends with a
unit summary slide. We strongly recommend that you run these presentations from the
instructors station as you teach this course. A copy of PowerPoint Viewer is included,
so it is not necessary to have PowerPoint installed on your computer.
The CD also contains a PowerPoint add-in that enables you to do two things:
Create slide notes for the class
Display a control panel for the Flash movies embedded in the presentations
EV
IE
After you complete this procedure, a new toolbar will be available at the top of the
PowerPoint window. This toolbar contains a single button labeled Create SlideNotes.
Click this button to generate slide-notes files in both text (.txt) and Excel (.xls) format.
By default, these files will be saved to the folder that contains the presentation. If the
PowerPoint file is on a CD-ROM or in some other location to which the slide-notes files
cannot be saved, you will be prompted to save the presentation to your hard drive and
try again.
PR
When you run a presentation and come to a slide that contains a Flash movie, you will
see a small control panel in the lower-left corner of the screen. You can use this panel to
start, stop, and rewind the movie, or to play it again.
Introduction
xi
Properly setting student expectations is essential to your success. This topic will help
you do that by providing:
Prerequisites for this course
A description of the target student
Course prerequisites
IE
Students taking this course should be familiar with personal computers and the use of a
keyboard and a mouse. Furthermore, this course assumes that students have completed
the following courses or have equivalent experience:
CompTIA A+ certification or equivalent experience
Target student
EV
The target student for this course is a system or network administrator experienced in
Microsoft Windows or another operating system environment. The best-prepared
students will have earned their CompTIA A+ certification and be familiar with common
network administration tasks. Familiarity with any Linux distribution and comfort
working at the command-prompt will be very helpful for students.
PR
For more information about CompTIAs certifications, such as its industry acceptance,
benefits, or program news, students should visit
http://www.comptia.org/certifications.aspx.
To contact CompTIA with any questions or comments, please call (630) 678-8300 or
e-mail questions@comptia.org.
xii
Course objectives
You should share these overall course objectives with your students at the beginning of
the day. This will give the students an idea about what to expect, and it will help you
identify students who might be misplaced. Students are considered misplaced when they
lack the prerequisite knowledge or when they already know most of the subject matter
to be covered.
After completing this course, students will know how to:
Install Linux.
Interact with Linux through both the command line and GUI interfaces.
Manage files, directories, and removable media.
Manage users and groups, set file and directory permissions.
IE
View, control, and kill processes, manage process priority, and load and unload
kernel modules.
EV
Back up and restore data, schedule tasks, monitor performance, and manage
logs.
Set up and configure networking and networking services including DHCP,
NTP, and BIND.
Enable file sharing, export file systems, and use remote file systems; set up,
configure, and manage printing.
Enable assistive technologies to provide accessibility and configure localization
settings to tailor the user environment to the locale.
Configure system and network security, configure routing, and configure
firewall filtering services.
Install and configure Apache, PHP, and MySQL server services; use SQL
commands to access information in a database.
Configure FTP services, and enable outgoing and incoming mail services.
PR
Manage the boot process and runlevels, recover a lost root password,
troubleshoot the network, and write shell scripts.
xiii
Introduction
Skills inventory
Use the following form to gauge students skill levels entering the class (students have
copies in the introductions of their student manuals). For each skill listed, have students
rate their familiarity from 1 to 5, with five being the most familiar. Emphasize that this
is not a test. Rather, it is intended to provide students with an idea of where theyre
starting from at the beginning of class. If a student is wholly unfamiliar with all the
skills, he or she might not be ready for the class. A student who seems to understand all
of the skills, on the other hand, might need to move on to the next course in the series.
Skill
IE
Downloading Linux
Logging on to Linux
EV
PR
xiv
IE
EV
Installing packages
Removing packages
Resolving dependencies
PR
Enabling quotas
xv
Introduction
Skill
IE
EV
PR
Configuring routing
Configuring IP filtering
Installing Apache
xvi
PR
EV
IE
Introduction
xvii
All our courses assume that each student has a personal computer to use during the
class. Our hands-on approach to learning requires they do. This topic gives information
on how to set up the classroom to teach this course. It includes minimum requirements
for the students personal computers, setup information for the first time you teach the
class, and setup information for each time that you teach after the first time you set up
the classroom.
Hardware requirements
Each students personal computer and the instructors computer should have:
IE
EV
Optionally, you may want to provide this additional equipment for use in the classroom:
One or more Linux compatible printers for students to install and print to
One or more USB flash drives that students may use, format, and write data to
Software requirements
Debian GNU/Linux 5.0.6 (Lenny); newer versions will probably work though
some activities might not key exactly as written.
Other versions of Linux might work as well. Some notes are provided where possible.
However, the activities will not work as written for distributions other than Debian.
PR
Network requirements
Student computers must have access to the network and Internet for the duration of the
course. They will download operating system components from the Debian repositories,
which will require Internet access.
You will need the following networking components:
A router to provide network access both within the classroom and to the Internet.
A DHCP server (or device, such as a router that provides DHCP services) to
assign dynamic IP addresses to clients.
A valid static IP address for each classroom computer.
xviii
The preferred configuration for the classroom is that each student has his or her own
physical computer running Debian Linux. However, you can optionally use a
virtualization environment within another operating system. For example, the activities
in this course were tested using Oracles VirtualBox running on a Windows XP
computer. Other virtualization systems are untested, but should work fine. Setup steps
for those alternate systems are not included in this guide.
Make sure to test your virtualization environment prior to class. You might need to
install guest additions or other components to provide a seamless experience between
the host and guest operating systems.
IE
Students will install Debian Linux onto their computers during class. Provided your
classroom computers support booting from a CD, you dont need to install any
operating system prior to class. Optionally, you could start with working Windows (or
Linux) based systems and have students install Linux in place of that operating system.
EV
You must follow these steps regardless of which setup option you choose:
1 Assign each students computer a lab station number. Write that number on a
place card or sticky note affixed to their computer.
2 Create a bootable CD for each student following these steps:
a Visit www.debian.org
b Click Getting Debian
c Under Download larger CD/DVD image files, click HTTP/FTP.
d Under Official CD/DVD images of the "stable" release, click the link
appropriate to your computer architecture, such as i386 or amd64. Save the
file to your computer.
e Burn the ISO file you downloaded to CD making one copy for each student
in your class.
PR
Instead of installing Linux as the sole operating system on the computer, you can run
Debian within a virtual machine using Oracle VirtualBox. If you choose this method,
you must follow these steps at each computer:
1 Install Windows XP, Windows Vista, or Windows 7 according to the software
manufacturers instructions.
2 Configure networking support so that computers can access the Internet.
3 Install the latest critical updates and service packs from
www.windowsupdate.com.
4 Create a user account for students to use. Record the credentials and be prepared
to provide them to students.
5 Log in under the student user account.
6 Download the Windows version of VirtualBox from www.virtualbox.org.
7 Install VirtualBox according to the manufacturers instructions. If warned about
installing unsigned drivers, install the drivers anyway. They are required to
enable USB and networking support within the virtualized environment.
Introduction
xix
Memory: Assign the recommended amount, roughly one-quarter to onehalf, of your computers physical RAM to the virtual machine.
Disk space: Use a dynamically expanding file with a maximum size of
at least 20 GB.
c Do not start the virtual machine at this time as that would begin the Linux
installation that students should do in Unit 1.
IE
Be prepared to help students through the process of starting their virtual machines and
installing Linux. The initial steps vary from installing onto an actual computer. But once
the Linux installer begins, the steps are identical. The following steps replace steps 1
and 2 of Activity B-3 in Unit 1.
1 Open VirtualBox.
2 Select the virtual machine and click Start.
3 When prompted for the installation media, you may use either a physical
CD/DVD disc or downloaded ISO file.
If using a physical disc, insert the CD/DVD disc in the drive. In
VirtualBox, select the appropriate CD/DVD drive when prompted.
EV
If using an ISO file, select ISO Image File and then browse to and select
the Linux installation ISO file.
After Unit 1, Activity B-3, students must enable Bridged Networking. Without this
option selected, the students virtual computers will be unable to communicate with
each other.
1 In the Linux guest, shut down the computer (choose System, Shut Down).
2 Within VirtualBox, select the virtual machine and click Settings.
3 On the left, select Network.
4 From the Attached to list, select Bridged Adapter.
5 Click OK to save your changes.
6 Start the virtual machine.
PR
xx
CertBlaster software
PR
EV
IE
CertBlaster pre- and post-assessment software is available for this course. To download
and install this free software, students should complete the following steps:
1 Go to www.axzopress.com.
2 Under Downloads, click CertBlaster.
3 Click the link for CompTIA Linux + 2009.
4 Save the .EXE file to a folder on your hard drive. (Note: If you skip this step, the
CertBlaster software will not install correctly.)
5 Click Start and choose Run.
6 Click Browse and then navigate to the folder that contains the .EXE file.
7 Select the .EXE file and click Open.
8 Click OK and follow the on-screen instructions.
Introduction
xxi
Topic D: Support
Contacting us
Your success is our primary concern. If you need help setting up this class or teaching a
particular unit, topic, or activity, please dont hesitate to get in touch with us.
Please contact us through our Web site, www.axzopress.com. You will need to provide
the name of the course, and be as specific as possible about the kind of help you need.
Instructors tools
PR
EV
IE
Our Web site provides several instructor tools for each course, including course outlines
and answers to frequently asked questions. To download these files, go to
www.axzopress.com. Then, under Downloads, click Instructor-Led Training and
browse our subject categories.
PR
EV
IE
xxii
11
Unit 1
Installing and using Linux
IE
PR
EV
B Install Linux.
12
EV
IE
Explanation
Exhibit 1-1: Ubuntu Linux with OpenOffice Writer and Mozilla Firefox open
Linux is perhaps most notable because it is free and open source. Programmers have
made versions of Linux available for nearly every computer hardware platform in
current use. Linux is available for:
PR
Specifically, Linus Torvalds wrote the original Linux kernel. The kernel is the software
components that provide the core set of operating system functions. These include
features for managing system hardware and communicating between software and
hardware.
The Linux kernel is the base on which various versions, or distributions, are built. Each
Linux distribution (typically abbreviated distro) bundles a specific set of features,
software components, and a design philosophy that targets a particular use or market
segment. The following table lists a few of the more common distributions in general
use as of this writing.
13
Description
Ubuntu
Make sure students are
clear on the distinctions
among desktop, server,
and embedded versions
of Linux. Many of the
distros are available for
more than one of these
categories, and students
need to choose the
appropriate version for
their own systems.
Red Hat, Inc., authors the Red Hat Enterprise Linux commercial distro
in versions for servers and desktops. It also provides middleware and
software components, consulting, support, and education services. Red
Hat is one of the largest Linux distros in the business marketplace.
Fedora
Fedora is Red Hats end-user Linux distro. While Red Hat engineers
participate, Fedora development is community driven.
SUSE and
openSUSE
Debian GNU/Linux
EV
IE
Distro
Slackware
You can get detailed information about most of the top Linux distros at
http://distrowatch.com/. The http://en.wikipedia.org/wiki/List_of_Linux_distributions
entry at Wikipedia lists even more distributions.
PR
Linux is distributed under a software licensing model called open source. With open
source licensing, you are free to use, modify, and even redistribute the original
programming code, provided you comply with specific terms of the license. There are
many open source licenses under which software can be distributed. Linux follows the
GNU Public License, or GPL.
Closed source
In contrast to open source, closed source is the software industrys traditional licensing
model. Such licenses give you the right to use the software (with various limitations).
However, you are typically restricted from reverse-engineering, modifying, or
redistributing the software. The original publisher retains ownership and full control of
the software. Microsoft Windows, Microsoft Office, Adobe Photoshop, Apple iTunes,
and so forth are examples of software distributed under closed source licenses.
14
Provided that:
IE
EV
Together, these provisions protect you as both the user and author of the software. GPL
software is distributed without warranty. This means you cannot sue or be sued by users
of the software should problems arise related to the use of the application. Furthermore,
you cannot, nor can others, take ownership of the software and release it under a
different license.
As of this writing, the current version of the GPL is called the GNU Affero General
Public License v3, or GPL v3. Many programs continue to be distributed under the
older GPL v2 license.
PR
The LGPL represents an interim place between the free software covered by the GPL
and software licensed under both more permissive and more restrictive licenses. In a
general case, you cant mix program components using one license with components
using another. For example, you cant create a closed source program that uses
components covered by the GPL.
The classic justification for the LGPL given by the FSF is a programming library. In
programming, a library is a self-contained component that provides a specific type or
class of functionality. For example, a library might provide the means to draw boxes on
the monitor. Any time a program needs to draw a box, it can call the library to do so.
Libraries enable programmers to focus on the task at hand rather than reinventing basic
functions for each program.
So lets say you wrote a library for drawing those boxes and released it under the GPL.
Another programmer couldnt use your library in her program unless she also released
her program under the GPL. Libraries are so useful that the FSF decided there should be
an exception for reusable code, such as libraries, so that anyone can benefit.
15
If you released your box-drawing library under the LGPL, other programmers could use
your library in their programs, even if those programs are released under another
license. In the broader realm of computing, LGPL is useful for hardware drivers, DLLs,
programming APIs, and so forth. Entire programs are rarely released under the LGPL.
PHP, Apache, and other license models
IE
The FSFs GPL and LGPL models are certainly not the only open source licensing
models. While some are more restrictive, many of these alternate licenses are
considerably more liberal than the GPL.
PHPThe PHP license, which originated with the PHP programming language,
is an open source license with restrictions. Chief among the restrictions is that
derivations cant use the name PHP in their name or to promote their products.
The licenses restrictions apply to the code of the PHP programming language,
not to programs written with that language.
BSDThe BSD license is a generally permissive license that grants permission
to use, modify, and redistribute software. It requires you to include the original
copyright notice and disclaimers with your modified or redistributed versions.
You cant relicense the code under a different license.
EV
ApacheUsed with the Apache Web server software, this model enables you to
use the software for any purpose. You may redistribute the software in original
or modified form. Unlike the GPL, this license doesnt require you to apply the
Apache license to your redistributed program.
MITOne of the more permissive of the open source models, the MIT license
permits you to use, release, and modify software, and even to change the
licensing model used by your modified version. Notable projects released under
the MIT license include the X Window System (X11), jQuery programming
library, PuTTY secure terminal system, and Bouncy Castle (encryption) API.
PR
Freeware is not a software licensing model. It means only that the software is
provided for free. Freeware could be covered by any of the preceding open source
licenses or could use a proprietary or closed source license.
Likewise, shareware isnt a licensing model. Such software is distributed in a trial
version, with either limited features or a time- or use-limit imposed. You have to pay
the licensing fees to obtain full access to the software. Shareware is typically distributed
under a closed source license.
16
The licenses listed so far apply to software. You cant generally use any of those
software licenses with documentation, books, articles, videos, songs, and so forth. The
Creative Commons group has released various licenses designed to be used with these
non-software digital resources, collectively called the Creative Commons licenses.
These are documented at http://creativecommons.org/about/licenses and range from
Attribution (licensees must simply acknowledge you as the original creator) to
Attribution Non-Commercial No Derivatives (which permits non-commercial
redistribution, but no modification or relicensing).
Public domain
IE
In the USA and most other countries, you automatically own a copyright on something
as soon as you commit it to a tangible medium. In most cases, tangible doesnt mean
physical. Writing a Web page, which exists entirely as digital bits and bytes, is
considered tangible in the eyes of copyright law. By controlling the copyright, you
control what can and cant be done with your creation.
PR
EV
The opposite of copyrighted is public domain. Public domain materials arent owned by
anyone in particular but instead by everyone. In the USA, most things created by the
government are owned by the people and are thus in the public domain. Anyone can do
anything with public domain materials. In practice, you probably couldnt claim public
domain materials as your own, copyright them, or release them under some sort of
restrictive license. Someone would simply need to show that the materials existed
before in the public domain to invalidate your claim.
A-1:
17
Heres how
Heres why
Answers typically include the availability of
professional support and the timely availability of
patches and updates.
IE
PR
EV
18
Objective
102.1
This topic covers the following CompTIA exam objectives for Linux+ [Powered by
LPI] Certification, LX0-101 and LX0-102 exams.
Ensure the /boot partition conforms to the hardware architecture required for booting
The following is a partial list of the used files, terms, and utilities:
IE
/ (root) filesystem
/var filesystem
/home filesystem
swap space
mount points
partitions
102.2
EV
Pre-installation
Explanation
Before you can install Linux, you generally perform the following tasks:
Select the installation type.
Download the appropriate installation files.
PR
19
Installation types
To install Linux, you need the installation files. Depending on the installation type, this
set of files might comprise a set of DVD discs containing every possible application and
package supported by the distro. Or it might include just the minimal files needed to
boot your PC, connect to the Internet, and download the files required to run your distro.
The following table describes the primary installation types you must choose from.
With this option
CD/DVD media
ISO file
IE
Install type
You download an ISO file, burn a disc, and then boot. Unlike the plain
ISO file install option, a live CD provides a fully working Linux
environment. You dont actually have to install anything to run Linux,
provided you have an available hard drive on which to store your files
(the live CD is unwritable). Installable live CDs include programs that
you can use to truly install Linux onto your computer.
Netinst
You download a small bootable file, which you store on a USB drive,
an optical disc, or even a floppy drive. You boot using that medium, at
which point the installation begins. All of the remaining files needed to
install Linux on your computer are downloaded from the Internet,
typically over an HTTP or FTP connection.
EV
Installable live CD
NFS
The Network File System is a means of file sharing across the network
akin to Windows shares. With this installation method, you connect to a
network drive that contains your Linux installation files and load the
installer from there.
Installation files
PR
Most Linux distros are available for multiple hardware platforms. Additionally, many
are available in both 32-bit and 64-bit versions. In general, you should choose the
installation file set that most closely matches your hardware.
For most distros, all Intel-compatible platforms are supported through a single release.
This means that you use the same file whether youre running an Intel Pentium or an
AMD clone system. You see such download files identified with abbreviations such as
x86, i386, i686, and so forth. 32-bit and 64-bit versions are typically be identified with a
suffix: for example, x86_32 or x86_64.
In some cases, a distro takes advantage of specific CPU optimizations; thus you see
processor-specific downloads. For example, you might see an AMD-specific version
identified by the abbreviation amd64.
In most cases, you can run a 32-bit version on a 64-bit CPU. The reverse isnt true,
however. You get the best performance and optimized feature set by using the exact
version for your platform (in other words, use the 64-bit version on a 64-bit platform,
whenever possible).
110
To burn an ISO file or installable live CD to disc, you need a CD/DVD recording
(burning) application that supports ISO files. Windows 7 enables you to burn ISO
images to disc. Simply right-click the ISO file and choose Burn disk image.
For Windows XP and earlier versions, you need to download and install ISO burning
software. The following table lists a few free and commercial applications for burning
ISO images on Windows XP-based computers.
License / cost
URL
InfraRecorder
www.infrarecorder.org
ISO Recorder
http://isorecorder.alexfeinman.com/isorecorder.htm
Commercial
www.nero.com
EasyCD Creator
Commercial
www.roxio.com
IE
Application
Do it!
EV
Macintosh OS X and Linux computers include the software needed to burn ISO images
to disc. On a Macintosh, use the Disk Utility program. On Linux, you can use the
command line cdrecord tool or any of the graphical front-ends, including X-CdRoast
or gCombust. The Nautilus file management tool in the GNOME environment also
provides ISO burning functions.
B-1:
Heres how
Heres why
PR
111
Explanation
Each partition uses a file system type. Various file systems are available, each with
(sometimes subtle) benefits and tradeoffs. If you set up multiple partitions on your
system, each can use a distinct file system type.
File system types
Popular hard drive file systems for Windows computers include NTFS (the Windows
NT File System) and FAT32. The older 16-bit FAT (file allocation table) file system
isnt used on hard drives any more. The virtual FAT (VFAT) system introduced with
Windows 95 is still used on some removable media, such as USB drives and camera
memory cards.
IE
Be brief.
Students dont need to
know in-depth file
system info at this
point.
Linux cant use NTFS, FAT32, or FAT/VFAT file systems for its hard disks, though it
can use FAT/VFAT and FAT32 on removable media. Natively, Linux distros use one or
more of the following file systems:
ext2The second extended file system is an older Linux file system type. It
offers benefits for removable media, particularly flash-memory-based devices.
EV
ext3The third extended file system is a journaling file system. Its the
primary file system used by many Linux distros at the time of this writing. In
general, journaling file systems log changes before actually writing them to the
file system, making them less likely to become corrupted during a system crash.
ext4The successor to ext3 was released at the end of 2008, yet for various
reasons, its not the default file system on most distros yet.
JFSIBM has released its Journaling File System (JFS) under the GPL and
makes versions available for Linux, OS/2, and AIX.
ReiserFSA journaling file system created by programmer Hans Reiser at
Namesys. Once the native file system of SUSE Linux, it isnt commonly used in
current distros.
PR
XFSA journaling file system created by Silicon Graphics (SGI) for its IRIX
operating system. Its a high performance file system with features to support
large files. SGI ported the file system to the Linux kernel, which has included
XFS support since kernel version 2.4.
Linux partitions
You may create additional partitions. For example, you can create a volume for just
your data files. Doing so would make backing up your data files a bit easier, as you
could simply back up that entire volume.
Unless volumes are on distinct hard drives, theres generally no performance advantage
to maintaining separate partitions. Putting the root and swap files onto separate
partitions is an exception to this rule.
112
Swap data, specifically, doesnt need or benefit from journaling. In fact, journaling
requires extra processing and transfer overhead, which is contrary to the purpose of
swap data. Because swap data is dynamic, loss during a drive failure or power outage
isnt a problem; the data will be recreated the next time you boot, regardless.
Swap partition size
When you run programs that consume more memory than you have installed in your
computer, some portions of memory are stored on the swap partition. This creates the
illusion that your computer has more RAM than it actually does. This begs the question
of how much swap space is sufficient.
Amount of RAM
IE
Low, 30 GB or less
512 MB 1 GB swap
1 2 GB swap
Low, 30 GB or less
1 GB swap
2 GB swap
EV
In all cases, adding more physical RAM is better than adding more swap space.
However, expanding the size of your swap partition later is more difficult than creating
a larger partition when you install Linux. So, dont skimp unless youre very limited on
disk drive space.
Partitioning utilities
Partitioning utilities are the software you use to create and manage partitions and their
file systems. In most cases, these utilities are built into the installer or are run
automatically during installation. You can also download and use some separately. For
example, you can use gparted, the GNOME Partition Editor, to manage partitions.
PR
With gparted, you download an ISO file image, create a CD, and boot with that disc.
Your system loads a minimal Linux environment from that disc and opens the gparted
utility automatically. In fact, you can use gparted to manage Windows and Linux
partitions without installing Linux onto the computer.
Once your Linux computer is up and running, you can use gparted or its command-line
equivalent, parted (for partition editor), to modify your existing partitions. When
creating new partitions with parted, you might also need to use the mkfs (make file
system) command to create your file system. You can execute this command as part of
your parted command. For more information on parted, see your systems man
pages or visit www.gnu.org/software/parted/manual/html_mono/parted.html.
B-2:
113
Heres how
Heres why
The ext2 file system is more suitable for swap,
because it doesnt include journaling.
PR
EV
IE
114
Installing
With older versions of Linux, you used to have to gather all sorts of technical details
about the hardware in your computer. (Some of the technically complex distributions,
such as Slackware, still require this.) You needed to know the interrupts and IO
addresses of the various adapters in your system, the graphics chipset your video
adapter uses, and so forth. Arguably, one of the largest advancements in more recent
Linux distros has been improved installers that detect all these values for you. In this
way, modern Linux distros are now like Windows and Mac OS X in their ability to
auto-detect and auto-configure hardware configurations.
Explanation
IE
Another way installers have improved is their ability to work cooperatively with
existing operating systems on your computer. Previously, you had to install onto an
empty hard drive or partition your drive prior to installing Linux into an empty partition.
Modern desktop distros, in particular, now handle such details for you.
PR
EV
During an installation, you can often specify to resize an existing Windows partition in
order to make room for running Linux side by side with Windows on the same PC. Or,
you can use the installer to erase a Windows partition for a clean install of Linux.
Most Linux distros include boot loaders, which enable you to select which operating
system to load when you boot your PC.
B-3:
Installing Linux
Heres how
1 Insert your Linux installation CD
into your CD drive
IE
Heres why
115
EV
If necessary.
Click Continue
Click Continue
PR
Continue
Click Continue
If necessary.
Click Continue
116
partition (recommended
for new users)
Click Continue
10 Click Continue
Select Yes
Click Continue
IE
EV
PR
IE
117
PR
EV
118
Security
You must log on to Linux before you can perform most operations. In most cases, you
should log on using a normal user account. Linux includes methods to operate as an
administrative user temporarily, when you need to perform restricted operations.
EV
IE
Explanation
PR
B-4:
Logging on to Debian
Heres how
1 Enter your user name
Press e
2 Enter your password
Press e
It should be p@ssword.
IE
Heres why
If students systems
are running within a
VirtualBox environment,
they must configure
bridged networking
support at this time. See
the course setup
instructions.
119
6 Choose System,
EV
PR
120
Topic B
In this topic, you learned that modern Linux installers automatically perform most of the
hardware-specific configuration tasks needed when installing Linux. You learned about
various installation options, such as installing from CD, network location, or USB boot
image. You briefly examined the file systems used by popular Linux distros. You then
installed Linux onto your computer. Finally, you logged onto your new Linux system.
IE
Review questions
Topic A
There are versions of Linux for nearly every hardware platform imaginable.
The kernel is software components that provide the core set of operating system functions.
EV
Answers might include Ubuntu, Fedora, openSUSE, Debian, Red Hat Enterprise, and Slackware.
4 True or false? GPL software has to be given away; companies cant charge money
for it.
False. GPL software is free in the sense that youre free to use it, modify it, and redistribute it as
you see fit.
5 Lets say you modify a GPL program, such as Linux. According to the licensing
model, what must you do if you redistribute the modified software?
You must license your modified software under the GPL. You must include a copyright notice,
exclusion of warranty statement, and a copy of the GPL. You must also include or provide a
means to obtain the source code to your modified version of the software.
PR
No. GPL software isnt necessarily freeware. Freeware simply means that theres no monetary
cost for using the software. Freeware could be closed source software. You could charge money
for GPL software.
8 True or false? Only the government can create public domain resources?
False. You can release any original work into the public domain and thereby disclaim any
copyright, title, or rights to the work.
9 True or false? Installing Linux always begins with burning an ISO image to disc.
False. You could install over the network. You could also simply borrow a disc or purchase a
commercially prepared disc.
121
10 Youre about to download a Linux installation image. You want to install it onto an
AMD-based clone computer. Could you use a file named i386.iso?
Yes, though if the distro has an AMD-specific version, youd be better off choosing it instead.
11 Youve inherited a computer running an old version of Debian and want to install a
new version of Ubuntu. Youve downloaded the ISO file. Do you need a third-party
utility to burn a disc from that file?
No. Most Linux distros include utilities for burning discs from ISO files.
12 A ______ file system is one that logs changes before actually committing them to
disk.
journaling or journaled
IE
13 Whats the practical result of this statement? Ext3 volumes use 32-bit namespaces,
and ext4 volumes use 64-bit namespaces.
The ext4 file system supports much larger volumes and much larger files than ext3-based disks.
14 Whats the benefit of creating separate root and swap partitions on the same
physical drive?
You can use a different file system type on each.
15 Whats the benefit of creating separate root and swap partitions on separate physical
drives?
EV
Performance improvement: Your computer can likely perform multiple read and write operations
simultaneously when root and swap are on separate partitions.
16 In most cases, you log onto Linux using a(n) ______ user account and then use a
command to operate temporarily as a(n) ______ account ,when necessary.
normal, administrative
Youll compare Linux distros to learn why you might choose one over the other.
1 Log in to your Linux computer.
PR
PR
EV
IE
122
21
Unit 2
Using Linux
IE
PR
EV
22
Objective
103.1
This topic covers the following CompTIA exam objectives for Linux+ [Powered by
LPI] Certification, LX0-101 and LX0-102 exams.
Use single shell commands and one-line command sequences to perform basic tasks on the
command line
Invoke commands inside and outside the defined path
The following is a partial list of the used files, terms, and utilities:
IE
pwd
If you come from the Windows or Macintosh world, youre used to working with
graphical user interfaces (GUIs). Linux has GUI interfaces, too. In fact, it has multiple
ones. Whats different is that Linux operates independently of its GUI.
EV
In Linux, user interfaces are components run atop the kernel. You can run a commandline interface (CLI) called a shell. Or, you can run one of various graphical user
interfaces. In fact, because Linux is a multi-user system, one user can be interacting via
a shell while another is using a GUI. Multiple users can even use different GUIs
simultaneously on the same Linux computer.
PR
This is a simplification of
the X Windows system.
Using Linux
23
Client-server architecture
Prior to OS X, the Macintosh worked the same way. In fact, command-line tools were
supported only through add-ons and not as part of the core operating system. OS X has
changed that, because its built atop a Linux-like BSD core. Most people still work only
with the GUI on their Macs, but the command-line is there, hidden under the covers.
IE
The X Windows terminology is taken from the perspective of the application (not of the
user). So, applications (clients) make requests of the server to display output or gather
input from the user.
The primary benefit of this split nature is that you can run the server on one computer
and the client on another. In other words, X Windows is built from the ground up to
support remote computing. You can use a GUI terminal interface over the network to
access a central computer that performs most of the heavy duty processing work.
Virtual consoles
EV
Looking again at the diagram in Exhibit 2-1, you can see multiple shells running atop
the kernel. Linux is a multitasking operating system, and it can perform more than one
task at a time for you, including running multiple shells. One way you can run multiple
shells is by using virtual consoles.
In its traditional use, a console refers to your keyboard and monitoryour primary
input and output devices. If your hardware supports it, you can connect more than one
console (keyboard and monitor) to your computer and run separate programs via each
console. Alternatively, Linux supports virtual consoles, which are software equivalents
to separate keyboard and monitor configurations.
You can run more than one virtual console at a time and switch between them using
Ctrl+Alt key combinations. The following table lists the virtual consoles that Linux
supports and the keys you can use to switch among them.
Key combination
Interface type
tty1
Ctrl+Alt+F1
Command-line
tty2
Ctrl+Alt+F2
Command-line
tty3
Ctrl+Alt+F3
Command-line
tty4
Ctrl+Alt+F4
Command-line
tty5
Ctrl+Alt+F5
Command-line
tty6
Ctrl+Alt+F6
Command-line
tty7
Ctrl+Alt+F7
Graphical (GUI)
PR
Console name
A-1:
Do it!
Heres how
Heres why
24
IE
EV
Press g
8 Enter pwd
PR
6 Choose Applications,
Accessories, Terminal
Using Linux
10 Click within the terminal window
and enter exit
25
IE
Press c a &
Press c a @
13 Press c a &
PR
EV
12 Enter logout
26
Desktop environments
Explanation
GNOME
GNOME is
pronounced ga-nome
just as GNU is
pronounced ga-new.
As of this writing, GNOME (the GNU Network Object Model Environment) is the
most popular Linux desktop environment. Its the default desktop environment for
Debian, Fedora, and Ubuntu, though each of those distros is available with other
environments.
GNOME includes two primary components: the desktop environment and a
programming framework that enables developers to create programs that integrate with
the GNOME environment. The desktop environment is the set of icons, window
borders and colorsas well as the software enginethat enables those components. In
addition, it includes a set of common programs and utilities.
PR
EV
GNOME is no longer
an acronym for
anything. Some have
proposed changing the
name to Gnome to
reflect that change.
IE
Linux distros include a default desktop environment. You can download and install
additional or replacement environments at any time.
27
EV
IE
Using Linux
Metacity is pronounced
like capacity with the
emphasis on the
second syllable.
PR
KDE
The Kommon Desktop Environment, KDE, has been around longer than GNOME,
having started in 1996. At one time, licensing concerns over the Qt toolkit used within
the KDE project led to the starting of the GNOME project. The Qt toolkit is now
licensed under the GPL, removing those concerns.
At the time of this writing, no major Linux distributions other than Slackware use KDE
as their default environment. That said, most distros support KDE. For example, you
can download Kubuntu, which is the KDE version of Ubuntu (which uses GNOME).
Or, you can install KDE atop other distros.
IE
28
EV
KMaile-mail
Konsoleterminal emulation
Xfce
PR
The Xfce desktop environment project started in 1996 like KDE. However, it hasnt
reached the prominence that either GNOME or KDE has reached. Xfce is more modular
than the other environments. This means that users and developers can install only the
components they want, making modestly powered computers better suited to Xfce than
other environments are.
29
IE
Using Linux
EV
Oragecalendar
Terminalterminal emulation
At the time of this writing, no major Linux distributions use Xfce as their default
environment. That said, most distros support it. For some, you can download a variant
of the distro with Xfce already installed, for example, Xubuntu is Ubuntu with Xfce
installed and configured as the default environment.
PR
With a quick search of the Internet, youll easily find a dozen or more other desktop
environments for Linux. These include Enlightenment, Fluxbox, JWM, ROX Desktop,
Blackbox, Ion, and the oddly named Ratpoison. All of these have vocal and loyal
followers. Yet none have achieved widespread use. In most cases, you can download
these environments for most of the major Linux versions.
Do it!
A-2:
Heres how
Heres why
PR
EV
IE
210
Using Linux
211
This topic covers the following CompTIA exam objectives for Linux+ [Powered by
LPI] Certification, LX0-101 and LX0-102 exams.
#
Objective
103.1
Use single shell commands and one line command sequences to perform basic tasks on the
command line
Use and modify the shell environment including defining, referencing, and exporting
environment variables
Use and edit command history
IE
The following is a partial list of the used files, terms, and utilities:
bash
echo
man
history
103.2
EV
Send text files and output streams through text utility filters to modify the output using
standard UNIX commands found in the GNU textutils package
The following is a partial list of the used files, terms, and utilities:
cat
103.3
The following is a partial list of the used files, terms, and utilities:
ls
103.4
PR
105.1
212
Explanation
Unlike Windows or OS X, you dont have to use the GUI in Linux. You can work
entirely via the command line interface (CLI) to do everything from managing your
computer to writing and laying out complex technical publications.
Shells
IE
Another advantage of the Linux CLI is that its the engine behind the GUI. Everything
you can do in the GUI you can do with a text command. This isnt always the case with
Windows and OS X. Experienced users and administrators can take advantage of the
CLI to write scripts to automate common tasks or to manage systems remotely over
low-bandwidth network connectionsfeats that are more difficult in other operating
systems.
A shell is a command line interface to an operating system. In the case of Linux, its
your means of interacting with the kernel through typed commands. Actually, a shell
you use to interact with Linux is called an interactive shell. This is the terminal window
type of shell, akin to a Command Prompt window in Microsoft Windows.
EV
Non-interactive shells are used to run scripts and commands in the background. You
cant interact with a non-interactive shell, meaning you cant type or input information
in response to prompts from commands or from the system.
Well focus on interactive shells, of which theres a huge range available for Linux
systems. Linux shells are simply programs that run atop the kernel. Each shell provides
its own set of commands, options, and means of interaction. Common Linux shells
include the Bourne-Again Shell (bash), TC shell (tcsh), Z shell, public domain Korn
shell, and various others.
BASH
PR
The Bourne shell was developed by Stephen Bourne of AT&T Bell Laboratories in
1977. Linux cant use the Bourne shell directly because of licensing restrictions.
However, most Linux distros use the BASH shell, an open source shell modeled on the
Bourne shell and incorporating features from the Korn shell (ksh) and C shell (csh).
213
IE
Using Linux
EV
In the preceding example, command is the command youre executing. Options are
preceded by a hyphen and are most often single letter modifier to the command.
Arguments are input parameters that specify what resource should be used by the
command.
In other words, the command tells Linux what to do, options tell it how to do it, and
arguments tell it where or on what resource to perform the function. For example,
consider this command:
ls l /usr
PR
The command, ls, prints a list of files to your screen. The l option directs the
command to include long details (extra information, such as permissions, size, and so
forth) about each file. And, the argument directs the command to list the files in the
/usr directory, assuming you have permissions to read that directory.
214
cat
clear
date
echo
exit
finger
who
whoami
B-1:
EV
Do it!
IE
ls
Command
Heres how
Heres why
3 Enter ls /usr
4 Enter ls -l /usr
PR
1 Choose Applications,
Accessories, Terminal
5 Enter clear
6 Enter date
7 Enter cal
Using Linux
215
BASH proficiency
The BASH shell offers many features to ease the difficulty of working with commands
rather than clicks. We examine some of them in this section, starting with a simple trick
to use when the output of a command is too long to fit on the screen. You can press
Shift+Page Up to view previous screens of output. Use Shift+Page Down to scroll back
down a pages worth of output.
Explanation
Lets say youre trying to type whoami, and you type whao and realize youve
reversed the last two letters. You can hit Backspace twice and retype the letters. Or,
pressing Ctrl+T and BASH will reverse the last two letters for you automatically.
Prior commands
You can rerun prior commands by pressing the up-arrow and down-arrow keys until you
find the command you want, then pressing Enter. By default, BASH saves your previous
500 commands in a file named .bash_history (named with a leading period) in your
home directory. You can use the history command to print this command history to
your screen.
IE
EV
In addition to using arrows, you can use the !! command to rerun prior commands.
Entering !! and BASH reruns your previous command. It can also provide a shortcut to
commands you havent used in a while. Lets say you wanted to rerun a command that
began with the letters wh; you could enter !wh and press Enter. BASH reruns the
most recent command you entered that began with those letters. To be sure youre going
to run the right command, enter !wh:p, and BASH prints the command to your screen
rather than executing it.
The history command output includes numbers, which you can use to re-execute the
commands. Simply enter !##, where ## is the number of the command you want to
rerun.
BASH provides a few keyboard shortcuts to ease the task of editing a prior command.
After you press the up or down arrows to arrive at the previous command, you can use
the following shortcuts as you edit that command to meet your current needs:
Ctrl+bto move your cursor one character to the left without erasing (or use the
left arrow key)
Ctrl+f (or use the right arrow key)to move your cursor one character to the
right
PR
Shell variables
Shell variables are references to system information, such as the path to your home
directory. Rather than typing in one of these values manually, you can use the variable
and let BASH figure out the true values for you. This can be especially handy when you
dont know that real value.
Most shell variables begin with the dollar sign ($) with the variable name following in
all capital letters.
216
$GROUPS
$HISTSIZE
Contains the number of prior commands that are saved to your history
file. Enter echo $HISTSIZE to print this list to your screen.
$HOSTNAME
Contains the full path of your current working directory. Enter echo
$PWD to print this information to your screen (or use the pwd
command).
This variable doesnt contain information. Instead, enter echo
$RANDOM to print a random number between 0 and 32767 to your
screen.
EV
$RANDOM
IE
$PWD
Variable
$SHELL
Contains the full path name of the shell youre running. Enter echo
$SHELL to print this information to your screen.
Shell metacharacters
PR
In addition to the variables listed in the preceding table, BASH assigns special meaning
to various characters. These metacharacters enable you to group commands, execute
multiple commands in a single statement, and use the output of one command as input
for the next command. BASH uses the term list to denote the sequence of one or more
pipelines separated by the operators shown in the following table.
Using Linux
217
Description
() or {}
Group two or more commands and treat their output or exit status as a
unit.
&
Background execution
&& and ||
Metacharacters
IE
cd /bin && ls
cd /bin || ls
With the first, BASH attempts to change to the /bin directory. If thats
successful (you had permissions to do so), then it lists the contents of
the directory. If the cd command fails, the second command is
ignored.
With the second line, if you fail to change directories, BASH still lists
the contents of the current directory (not the /bin directory).
EV
Tab completion
You can use the Tab key to perform a few completion tricks. Lets say you want to
change directories to the /usr/games directory. Type cd /usr/g and press Tab. BASH
adds the ames to your command text. Press Enter and change directories.
Of course, this action assumes that youve entered enough information for BASH to
decipher a unique completion. If there are both a games and generic directory in the usr
directory, the preceding trick wont work: /usr/g isnt unique. When you press Tab,
youd hear a beep telling you so. Press Tab twice and BASH lists all the possible
matches for what you entered. You can then try again, entering a unique partial
command and pressing Tab to complete it.
PR
You can also use Tab completion with system commands. Lets say you want to
determine how long your system has been running. The command is uptime. Simply
type upt, press Tab, and BASH completes the command for you.
B-2:
Do it!
Heres how
The terminal window
should still be open. If the
screen saver has begun,
students need to enter
their password to unlock
their station.
Heres why
2 Press z
Press e
IE
4 Enter history
218
EV
Press s u
6 Enter ls /usr
Press a .
PR
Press e
Using Linux
9 Type cd /home/bogus; ls;
Press e
219
12 Type cd /usr/g
IE
Press t
Press e
EV
13 Type cd /b
Press t
Press t
14 Type g
Type n
Press j
PR
Press tt
15 Enter cd ~
16 Enter clear
220
Piping
You can use the output of one command as input to another command. You can also use
text in a file as input for a command rather than typing in required text. You can even
control the output of a command so that its sent to a device other than your screen, such
as to a printer. Collectively, these techniques are called piping and redirection.
Piping is the process of sending the output of one command, or a group of commands,
to another command, which performs some sort of manipulation of that information.
You pipe output using syntax similar to this:
command1 | command2
IE
The output of command 1 becomes the input to command 2. A very common use of
piping is to control the output of a command, such as cat, when that output fills more
than one screen. For example:
cat longfile.txt | more
In this command, the contents of longfile.txt are sent to the more command, which
prints that content to the screen one screenful at a time. Unlike Windows, you can use
the simpler more longfile.txt statement to accomplish the same thing. But the
example still illustrates the use of piping.
EV
Redirecting
Redirecting, or redirection, is similar to piping, except that instead of sending the output
to another program, you send the output to another file or device. For example, the
following command would send the contents of longfile.txt to the printer attached to
/dev/lp0.
cat longfile.txt > /dev/lp0
Redirection can be performed the other way. Lets say you want to automate the transfer
of a file to an FTP server. Typically, you enter a series of commands such as these:
1. ftp e
2. open ftp.example.com e
3. your_username e
4. your_password e
5. lcd ~/localfolder/ e
6. cd ~/serverfolder/ e
7. binary e
8. put myfile.tar.gz e
9. exit e
PR
Using Linux
221
Youre prompted to enter your password. Then, one by one, each line in your text file is
redirected to the ftp command, just as if youd typed in the text yourself.
STDIN, STDOUT, and STDERR
STDIN is the standard input device, which in most cases is your keyboard. In some
Linux implementations, however, STDIN might be something else. Consider Linux
running on a tablet computer with a touchscreen and no keyboard. In such a case, the
touchscreen is likely configured as STDIN and treated much like mouse input.
STDOUT is the standard output device. On modern computers, STDOUT is typically
the monitor. Historically, a line printer or modem was more likely to be the standard
output device.
IE
STDERR is the standard error device, to which the operating system and commands
send error messages. Typically, STDERR is the monitor, but as with STDOUT it used
to be a line printer or modem. STDERR can be configured to go to a nonexistent device,
such as /dev/null, so that error messages arent visible.
Many Linux commands, such as echo, read input from STDIN. Normal output from
these programs is sent to STDOUT. Using piping and redirection, you can temporarily
override these normal input and output locations.
Redirecting STDERR
EV
To override where error messages are sent, you must use a special form of piping and
redirecting. Lets say you want to send the error messages from a fictional program
called someprogram to a file named error log. Youd use a command statement like the
following:
./someprogram 2> error.log
This command says, in essence, to take the output sent to line 2, which is the error
output, and redirect it to the error.log file. The line 1 output, which is the standard
output, is sent to its normal destination (STDOUT). You could send the output of both
lines to the file with this statement:
./someprogram 2&> error.log
The next trick involves using the tee command. It takes the text from STDIN and
writes it to a file you specify. You can use tee to direct output to both a file and the
screen. For example:
PR
Do it!
B-3:
Heres how
Heres why
1 Enter ls /dev
222
Press q
Press Q
2 Enter ls
3 Enter
IE
tee getdebianinfo
EV
Press c + C
PR
6 Enter ls
Using Linux
7 Enter cat nonexistent.file
223
8 Enter rm error.log
IE
PR
EV
224
Named pipes
Explanation
With that command, BASH runs both the cat and more programs at the same time,
directing one to send its output to the structure called a pipe, while directing the other to
read from that pipe, as if the pipe were a file. In essence, a pipe is a special kind of file.
In this case, its an unnamed file set up temporarily by BASH for the duration of the
execution of these commands.
You can also create a persistent pipe in the form of a named pipe. Just as with the
unnamed pipes you used already, named pipes are conduits between applications. They
exist as actual files on your disk and remain until you remove them.
IE
Both named and unnamed pipes are FIFO cache, meaning the first byte in is the first
byte out. Practically, this means that, even though a named pipe is a file on your disk,
data sent to a named pipe is never stored on your disk and takes no space. To work, both
programs must be running and looking to the pipe for output or input. As one program
writes a byte to the pipe, the other reads it from the pipe.
You create a named pipe with the mkfifo command. For example:
mkfifo pipe_name
EV
On some systems, particularly older Linux versions, you use the mknod command
instead of mkfifo. If both are available, mkfifo is the preferred method for creating
named pipes. See the man pages for information on using mknod on your distro.
Once created, you can send output from one command to the pipe and direct another
program to read from the pipe. For example, lets say you create a pipe with this
command:
mkfifo mypipe
Then, you open a new terminal window and enter this command:
cat < mypipe
PR
The file listing created by the ls command is sent to the pipe file named mypipe. In the
other window, the cat reads the mypipe file, as if it were an ordinary file, and outputs
its contents, in this case the file listing, to the screen.
Actually, the order you run the ls and cat commands doesnt matter. The cat
command stops its output when it reaches the end of a file. Basically, it keeps writing
new bytes of data as they arrive in the pipe, just as if it were dealing with an enormous
file. It finally stops when the ls command finishes.
Named pipes are useful when writing shell scripts (mini-programs you write using shell
commands). Theyre also useful to programmers writing applications. You probably
wont use named pipes too often in everyday situations. But there are times they come
in handy.
Lets say you have a program that converts MP3 files to WAV files. And you have a
program that burns WAV files to a CD. To burn a set of MP3 files to a disc, you could
convert the MP3 files to WAV files, then burn the WAV files to disc. But youd need an
extra 700 MB or so of disk space to store the WAV files during the operation. And you
would have to perform the two parts of the operation individually.
Using Linux
225
Do it!
B-4:
Instead, you could set up a named pipe and funnel the output of the MP3-to-WAV
converter into the pipe. Youd direct your CD burner to read from the pipe, as if the
named pipe were a WAV file ready for burning. As each converted byte went in, it
would come out as input to the burner application. The converted files would never
actually be stored on your hard drive, eliminating the need for temporary storage space.
Of course, youd need a computer fast enough to convert the MP3 files, pass the bytes
through the named pipe, and write the resultant WAV files to the CD all at the same
time. Most modern PCs would be able to handle such an arrangement.
Heres how
IE
Heres why
2 Enter
EV
PR
6 Enter rm mypipe
226
Getting help
As you probably know, there are hundreds of BASH commands. Many applications and
services add even more commands for you to learn and use. How can you know all
these commands, their options, and arguments?
Explanation
Fortunately, most Linux distributions include various help tools to make finding such
information easier. You can often turn to the Internet for articles, blog posts, and
examples.
man pages
EV
IE
Linux documentation is typically delivered through man pages, short for manual pages.
To read the documentation on a particular command, enter man followed by the
command name. Syntax and explanatory information about the command will display
on your screen.
Each man page includes sections, a few of the more important of which are:
PR
The output of a man page is shown one screen at a time. Press Enter to advance one line
or Spacebar to advance one screen. With some distros, you can also use the Page Up
and Page Down keys to move through the screens of information. When you reach the
end of a man page, further presses of the Spacebar or Enter keys dont do anything.
Press the Q key at any time to exit the man page.
Sections
Linux commands are categorized by sections in the man page database depending on
the purpose of the command. The following table lists the man page sections and the
types of commands each contains.
Using Linux
Command types and purposes
Library functions
File formats and file conventions, such as documenting the /etc/passwd file
Games
8
9
Section
IE
227
Programs and commands that only the root user may execute
Nonstandard kernel routines
Not all distributions use the exact same categorization scheme. You can find out your
systems man structure by viewing the man pages for the man command (enter man
man).
EV
Sometimes the same keyword is used for both a command and something else, such as a
library routine, so that there are two man page entries. For example, locale is both a
shell command and a file used within programs. It has two man page entries: one in
section 1 and one in section 7.
By default, man displays the lowest-number section page first. So, if you type man
locale, the section 1 man page displays. To display a page from a higher section, include
that number in your command. For example:
man 7 locale
Info pages
Novice users in particular find man pages complex and hard to follow. An alternative,
the info pages, were created to provide simpler instructions more suited to end-users and
beginners.
PR
The info and man pages work similarly, though perhaps differently enough to be a bit
frustrating. While viewing an info page, you press Spacebar to view the next page full
of information. With some distros, you can also use the Page Up and Page Down keys
to move through the screens of information. Pressing Enter activates a cross-reference,
if one exists, rather than advancing the display by a single line as with man pages. Also
unlike man pages, when you reach the end of an info page, pressing Spacebar again
returns you to the beginning of the page. But, like man pages, you press the Q key to
exit the info page.
Some info pages begin with copyright or other information not directly germane to
getting help with a command. You have to press Spacebar as necessary to bypass these
screens.
228
Some commands, in particular many of the BASH shell commands, provide syntax help
in addition or instead of a man or info page. You can access this syntax summary in one
of two ways:
help echo
ls --help
The first of the preceding statements prints syntax help for the echo command. The
second displays such help for the ls command. Unfortunately, the reverse doesnt
work: entering echo --help results in outputting the characters --help to your screen.
Do it!
B-5:
IE
If you enter help by itself, you get a list of commands for which help pages are
available. If you dont see a command listed in that output, you can try using the
--help command-line option instead. Or, you can simply try your favorite method. If it
doesnt work, try the other.
Getting help
Heres how
Heres why
Press Q
EV
Enter help ls
PR
4 Enter man ls
Press e
Press q
Press Q
Press Q
Using Linux
Press Q
229
IE
info gzip
EV
PR
230
Topic B
In this topic, you learned that shells provide the command line interface to Linux. The
default CLI shell for Linux is the BASH shell. You used various commands to interact
with your system. You also used various BASH shell techniques to re-execute previous
commands, edit commands, and pipe and redirect input and output from commands.
Finally, you explored the various help systems, including man pages, info pages, and
command-line help options.
IE
Review questions
Topic A
1 True or false? In Linux, the GUI is tightly integrated with the operating system,
making it difficult to change.
False. GUIs interact with the X Windows system so that you can easily switch between GUIs in a
way not possible with many other operating systems.
EV
False. The CLI interacts directly with the operating system and doesnt rely on any GUI
components.
3 In GNOME, bars at the top or bottom of the screen are called _______.
panels
GNOME, KDE, and Xfce are the most popular. But the list also includes environments such as
Enlightenment, Fluxbox, Blackbox, and Ratpoison.
5 The default desktop environment for Debian, Fedora, and Ubuntu is _______.
GNOME
6 True or false? You can install both GNOME and KDE on the same Linux system.
PR
True
Using Linux
231
12 With the ________ command, you can determine whos logged onto your system.
who
Press Shift+Page Up
13 Whats the keystroke combination you use to scroll up to view information that has
scrolled off your screen?
14 What the keystroke combination you use to repeat the last argument from the
previous command?
Press Alt+period
IE
17 True or false? Once youve logged off, the list of your prior commands is erased, so
that its unavailable the next time you log on.
False. Prior commands are saved to the .bash_history file in your home directory, so that theyre
available the next time you log on.
18 Youre helping a user and want to change the working directory to her home
directory. What command do you use?
EV
19 You want to determine how long your computer has been running. You can enter
upt and press the ______ key to get BASH to finish the command for you.
Tab
20 Piping uses the ______ of one command as ______ for a second command.
output, input
21 True or false? You can use redirection to send a collection of inputs automatically to
a command.
True
PR
22 Whats the help command used to display technical information best suited for
experienced users and administrators?
man
23 Whats the help command used to display information best suited for end users?
info
232
To explore how a graphical user interface makes tasks easier, youll explore the
OpenOffice Calc program. Then, youll practice some shell commands.
EV
IE
2 Using Exhibit 2-8 as a reference, create a basic spreadsheet. Use the buttons and
menus to format your spreadsheet to approximate the exhibit.
PR
6 Explore the cal command: try entering it; use the help systems to determine its
purpose and command options.
7 Explore the find command: try entering it; use the help systems to determine its
purpose and command options.
8 Explore the sudo command: try entering it; use the help systems to determine its
purpose and command options.
10 Log out.