SuSe Linux Fundamentals

Download as pdf or txt
Download as pdf or txt
You are on page 1of 396
At a glance
Powered by AI
The document covers topics related to Novell networking software including copyright statements, disclaimers, trademarks and piracy policies.

The document covers topics such as proprietary statements, disclaimers, trademarks, software piracy, and a glossary of terms.

Some key terms defined include proprietary statements, disclaimers, trademarks, software piracy, Novell, NetWare, and more.

SUSE Linux Fundamentals

C OURSE 303 6

Novell Training Services


A U T HOR IZ E D C OU RS E WARE

w w w. n o v e l l . c o m

100-005042-001 Version 3

Proprietary Statement
Copyright 2005 Novell, Inc. All rights reserved. No part of this publication may be reproduced, photocopied, stored on a retrieval system, or transmitted without the express prior consent of the publisher. This manual, and any portion thereof, may not be copied without the express written permission of Novell, Inc. Novell, Inc. 1800 South Novell Place Provo, UT 84606-2399

Trademarks
Novell, Inc. has attempted to supply trademark information about company names, products, and services mentioned in this manual. The following list of trademarks was derived from various sources.

Novell, Inc. Trademarks


Novell, the Novell logo, NetWare, BorderManager, ConsoleOne, DirXML, GroupWise, iChain, ManageWise, NDPS, NDS, NetMail, Novell Directory Services, Novell iFolder, Novell SecretStore, Ximian, Ximian Evolution and ZENworks are registered trademarks; CDE, Certified Directory Engineer and CNE are registered service marks; eDirectory, Evolution, exteNd, exteNd Composer, exteNd Directory, exteNd Workbench, Mono, NIMS, NLM, NMAS, Novell Certificate Server, Novell Client, Novell Cluster Services, Novell Distributed Print Services, Novell Internet Messaging System, Novell Storage Services, Nsure, Nsure Resources, Nterprise, Nterprise Branch Office, Red Carpet and Red Carpet Enterprise are trademarks; and Certified Novell Administrator, CNA, Certified Novell Engineer, Certified Novell Instructor, CNI, Master CNE, Master CNI, MCNE, MCNI, Novell Education Academic Partner, NEAP, Ngage, Novell Online Training Provider, NOTP and Novell Technical Services are service marks of Novell, Inc. in the United States and other countries. SUSE is a registered trademark of SUSE Linux AG, a Novell company. For more information on Novell trademarks, please visit http://www.novell.com/company/legal/trademarks/tmlist.html.

Disclaimer
Novell, Inc. makes no representations or warranties with respect to the contents or use of this manual, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. Further, Novell, Inc. reserves the right to revise this publication and to make changes in its content at any time, without obligation to notify any person or entity of such revisions or changes. Further, Novell, Inc. makes no representations or warranties with respect to any NetWare software, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. Further, Novell, Inc. reserves the right to make changes to any and all parts of NetWare software at any time, without obligation to notify any person or entity of such changes. This Novell Training Manual is published solely to instruct students in the use of Novell networking software. Although third-party application software packages are used in Novell training courses, this is for demonstration purposes only and shall not constitute an endorsement of any of these software applications. Further, Novell, Inc. does not represent itself as having any particular expertise in these application software packages and any use by students of the same shall be done at the students own risk.

Other Trademarks
Adaptec is a registered trademark of Adaptec, Inc. AMD is a trademark of Advanced Micro Devices. AppleShare and AppleTalk are registered trademarks of Apple Computer, Inc. ARCserv is a registered trademark of Cheyenne Software, Inc. Btrieve is a registered trademark of Pervasive Software, Inc. EtherTalk is a registered trademark of Apple Computer, Inc. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries. Linux is a registered trademark of Linus Torvalds. LocalTalk is a registered trademark of Apple Computer, Inc. Lotus Notes is a registered trademark of Lotus Development Corporation. Macintosh is a registered trademark of Apple Computer, Inc. Netscape Communicator is a trademark of Netscape Communications Corporation. Netscape Navigator is a registered trademark of Netscape Communications Corporation. Pentium is a registered trademark of Intel Corporation. Solaris is a registered trademark of Sun Microsystems, Inc. The Norton AntiVirus is a trademark of Symantec Corporation. TokenTalk is a registered trademark of Apple Computer, Inc. Tru64 is a trademark of Digital Equipment Corp. UnitedLinux is a registered trademark of UnitedLinux. UNIX is a registered trademark of the Open Group. WebSphere is a trademark of International Business Machines Corporation. Windows and Windows NT are registered trademarks of Microsoft Corporation. All other third-party trademarks are the property of their respective owners.

Software Piracy
Throughout the world, unauthorized duplication of software is subject to both criminal and civil penalties. If you know of illegal copying of software, contact your local Software Antipiracy Hotline. For the Hotline number for your area, access Novells World Wide Web page at http://www.novell.com and look for the piracy page under Programs. Or, contact Novells anti-piracy headquarters in the U.S. at 800PIRATES (747-2837) or 801-861-7101.

Contents

Contents

Introduction Course Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-2 Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-2 Certification and Prerequisites . . . . . . . . . . . . . . . . . . . . . . Intro-3 SLES 9 Support and Maintenance . . . . . . . . . . . . . . . . . . . Intro-5 SLES 9 Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . Intro-6 Agenda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-7 Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-8 Exercise Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-9 SECTION 1 Understand the Linux Story Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 Objective 1 The History of Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
The Historical Development of UNIX . . . . . . . . . . . . . . . . . . . 1-2 The Development of Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 The Software Differences Between SUSE Linux and SUSE Linux Enterprise Server . . . . . . . . . . . . . . . . . . . . . . . . 1-6

Objective 2

Identify the Components of SLES 9 . . . . . . . . . . . . . . . . . . . . 1-8


Updated Core System with Latest Versions/Features of All Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . New and Improved YaST Modules . . . . . . . . . . . . . . . . . . . . . Next Generation Linux Kernel 2.6.5 . . . . . . . . . . . . . . . . . . . . Improved High Availability Support . . . . . . . . . . . . . . . . . . . Full Enablement and Support of UTF-8 . . . . . . . . . . . . . . . . 1-8 1-9 1-9 1-10 1-10

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

TOC-1

SUSE Linux Fundamentals

Inclusion of Red Carpet Enterprise Daemon . . . . . . . . . . . . . 1-10 New Type of Installation Source: SLP . . . . . . . . . . . . . . . . . 1-10 POSIX-Compliant, High-Performance Threads Support (NPTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11

Objective 3 Objective 4

Understand the Multiuser Environment. . . . . . . . . . . . . . . . . 1-12 Perform a Simple Installation of SLES 9. . . . . . . . . . . . . . . . 1-15
Pre-Installation Requirements and Guidelines . . . . . . . . . . . . Installation Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Basic Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Manual Software Selection . . . . . . . . . . . . . . . . . . . . . . . . . . Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 1-1 Install SUSE Linux Enterprise Server 9 . . . . . . . 1-15 1-17 1-19 1-23 1-26 1-37

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-40 SECTION 2 Use the Linux Desktop Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Objective 1 Objective 2 Overview of the Linux Desktop. . . . . . . . . . . . . . . . . . . . . . . . 2-3 Use the KDE Desktop Environment . . . . . . . . . . . . . . . . . . . . 2-6
How to Log In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Log Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Shut Down and Reboot the Linux System . . . . . . . . . How to Identify KDE Desktop Components . . . . . . . . . . . . . How to Manage Icons in the KDE Environment . . . . . . . . . . How to Use the Konqueror File Manager . . . . . . . . . . . . . . . Exercise 2-1 Explore Your KDE Desktop . . . . . . . . . . . . . . . . 2-6 2-9 2-9 2-11 2-14 2-17 2-20

Objective 3

Use the Gnome Desktop Environment . . . . . . . . . . . . . . . . . 2-22


How to Start GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to Navigate in GNOME . . . . . . . . . . . . . . . . . . . . . . . . How to Manage Icons in GNOME . . . . . . . . . . . . . . . . . . . . How to Use the GNOME File Manager (Nautilus) . . . . . . . . 2-23 2-23 2-25 2-26

TOC-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Contents

Exercise 2-2 Explore Your GNOME Desktop . . . . . . . . . . . . . 2-28

Objective 4

Access the Command Line Interface From the Desktop . . . . 2-29 Exercise 2-3 Access the Command Line Interface. . . . . . . . . . 2-31 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32

SECTION 3

Locate and Use Help Resources in the Linux System Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1

Objective 1 Objective 2 Objective 3

Access and Use man Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Exercise 3-1 Access and Use man Pages . . . . . . . . . . . . . . . . . . 3-8 Use info Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 Exercise 3-2 Access and Use info Pages . . . . . . . . . . . . . . . . . 3-11 Access Release Notes and White Papers . . . . . . . . . . . . . . . . 3-12
Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Howtos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Help for Installed Packages . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 3-3 Access Release Notes and White Papers Pages . 3-12 3-12 3-13 3-14

Objective 4

Use GUI-Based Help in the Linux System . . . . . . . . . . . . . . 3-15


Display the SUSE HelpCenter . . . . . . . . . . . . . . . . . . . . . . . . 3-15 Use Help Commands With Konqueror . . . . . . . . . . . . . . . . . 3-17 Exercise 3-4 Use GUI-Based Help . . . . . . . . . . . . . . . . . . . . . . 3-19

Objective 5

Find Help on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20 Exercise 3-5 Find Help on the Web . . . . . . . . . . . . . . . . . . . . . 3-21 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

TOC-3

SUSE Linux Fundamentals

SECTION 4

Administer Linux with the YaST Management Utility Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1

Objective 1 Objective 2

Get to Know YaST. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 Exercise 4-1 Get to Know YaST . . . . . . . . . . . . . . . . . . . . . . . . 4-5 Manage User Accounts With YaST. . . . . . . . . . . . . . . . . . . . . 4-6
Basics About Users and Groups . . . . . . . . . . . . . . . . . . . . . . . 4-6 User and Group Administration With YaST . . . . . . . . . . . . . . 4-7 Exercise 4-2 Manage User Accounts with YaST . . . . . . . . . . . 4-16

Objective 3

Install a Printer in the Linux System . . . . . . . . . . . . . . . . . . . 4-18


When to Configure a Printer . . . . . . . . . . . . . . . . . . . . . . . . . 4-18 How to Change a Printer Configuration . . . . . . . . . . . . . . . . 4-19 Exercise 4-3 Change Your Printer Configuration . . . . . . . . . . 4-25

Objective 4

Understand the YaST Software Management Feature. . . . . . 4-27


How to Select Software Packages to Install . . . . . . . . . . . . . 4-27 How to Manage Installation Sources . . . . . . . . . . . . . . . . . . . 4-29 Exercise 4-4 Install New Software . . . . . . . . . . . . . . . . . . . . . . 4-32

Objective 5

Obtain Hardware Configuration Information from YaST . . . 4-33 Exercise 4-5 Obtain Hardware Configuration Information . . . 4-34 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35

SECTION 5

Manage Directories and Files in the Linux System Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1

Objective 1

Understand the File System Hierarchy Standard (FHS) . . . . . 5-2


The Hierarchical Structure of the File System . . . . . . . . . . . . . FHS (Filesystem Hierarchy Standard) . . . . . . . . . . . . . . . . . . . Root Directory / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Essential Binaries for Use by All Users (/bin/) . . . . . . . . . . . . Boot Directory (/boot/) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Device Files (/dev/) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 5-4 5-5 5-5 5-6 5-7

TOC-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Contents

Configuration Files (/etc/) . . . . . . . . . . . . . . . . . . . . . . . . . . . User Directories (/home/) . . . . . . . . . . . . . . . . . . . . . . . . . . . Libraries (/lib/) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mountpoints for Removable Media (/media/*) . . . . . . . . . . . Application Directory (/opt/) . . . . . . . . . . . . . . . . . . . . . . . . . Home Directory of the Administrator (/root/) . . . . . . . . . . . . System Binaries (/sbin/) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Directories for Services (/srv/) . . . . . . . . . . . . . . . . . . . Temporary Area (/tmp/) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Hierarchy Below /usr/ . . . . . . . . . . . . . . . . . . . . . . . . . . . Variable Files (/var/) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Process Files (/proc/) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . System Information Directory (/sys/) . . . . . . . . . . . . . . . . . . Mountpoint for Temporarily Mounted File Systems (/mnt/) . Directories for Mounting Other File Systems . . . . . . . . . . . . Exercise 5-1 Explore the SUSE Linux File System Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5-10 5-11 5-12 5-12 5-13 5-13 5-13 5-14 5-14 5-14 5-15 5-16 5-19 5-20 5-20 5-23

Objective 2

Identify File Types in the Linux System . . . . . . . . . . . . . . . . 5-25


Normal Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Device Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FIFOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-25 5-25 5-26 5-26 5-26 5-26 5-27 5-28 5-29 5-30

Objective 3

Change Directories and List Directory Contents . . . . . . . . . . 5-27


ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . cd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 5-2 Change Directories and List Directory Contents.

Objective 4

Create and View Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31


Create a New File with touch . . . . . . . . . . . . . . . . . . . . . . . . . View a File with cat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . View a File with less . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . View a File with head and tail . . . . . . . . . . . . . . . . . . . . . . . . 5-31 5-32 5-32 5-33

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

TOC-5

SUSE Linux Fundamentals

Exercise 5-3 Create and View Files . . . . . . . . . . . . . . . . . . . . . 5-35

Objective 5

Manage Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . 5-37


Copy and Move Files and Directories . . . . . . . . . . . . . . . . . . Exercise 5-4 Copy and Move Files and Directories . . . . . . . . . Create Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 5-5 Create Directories . . . . . . . . . . . . . . . . . . . . . . . . Delete Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 5-6 Delete Files and Directories . . . . . . . . . . . . . . . . Link Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 5-7 Link Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-37 5-40 5-41 5-41 5-42 5-43 5-44 5-47

Objective 6

Find Files on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48


KFind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . locate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . whereis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . which . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 5-8 Find Files on Linux . . . . . . . . . . . . . . . . . . . . . . . 5-48 5-51 5-54 5-56 5-56 5-57 5-58

Objective 7

Search File Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-60


How to Use the Command grep . . . . . . . . . . . . . . . . . . . . . . . 5-60 How to Use Regular Expressions . . . . . . . . . . . . . . . . . . . . . 5-61 Exercise 5-9 Search File Content . . . . . . . . . . . . . . . . . . . . . . . 5-64

Objective 8

Archive, Compress, and Uncompress Files . . . . . . . . . . . . . . 5-65


Archive Files With ark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Archive Files With tar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 5-10 Archive Files . . . . . . . . . . . . . . . . . . . . . . . . . . . Compress With gzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Uncompress Files with gunzip . . . . . . . . . . . . . . . . . . . . . . . . Compress Files With bzip2 . . . . . . . . . . . . . . . . . . . . . . . . . . Uncompress Files With bunzip2 . . . . . . . . . . . . . . . . . . . . . . View Compressed Files With zcat . . . . . . . . . . . . . . . . . . . . . Exercise 5-11 Compress and Uncompress Files with gzip and bzip2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-65 5-67 5-71 5-73 5-74 5-74 5-75 5-75 5-76

TOC-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Contents

Objective 9

Manage File Permissions and Ownership . . . . . . . . . . . . . . . 5-78


Change the File Permissions With chmod . . . . . . . . . . . . . . . 5-78 Change the File Ownership With chown and chgrp . . . . . . . 5-80 Exercise 5-12 Manage File Permissions and Ownership . . . . . 5-82

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-84 SECTION 6 Work With the Linux Shell and Command Line Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1 Objective 1 Get to Know the Command Shells. . . . . . . . . . . . . . . . . . . . . . 6-2
Types of Shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bash Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . File Name Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Completion of Commands and File Names . . . . . . . . . . . . . . . 6-2 6-3 6-5 6-6

Objective 2

Execute Commands at the Command Line . . . . . . . . . . . . . . . 6-7


History Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7 Switch to User root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8 Exercise 6-1 Execute Commands at the Command Line . . . . . 6-10

Objective 3

Get to Know Common Command Line Tasks. . . . . . . . . . . . 6-11


Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11 Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12 Exercise 6-2 Perform Common Command Line Tasks . . . . . . 6-15

Objective 4

Understand Command Syntax and Special Characters . . . . . 6-16


Name Expansion Using Search Patterns . . . . . . . . . . . . . . . . 6-16 Prevent the Shell from Interpreting Special Characters . . . . . 6-17 Exercise 6-3 Work With Command Syntax and Special Characters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19

Objective 5 Objective 6

Use Piping and Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . 6-21 Exercise 6-4 Use Piping and Redirection . . . . . . . . . . . . . . . . . 6-26 Manage User Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27
useradd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

TOC-7

SUSE Linux Fundamentals

passwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . usermod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . userdel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercise 6-5 Manage User Accounts . . . . . . . . . . . . . . . . . . . .

6-31 6-33 6-34 6-35

Objective 7 Objective 8

Execute RPM Package-Related Operations. . . . . . . . . . . . . . 6-37 Exercise 6-6 Execute RPM Package-Related Operations . . . . 6-43 Use the Basic Linux mail Command . . . . . . . . . . . . . . . . . . . 6-44
Read Status Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-44 Use the Simple Mail Client . . . . . . . . . . . . . . . . . . . . . . . . . . 6-45 Exercise 6-7 Send Mail to root . . . . . . . . . . . . . . . . . . . . . . . . . 6-48

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49 SECTION 7 Use Linux Text Editors Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1 Objective 1 Objective 2 Get to Know Linux Text Editors . . . . . . . . . . . . . . . . . . . . . . . 7-2 Use Command Line Editors to Edit Files in the Linux System 7-3
Start vi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Use the Editor vi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Get to Know the Working Modes . . . . . . . . . . . . . . . . . . . . . . Exercise 7-1 Use Command Line Editors to Edit Files in the Linux System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 7-4 7-5 7-8

Objective 3

Use Desktop Editors to Edit Files in the Linux System. . . . . 7-10 Exercise 7-2 Use Desktop Editors to Edit Files
in the Linux System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14

TOC-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Contents

SECTION 8

Understand and View Processes in the Linux System Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2

Objective 1

View Processes from the GUI and the Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
View Processes from the GUI . . . . . . . . . . . . . . . . . . . . . . . . . 8-3 View Processes from the Command Line Interface . . . . . . . . 8-5 Exercise 8-1 View Processes from the GUI and the Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14

Objective 2

Understand the Runlevel Concept . . . . . . . . . . . . . . . . . . . . . 8-16


The init Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16 The Runlevels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16 Exercise 8-2 Work With Runlevels . . . . . . . . . . . . . . . . . . . . . 8-20

Objective 3

Multitask in the Linux System . . . . . . . . . . . . . . . . . . . . . . . . 8-21


System Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-21 Jobs of Individual Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-22 Exercise 8-3 View crontab Processes . . . . . . . . . . . . . . . . . . . . 8-23

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-24 SECTION 9 Manage the Network Conguration Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 Objective 1 Manage the Network Configuration Information from YaST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 Exercise 9-1 Manage the Network Configuration
Information from YaST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12

Objective 2

Get to Know Network-Related Command Line

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

TOC-9

SUSE Linux Fundamentals

Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Determine Connectivity Between Hosts Using ping . . . . . . . List Currently Active Network Connections With netstat . . . Display the Route Between Hosts With traceroute . . . . . . . . Update Network Interfaces Configuration Using ifup and ifdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Display the Routing Table Using route . . . . . . . . . . . . . . . . . Exercise 9-2 Use Network-Related Commands . . . . . . . . . . . . 9-14 9-17 9-20 9-23 9-26 9-28

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-29 Appendix A Index Novell CLP and LPI Requirements

TOC-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Introduction

Introduction

In the SUSE Linux Fundamentals (3036) course, you learn the basic Linux skills necessary to prepare you for performing SUSE Linux Enterprise Server 9 (SLES 9) administrative tasks. These skills, along with those taught in the SUSE Linux Administration (3037) and SUSE Linux Advanced Administration (3038) courses, prepare you to take the Novell Certied Linux Professional (Novell CLP) certication practicum test. The contents of your student kit include the following:

SUSE Linux Fundamentals Manual SUSE Linux Fundamentals Course CD SLES 9 VMware Server DVD SUSE Linux Enterprise Server 9 CDs (CD 1 CD 6)

The SLES 9 VMware Server DVD contains a VMware Workstation SLES 9 server that you can use with the SUSE Linux Fundamentals Self-Study Workbook (in PDF format on your Course CD) outside the classroom to practice the skills you need to prepare for the 3037 Course.

Instructions for setting up a self-study environment are included in the SUSE Linux Fundamentals Self-Study Workbook. If you do not own a copy of VMware Workstation, you can obtain a 30-day evaluation version at www.vmware.com. If you want to dedicate a machine to install SLES 9, instructions are also provided in the Self-Study Workbook.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Intro-1

SUSE Linux Fundamentals

Course Objectives
This course teaches you the following concepts and skills fundamental to understanding SLES 9:

Understand the Linux story Use the Linux desktop Locate and use Help resources in the Linux system Administer Linux with the YaST management utility Manage Directories and Files in the Linux System Work with the Linux shell and command line Use Linux text editors Understand and view processes in the Linux system Manage the network configuration

These are fundamental and prerequisite to learning the skills of an entry level SUSE Linux administrator or help desk technician in an enterprise environment.

Audience
While the primary audience for this course is the current Novell CNESM, certication candidates with experience in other operating systems can also use this course to begin preparing for the Novell CLP Practicum.

Intro-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Introduction

Certication and Prerequisites


This course helps you prepare for the Novell Certied Linux Professional (Novell CLP) Practical Test, called a practicum. The Novell CLP is an entry-level certication for people interested in becoming SUSE Linux administrators. As with all Novell certications, course work is never required. You only need only pass a Novell CLP Practicum (050-689) in order to achieve the certication. The Novell CLP Practicum is a hands-on, scenario-based exam where you apply the knowledge you have learned to solve real-life problemsdemonstrating that you know what to do and how to do it. The practicum tests you on objectives in this course (SUSE Linux Fundamentals - Course 3036) and the skills outlined in the following Novell CLP courses:

SUSE Linux Administration - Course 3037 SUSE Linux Advanced Administration - Course 3038

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Intro-3

SUSE Linux Fundamentals

The following illustrates the training/testing path for Novell CLP: Figure Intro-1
Novell Certified Linux Professional (Novell CLP): Training/Testing Path

New to Linux Administration

SUSE LINUX Fundamentals


(Course 3036)
(Training opportunity)*

SUSE LINUX Administration


(Course 3037)
(Training opportunity)*

SUSE LINUX Advanced Administration


(Course 3038) (Training opportunity)*

Advanced Linux Administrators


(Previous Linux certifications)

Novell Practicum: 050-689 Novell CLP


(Required Practical Exam)

Migrating to SUSE LINUX


(Course 3019)
(Training opportunity)*

Novell Certified Linux Professional

*Courses are not required for Novell CLP certification. Passing the Novell Practicum (050-689) is required.

Intro-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Introduction

Before attending this course, we recommend that you have some experience working with a Linux desktop or server in a computing environment (such as an enterprise or academic environment).

For more information about Novell certication programs and taking the Novell CLP Practicum, see http://www.novell.com/education/certinfo.

SLES 9 Support and Maintenance


The copy of SUSE Linux Enterprise Server 9 (SLES 9) you receive in your student kit is a fully functioning copy of the SLES 9 product. However, to receive ofcial support and maintenance updates, you need to do one of the following:

Register for a free registration/serial code that provides you with 30 days of support and maintenance. Purchase a copy of SLES 9 from Novell (or an authorized dealer).

You can obtain your free 30-day support and maintenance code at http://www.novell.com/products/linuxenterpriseserver/eval.html.

You will need to have or create a Novell login account to access the 30-day evaluation.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Intro-5

SUSE Linux Fundamentals

SLES 9 Online Resources


Novell provides a variety of online resources to help you congure and implement SLES 9. These include the following:

http://www.novell.com/products/linuxenterpriseserver/ This is the Novell home page for SLES 9.

http://www.novell.com/documentation/sles9/index.html This is the Novell Documentation web site for SLES 9.

http://support.novell.com/linux/ This is the home page for all Novell Linux support, and includes links to support options such as the Knowledgebase, downloads, and FAQs.

http://www.novell.com/coolsolutions

This Novell web site provides the latest implementation guidelines and suggestions from Novell on a variety of products, including SUSE Linux.

Intro-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Introduction

Agenda
The following is the agenda for this 3-day course: Table Intro-1
Day 1 Section Introduction Section 1: Understand the Linux Story Section 2: Use the Linux Desktop Section 3: Locate and Use Help Resources in the Linux System Day 2 Section 4: Administer Linux with the YaST Management Utility Section 5: Manage Directories and Files in the Linux System Day 3 Section 6: Work with the Linux Shell and Command Line Section 7: Use Linux Text Editors Section 8: Understand and View Processes in the Linux System Section 9: Manage the Network Conguration Duration 00:30 02:00 02:00 01:30

02:00

03:30

2:30

00:30 01:00

01:00

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Intro-7

SUSE Linux Fundamentals

Scenario
You are system administrator for your Digital Airlines ofce. The management is considering migration of some network services to SLES 9 servers. As system administrator, you decide to do the following:

Install SLES 9 on a test workstation. Become familiar with the graphical user interface and the command line interface. Learn how to get help for all problems you might have. Learn how to manage users and software packages with the configuration tool YaST2 and at the command line. Understand the structure of the Linux file system and basic shell commands for working in the file system (e.g. copying, moving, archiving files). Learn how to edit configuration files with an graphical editor or the command line editor vi. Discover the most important tools for checking your network connection.

Once you complete this training, you will be able to install SLES 9 and set up a system for further tests.

Intro-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Introduction

Exercise Conventions
When working through an exercise, you will see conventions that indicate information you need to enter that is specic to your server. The following describes the most common conventions:

italicized/bolded text. This is a reference to your unique situation, such as the host name of your server. For example, if the host name of your server is DA50, and you see the following, hostname.digitalairlines.com you would enter DA50.digitalairlines.com

10.0.0.xx. This is the IP address that is assigned to your SLES 9 server. For example, if your IP address is 10.0.0.50, and you see the following 10.0.0.xx you would enter 10.0.0.50

Select. The word select is used in exercise steps to indicate a variety of actions including clicking a button on the interface and selecting a menu item. Enter and Type. The words enter and type have distinct meanings. The word enter means to type text in a eld or at a command line and press the Enter key when necessary. The word type means to type text without pressing the Enter key. If you are directed to type a value, make sure you do not press the Enter key or you might activate a process that you are not ready to start.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Intro-9

SUSE Linux Fundamentals

Intro-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

SECTION 1

Understand the Linux Story

This section provides background information about Linux and guides you through an installation of SLES 9.

Objectives
1. 2. 3. 4.

The History of Linux Identify the Components of SLES 9 Understand the Multiuser Environment Perform a Simple Installation of SLES 9

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-1

SUSE Linux Fundamentals

Objective 1

The History of Linux


Linux is closely related to the UNIX operating system. To understand the history of Linux, you need to know the following:

The Historical Development of UNIX The Development of Linux The Software Differences Between SUSE Linux and SUSE Linux Enterprise Server

The Historical Development of UNIX


At the end of the 1960s, most operating systems were only designed for batch operations. If you wanted to run a program, you inserted a pile of punch cards or a roll of perforated strips into a reading device and waited until the result was sent to a printer. If there was an error in the program or if you did not get the required result, you had to rewrite the perforated roll or replace one or several punch cards, reread the stack, and again wait for the result. This procedure was not only long-winded, but also inefcient which led computer developers to look for a way to allow a number of users to simultaneously use a dialog-oriented way of working with the system. MULTICS was one of the rst programs created to meet this demand. It allowed you to work in a dialog with the computer, but it was still very strongly inuenced by the batch operation, and it was difcult to operate. In 1969, one of the MULTICS developers, Ken Thompson, began creating an operating system that, apart from a dialog-oriented operation, aimed to provide a high functionality and structural simplicity.

1-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

The rst version of UNIX was written in Assembler, a programming language close to the machine-level. To be machine-independent in its further development, UNIX was rewritten in 1971 in the programming language C, developed by Dennis Ritchie. Because Bell Laboratories (a subsidiary company of AT&T) provided documentation and the source text of UNIX to universities almost at cost, the system spread relatively quickly. The simple operation of the system, the almost unlimited availability of the source text, and its relative portability motivated many users and companies to become actively engaged in the development, so functionalities were very quickly added to UNIX and it reached a very high level of maturity. At the same time, a series of commercial UNIX derivatives arose including versions from IBM, DEC, and HP (HP-UX, 1982), as well as BSD UNIX (Berkeley Software Distribution, 1978), developed by the University of California in Berkeley. In 1983, AT&T began marketing UNIX System V commercially via its sister company USL, proclaiming System V as the UNIX standard. As a consequence of this, the licensing of UNIX changed considerably, leading, among other things, to a long-lasting legal battle with BSD. At the same time, with never-ending quarrels between UNIX vendors, a genuine standardization of the UNIX operating system family was prevented. Modern UNIX operating systems can still be separated as either more System V or more BSD types, although there are no pure systems of one or the other kind. Linux tries to combine the best from both worlds.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-3

SUSE Linux Fundamentals

Because Linux is written in C, it is available for a lot of different hardware platforms, including the following:

i386: 32 bit Intel/AMD: 64 bit PowerPC (Macintosh, RS/6000) SPARC (Sun) IBM pSeries IBM zSeries (S/390) Embedded

The Development of Linux


In the spring of 1991, the Finnish student Linus Benedict Torvalds began to take a closer look at the memory management of his 386 PC.

1-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

A few months later he had developed a rudimentary kernel which he passed on as a source text to others who were interested via the Internet with the following message:
From: [email protected] (Linus Benedict Torvalds) Newsgroups: comp.os.minix Subject: What would you like to see most in minix? Summary: small poll for my new operating system Message-ID: <[email protected]> Date: 25 Aug 91 20:57:08 GMT Organization: University of Helsinki Hello everybody out there using minix I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready. I'd like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) among other things). I've currently ported bash(1.08) and gcc(1.40), and things seem to work. This implies that I'll get something practical within a few months, and I'd like to know what features most people would want. Any suggestions are welcome, but I won't promise I'll implement them :-) Linus ([email protected]) PS. Yes - it's free of any minix code, and it has a multi-threaded fs. It is NOT portable (uses 386 task switching etc), and it probably never will support anything other than AT-harddisks, as that's all I have :-(.

Linus Torvalds made the source code of his Linux kernel available with the GPL (GNU General Public License). The GPL allows everyone to read and edit the source code. The GPL license also requires any edited source code to be made available to the public.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-5

SUSE Linux Fundamentals

Linux rapidly developed into a project involving many people, although the development of the system's core (Linux kernel) is still coordinated by Linus Torvalds. All kernel modications are integrated by him. The functions of the kernel include input and output control, device control, process management, and le management. Other system components (shell utilities, network programs, and implementations of the kernel for non-Intel processors) are looked after by other people or groups. As a rule, there are two current versions of Linux development: a stable one, identiable by an even number after the rst dot, and developer versions identied by an odd number. Linux distributionsconsisting of the Linux kernel, applications (such as ofce packages, databases, and network services), and manualsare based on the even-numbered versions, but they often provide current development kernels, which, under certain circumstances, are needed for the integration of new hardware components.

The Software Differences Between SUSE Linux and SUSE Linux Enterprise Server
SUSE Linux Enterprise Server (SLES) is based on the SUSE Linux Professional distribution. The time between release of the Professional distribution and release of SLES is used for intensive testing and applying patches which improve security and stability of the system. Additionally, SLES contains some features which will be made available in future versions of the Professional distribution.

1-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

The following illustrates the relationships between open source code, SUSE Linux Professional and SUSE Linux Enterprise Server: Figure 1-1

SUSE Linux Enterprise Server 9 has fewer packages (about 1,000) than the SUSE Linux Professional distribution (about 3,500). Most packages that have been removed are server applications. SLES has a guaranteed life cycle of 5 years. During this time, you are provided patches and xes that help you maintain SLES. In addition, you can choose from a range of support offers. Only the SLES product is certied by independent hardware and software vendors.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-7

SUSE Linux Fundamentals

Objective 2

Identify the Components of SLES 9


SUSE Linux Enterprise Server 9 has several new and improved features, including the following:

Updated Core System with Latest Versions/Features of All Packages New and Improved YaST Modules Next Generation Linux Kernel 2.6.5 Improved High Availability Support Full Enablement and Support of UTF-8 Inclusion of Red Carpet Enterprise Daemon New Type of Installation Source: SLP POSIX-Compliant, High-Performance Threads Support (NPTL)

Updated Core System with Latest Versions/Features of All Packages


The following are updated core system features and versions:

SUSE Linux Kernel (version 2.6.5) Main C library (glibc 2.3.3) GNU compiler collection (GCC 3.3.3) XFree X11 graphical user interface (XFree 4.3.99) KDE Desktop Environment (3.2.1) GNOME Desktop Environment (2.4.2) File, print, and other services for Windows (Samba 3.0.4) Apache web server version 2.x (Apache 2.0.49) Domain name server (BIND 9.2.3)

1-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

New and Improved YaST Modules


YaST is the installation and administration tool for SLES 9. It includes the following improvements:

New YaST license (GPL) New/improved installation methods (NFS, HTTP, FTP, VNC, ssh, SLP) New/improved configuration modules (such as DNS)

Next Generation Linux Kernel 2.6.5


Linux kernel 2.6.5 includes several improvements over the 2.4.x kernel versions, such as the following:

Performance Improved hyper threading (one processor can handle more processes at the same time) and NUMA (Non-Uniform Memory Access) support (memory architecture for multi-processor systems) Full enablement and support of UTF-8 Better support of big SMP (symmetric multiprocessing) systems Fine granular locking to boosts parallel execution Multiple kernel tuning parameters (like I/O scheduler) Scalability Support for more than 64 CPUs Support for thousands of devices/disks (64bit major/minor) Improved block I/O layer Improved network stack with IPv6, IPSEC, and Mobile IPv6 Hotplug support (SCSI, USB, Firewire, PCI, CPU)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-9

SUSE Linux Fundamentals

Persistent device names and unified device handling Class-based kernel resource management (CKRM) ACPI improvements (such as suspend to disk/RAM) Infiniband support (high-speed serial computer bus)

Improved High Availability Support


The following are high availability supported features:

Cluster volume manager (EVMS) Cluster IP alias Lustre Cluster file system

Full Enablement and Support of UTF-8


SLES 9 is ready for support of Asian characters and fonts with UTF-8 support which includes translations and commercial fonts.

Inclusion of Red Carpet Enterprise Daemon


SLES 9 includes the Red Carpet daemon.

New Type of Installation Source: SLP


SLES 9 now supports a Service Location Protocol (SLP) installation source, and can send an SLP request for service install.suse to the network and prompt you to select an entry from the list of returned URLs.

1-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

POSIX-Compliant, High-Performance Threads Support (NPTL)


SLES 9 features a new thread implementation called NPTL, which is faster and better than the old implementation (called linuxthreads).

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-11

SUSE Linux Fundamentals

Objective 3

Understand the Multiuser Environment


One of the goals of UNIX was to enable a number of users to use the system simultaneously (multiuser capability). Because several users might also want to use several different programs simultaneously, mechanisms must be available to allow these programs to run simultaneously (multitasking capability). The implementation of a multiuser and multitasking system appears to be simultaneous in a single processor system, but this is only possible in a multiprocessor system. Even in a single-processor system, advantages can be gained through multitasking because waiting times for input or output from other processes can be used. UNIX implements preemptive multitaskingeach process is allowed a maximum time with which it can work. When this time has expired, the operating system takes away processor time away from the process and gives it to another process waiting to run. Other operating systems (such as versions older than the MAC OS version X) do not intervene in this process cycle. Instead, control over the processor must be released by the running process before another process can run. This can lead to one process hijacking the processor, leaving other processes without processing time and blocking the system. The operating system coordinates access to the resources available in the system (hard drives, tapes, interfaces). If there is competition among processes for access to a tape device, only one process can be granted access. The others must be rejected.

1-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

This coordination task is very complex and no operating system is able to implement an ideal solution. The classic problem involves a situation in which 2 or more processes exclusively need the same resources, as illustrated in the following resource conict: Figure 1-2

A
Access

Request

B
Access

R1

R2

The following describes the resource conict:


Process A needs resources R1 and R2. Process B needs resources R2 and R1. Process A has received access to R1 and would now also like access to R2. In the meantime, however, B has already gained access to R2 and, in turn, would like access to R1 as well. If these two processes now wait until what they need is available, nothing more will happens-they are deadlock.

Multithreading is an extension of multitasking, and helps solve this problem.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-13

SUSE Linux Fundamentals

In multithreading, a number of parts independent from one another (threads) can be produced within a process. Multithreading increases the level of parallel processes with each thread needing to be administered, which makes the use of a multiprocessor system more valuable. A clear distinction should be made here between programs and processes: as a rule, a program exists only once in the system, but there can be several processes that perform the same program. If a number of users are active, both programs and processes can be used independently of one another (such as a program used to display directories).

1-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

Objective 4

Perform a Simple Installation of SLES 9


The process of installing the SUSE Linux Enterprise Server 9 can be divided into the following steps:

Pre-Installation Requirements and Guidelines Installation Options Basic Installation Manual Software Selection Configuration

Pre-Installation Requirements and Guidelines


The following are basic system requirements for SLES 9:

Minimum system requirements for operation:


256 MB RAM 500 MB hard disk space for software 500 MB hard disk space for user data 512 MB to 3 GB RAM, at least 256 MB per CPU 4 GB hard disk space Network interface (Ethernet or modem)

Recommended system requirements:


After installing SLES 9, some system congurations can be hard to change. In order to make sure you are prepared to install SLES 9 with the conguration settings you need, you should consider the following:

Hardware compatibility. SUSE Linux Enterprise Server 9 supports most enterprise hardware for servers. It also supports hardware for desktops. Some laptop computer hardware might not be compatible with SUSE Linux Enterprise Server 9.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-15

SUSE Linux Fundamentals

To verify that your hardware is compatible with SUSE Linux Enterprise Server 9, you can use the following web site: http://www.novell.com/partnerguide/section/481.html

File system types. SUSE Linux Enterprise Server 9 supports various file system types. Make sure you select the le system type that is right for your particular needs and requirements. For details on le system types, see Section 3 Select a Linux File System on 3-2.

Partitioning scheme. Make sure you plan for the appropriate partitions and partition sizes before starting your installation (if you are using traditional instead of virtual partitions). Modifying partition sizes after installation can be impossible or difcult to achieve. Its also easier to congure Software RAID or LVM during installation. This is especially true of conguring the root le system.

Software package selection. Although you can install software packages after installation, it can be easier to decide ahead of time which packages you want installed and do the configuration during SUSE Linux installation.
To increase the security of your system, make sure you install only required services on your computer.

Dual-boot system. If you plan on installing a dual-boot system on your computer (with SUSE Linux Enterprise Server 9 as one of the systems), it is often better to install SUSE Linux Enterprise Server 9 first.

1-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

For example, if you install SUSE Linux Enterprise Server 9, and then install a Windows operating system, SUSE Linux recognizes the Windows operating system and automatically provides a dual boot screen after installing Windows.

Installation Options
When you boot your computer from the installation CD, the following welcome screen appears: Figure 1-3

You can choose the installation option you want to use or you can wait. If you do not choose an option within 20 seconds, the rst entry in the list (Boot from Hard Disk) is chosen automatically. To stop this countdown, simply press the Tab key once.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-17

SUSE Linux Fundamentals

The following are the most important options on the welcome screen:

Boot from Hard Disk: Boots the standard operating system installed on your hard disk. Installation: Starts the normal installation process. Installation - ACPI Disabled: Some old computers don't have ACPI power management. This can lead to problems during the installation. With this kind of installation, you can disable the ACPI features of SUSE Linux Enterprise Server 9. Installation - Safe Settings: Some older computers don't have any kind of power management or hard disk acceleration. If you have problems with your installation, you should try this. Manual Installation: All automatic features of YaST (such as hardware detection) are disabled. You configure everything manually. Rescue System: A minimal Linux system (without a graphical user interface) starts from the CD and lets you repair the Linux installation on the hard disk. Memory Test: Tests the RAM for physical errors.

When you select an installation option and press Enter, the installation program (YaST) starts.

1-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

Basic Installation
Before you can install SLES 9, you must read and accept the following Novell Software License Agreement by selecting I Agree: Figure 1-4

After you accept the software license agreement, YaST asks you for the language to be used during the installation process. Select your language and select Accept.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-19

SUSE Linux Fundamentals

If you have Linux already installed on your computer, the following dialog appears: Figure 1-5

From this dialog, you can do the following:

Install SUSE Linux Enterprise Server 9 by selecting New installation Update an existing system by selecting Update an existing system Repair an installed System by selecting Repair Installed System Boot an installed system by selecting Boot installed system Abort the installation by selecting Abort installation

1-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

After selecting the OK button, YaST displays the following information about your hardware and makes suggestions for the installation: Figure 1-6

You can change these settings by selecting the headline of each of the sections or by using the Change menu. The following sections are available:

System: Lists details about your hardware. Mode: Lists the available installation modes. Keyboard layout: Identifies the layout of your keyboard. Mouse: Identifies your mouse type. Partitioning: Lets you create and change the partitioning table of your hard disk. If you have free space on your hard disk, the configuration program tries to use it for the installation.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-21

SUSE Linux Fundamentals

If a Windows partition exists, YaST tries to resize it. An existing Linux Partition is overwritten. In any case, you should make a backup of still needed partitions.

Software: Lets you select the software to be installed (see the following section). Booting: Lets you install and configure the GRUB boot loader. Time zone: Lets you select your time zone. Language: Lets you select the default language for your installation. Default Runlevel: Lets you select your default runlevel for SLES 9. Runlevels are different modes your system can work in. Runlevel 5 offers full networking capabilities and starts the graphical user interface.

Normally you do not need to change the recommendations made by YaST. If you already have another operating system installed on the computer, but your hard drive has free, unpartitioned space left, YaST automatically recommends installing SLES 9 in that free space and creating a dual boot conguration for both operating systems. After selecting Accept, you need to conrm your settings again. Selecting Yes, install starts the installation process. The installation can take some time, depending on your hardware.

1-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

Manual Software Selection


If you want to install software which is not included in the default installation, select the Change drop-down list and select Software. The following dialog appears: Figure 1-7

You can select one of the following:

Minimum system. Installs a minimum SUSE Linux configuration without a graphical system Minimum graphical system (without KDE). Installs a standard software selection but with limited graphical capabilities. Instead of the powerful KDE or GNOME environments, only the basic window manager fvwm2 is installed.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-23

SUSE Linux Fundamentals

Full Installation. Installs most packages available on the SUSE Linux Enterprise Server CDs. Default system. Installs a standard software selection, including KDE as desktop environment.

If you want to select individual packages, you can select Detailed selection. The following dialog appears: Figure 1-8

SUSE Linux Enterprise Server contains a broad range of software. When selecting individual packages, you can use different lters to display the available software packages. These lters are available from the drop-down list in the top left corner and include the following:

Selections: Displays only the installed packages. Package Groups: Displays all software packages that are available on the known installation media.

1-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

Search: Lets you enter a search term and select where you want YaST to search. Installation Summary: Displays all the packages with the marked status.

Enter the full package name, part of the name, or keywords in the Search text eld and select Search. The results are listed in the right window. The installation state is shown by a small symbol in front of the package name. The most important symbols are shown in the following (view a complete list by selecting Help > Symbols): Figure 1-9

Select the symbol of the package you want to install until the install symbol appears; then select Accept. You might see a dialog indicating that the dependencies between the packages cannot be resolved and that some other packages need to be installed, too. In most cases, you can simply conrm this dialog. If the wrong CD is in your drive, a warning appears.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-25

SUSE Linux Fundamentals

Conguration
During the conguration phase of the installation, you congure the following:

Root Password Network Devices Services Users Hardware

Root Password

If the installation was successful, the computer reboots. YaST starts again because you need to congure some basic settings.

1-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

First you need to specify the password for the administrator root in the following dialog: Figure 1-10

Warnings appear if the selected password is too simple.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-27

SUSE Linux Fundamentals

Network Devices

After you have specied a password, you need to review your network conguration. YaST displays a summary the network devices it has discovered: Figure 1-11

The following are types of network devices displayed:


Network interfaces DSL connections ISDN adapters Modems

By default YaST selects the DHCP conguration for the network interfaces. You can change the network conguration by selecting the headline of the section or by using the Change menu.

1-28

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

In the next dialog, you can test your Internet connection: Figure 1-12

If you select Yes, Test Connection to the Internet, the latest release notes will be downloaded and YaST will check for new updates. If new updates are found, YaST asks you to verify the download and installation. You should apply any updates to ensure your new system has the latest patches applied.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-29

SUSE Linux Fundamentals

Services

In the next dialog you can congure two very important services: Figure 1-13

These services include the following:

CA Management: The purpose of a CA (Certificate Authority) is to guarantee a trust relationship among all network services communicating with each other. OpenLDAP Server: You run an LDAP server on your host to provide a central facility managing a range of configuration files. Typically, an LDAP server handles user account data, but with SUSE Linux Enterprise Server, it is also used for mail-, DHCP-, and DNS-related data.

1-30

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

If you decide against the use of an LDAP server, the YaST mail server module will not work because it depends on LDAP functionality. Nevertheless, you can still set up a mail server on your system with the help of the Mail Transfer Agent module. By default, a CA is created and an LDAP server is set up during the installation.

Users

After you congure the services, you congure user authentication. First, select the authentication method you want to use: Figure 1-14

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-31

SUSE Linux Fundamentals

Three different methods are available:

NIS: User account data is managed centrally by a NIS server. NIS can only be used in pure UNIX environments. LDAP: User account data is managed centrally by an LDAP server. Users must be authenticated via LDAP if you are working in a network environment that has both UNIX and Windows computers. Local (/etc/passwd): This setup is used for systems where no network connection is available or where users are not supposed to log in from a remote location at all. User accounts are managed using the local file /etc/passwd.

The next dialog displayed depends on your chosen authentication method. If you select the LDAP authentication method (the default) and select Next, you need to specify the LDAP client conguration: Figure 1-15

1-32

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

x
Figure 1-16

We won't use LDAP authentication in this course. The topic is covered in the SUSE Linux Advanced Administration course (3038). In this course only the local authentication is explained.

If you choose Local (/etc/passwd) and select Next, the following dialog appears:

To add a user, you need to provide the following information:


Full User Name: The complete name of the user. User Login: The login name of the user. This name must be unique on the system. Password: The case-sensitive login password for the user. You have to enter the password twice for verification. For security reasons, the letters of the password are shown as stars. YaST displays warnings if the password is insecure.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-33

SUSE Linux Fundamentals

If you want the user to receive automatically generated email for root, then select Receive System Mail. If you use your Linux computer only at your own desk and you want to avoid the login during the startup, select Auto Login option.

For security reasons, we recommended that you deselect this option.

After setting up one or more users, the system information is written to disk. YaST opens a window with the release notes. Go to the last step of the installation by selecting Next.

1-34

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

Hardware

At this point, the nal conguration dialog appears (hardware conguration): Figure 1-17

From this dialog you congure additional hardware items such as the following:

Graphics cards Printers Sound cards

YaST congures the graphics card and the sound card automatically. YaST also detects most printers automatically. Conrm the settings and write them to the system by selecting Next.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-35

SUSE Linux Fundamentals

The last dialog tells you that the installation was successful. Select the Finish button. SUSE Linux Enterprise Server 9 is now ready for use.

1-36

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

Exercise 1-1

Install SUSE Linux Enterprise Server 9


To install SUSE Linux Enterprise Server 9, do the following:
1. 2. 3. 4.

Insert SLES 9 CD 1 into your CD drive. Reboot your computer. From the installation menu, select Installation. From the Novell Software License Agreement dialog, select I Agree. From the language dialog, select English (US); then select Accept. Select New installation; then select OK. Verify that the correct keyboard layout is selected in the section Keyboard layout. (Conditional) If the correct keyboard layout is not selected, from the Change drop-down list select Keyboard layout; then select the correct layout and select Accept. From the Change drop-down list, select Software. select Selections.

5.

6. 7.

8.

9.

10. Select Detailed selection; then from the Filter drop-down list 11. In the left window, select GNOME system; then select Accept. 12. Confirm the YaST installation suggestions by selecting Accept. 13. Confirm the installation settings by selecting Yes, install. 14. (Conditional) If YaST indicates that another installation CD is

needed, insert the correct CD. After copying les and nishing a basic installation, YaST reboots your computer to a Password for root dialog.
15. Specify the root password by entering novell (twice); then select

Next.
16. Confirm the 2 warning messages by selecting Yes.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-37

SUSE Linux Fundamentals

You should use an insecure password (such as novell) only for the purpose of training. Choose a more secure password on a live system.
17. Confirm the suggestions of YaST's network configuration by

selecting Next.
18. Select Yes, Test Connection to the Internet; then test your

Internet connection by selecting Next.


19. Do one of the following:

If the connection test fails (you see a failed message for the release notes), select OK. or If the connection test is successful, select Next.

20. Do not install the updates found by selecting No, Skip Update;

then select OK.

You should install the updates on production systems. You do not install the updates during training because the updates might change menus and user interfaces.
21. In the Service Configuration dialog, make sure that Use

Following Configuration; then select Next.


22. In the User Authentication Method dialog, select Local

(/etc/passwd); then select Next.


23. Add a local user by entering the following:

Full Name: Geeko Novell User Login: geeko Password: N0v3ll (use zero, not an uppercase o) Verify Password: N0v3ll

24. When you finish, select Next.

YaST begins conguring your SLES 9 system.

1-38

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

25. Confirm the release notes by selecting Next. 26. Accept the default hardware configuration by selecting Next. 27. When the installation is complete, select Finish.

The GUI login screen appears. This is where you need to be to start the next exercise.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-39

SUSE Linux Fundamentals

Summary
Objective
1. The History of Linux

Summary The development of UNIX started in the sixties. UNIX comprises two main development lines: System V and BSD. The development of Linux was launched in 1991 by Linus Benedict Torvalds.

2. Identify the Components of SLES


9

SUSE Linux Enterprise Server 9 provides advantages in the following areas:

Latest versions/features of all packages New and improved YAST modules Next generation 2.6.5 Linux kernel Improved HA (high-availability) support Full enablement and support of UTF-8 Inclusion of Red Carpet Enterprise daemon New type of installation source: SLP POSIX-compliant, high-performance thread support (NPTL)

1-40

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand the Linux Story

Objective
3. Understand the Multiuser
Environment

Summary Linux is a multitasking system; in other words, the processes seem to be executed concurrently. An important task of the operating system is to coordinate access to the resources available in the system. Multithreading is an extension of multitasking. Here, within a process, a number of parts independent from one another (threads) can be produced. A program exists only once in the system, but there can be several processes using the same program at the same time.

4. Perform a Simple Installation of


SLES 9

The process of installing the SUSE Linux Enterprise Server 9 can be divided into the following steps:

Choose the installation option Basic installation Conguration

The most important installation options are


Installation Installation - ACPI Disabled Installation - Safe Settings

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

1-41

SUSE Linux Fundamentals

1-42

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

SECTION 2

Use the Linux Desktop

This section gives an overview of 2 different graphical user interfaces of SLES and explains how to access the command line.

Objectives
1. 2. 3. 4.

Overview of the Linux Desktop Use the KDE Desktop Environment Use the Gnome Desktop Environment Access the Command Line Interface From the Desktop

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-1

SUSE Linux Fundamentals

Introduction
You cannot install Windows without its graphical user interface (GUI). In Linux, the GUI is a normal application that you can choose whether or not to install. Most services in Linux can be congured by editing an ASCII text le, so you do not need a GUI if you want your computer to act only as a server. Not installing a graphical user interface has the following advantages:

Stability. Every program contains errors that can make your system unstable. The fewer programs are installed, the more stable your system will be. A graphical user front end is a large program and that might contain a large number of undiscovered programming errors, even if the error ratio is low. Performance. Every running program needs system resources. Fewer programs running on your computer means increased performance.

2-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

Objective 1

Overview of the Linux Desktop


The base of any graphical user interface is the X Window System (simply called X or X11). It allows you to control the input and output of several applications in different windows of a graphical interface. You need to distinguish here between graphical applications, which run in their own windows, and text-based applications, which are carried out in a terminal window. The X Window System was created in 1984 at MIT (Massachusetts Institute of Technology). The aim of the development was to be able to use graphical applications across a network, independent of hardware. The X Window System allows graphical applications to be displayed and operated on any monitor, without running the applications on the machines to which these monitors are connected. The basis for this is the separation into a server component (X server) and the application itself (client application). The X server and client application communicate with each other by way of various communication channels.

X server. The X server controls the graphical screen. This corresponds roughly to what would be called a graphics driver on other systems. In addition, it manages the input devices, such as keyboard and mouse, and transmits their actions to the X client. The X server, however, has nothing to do with the appearance of the window and the desktop; this is the task of the window manager. XFree86 3.3.x and its successor XFree86 4.x are free implementations of the X server. SUSE Linux Enterprise Server defaults to using XFree86 4.x.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-3

SUSE Linux Fundamentals

Client application. The client application is a graphical application that uses the services of the X server to receive keyboard and mouse actions and to have its own output displayed on the screen.

The communication between X server and X client uses the network protocol TCP/IPeven if the server and client run on the same computer.

Window managers are specialized client applications. A window manager works together with the X server and provides additional functionality. The window manager

Provides control elements Manages virtual desktops Provides functionality of window frames (for example, changing their size)

The X Window System is not linked to any specic window manager and thus it is not linked to any particular look and feel. SUSE Linux Enterprise Server is currently released with several window managers, including kwin (the KDE window manager) and twm (Tab Window Manager). Desktop environments go far beyond the look and feel window managers provide for desktops and manipulating windows. The aim is to provide clients with a unied look and feel. KDE is the standard graphical desktop for SUSE Linux Enterprise Server, but you can install the GNOME desktop instead.

2-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

As can be seen in the following gure, the X server is running on computer da5, while the X applications are running on computers da1 and da2: Figure 2-1
da1 Network da2

X Application da1

da5 X Server

X Application da2

The display of the client applications, however, is performed by the X server on the machine da5. All of these computers can be running different operating systems.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-5

SUSE Linux Fundamentals

Objective 2

Use the KDE Desktop Environment


One of the most used graphical desktop environments is KDE. This desktop environment is installed by default during the installation of SUSE Linux Enterprise Server. The following explain how to use KDE on SUSE Linux Enterprise Server:

How to Log In How to Log Out How to Shut Down and Reboot the Linux System How to Identify KDE Desktop Components How to Manage Icons in the KDE Environment How to Use the Konqueror File Manager

How to Log In
If computer users want to work with a multiuser-capable operating system, they must rst identify themselves to the operating system. For this purpose, they need

A login string or username A password (usually assigned by the system administrator when a new user is added)

2-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

When the computer is booted and ready for work, the following login dialog appears: Figure 2-2

After entering a username and password, select Login. If the login is successful, the following KDE desktop environment appears:

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-7

SUSE Linux Fundamentals

The following Welcome dialog appears: Figure 2-3

You can read the information or just close the window by selecting the X button in the top right corner of the window: Figure 2-4

2-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

How to Log Out


When you are ready to log out of the system, open the KDE menu by selecting the rst (left) icon in the bottom panel: Figure 2-5

At the bottom of the KDE menu, select the Logout entry. You can also right-click on the window background and select the same option from the popup menu. After selecting Logout, a conrmation dialog appears. If you select Logout again, you are logged out and the login screen re-appears, allowing you or another person to log in.

How to Shut Down and Reboot the Linux System


If you are at the login screen, you can shut down or reboot your computer by opening the Menu menu and selecting one of the following options:

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-9

SUSE Linux Fundamentals

Session Type. You can choose a window manager other than KDE. In this student manual, we cover only KDE (the default window manager). Restart X Server. You can restart the program that's responsible for the graphical user interface. Remember, SUSE Linux Enterprise Server does not need a graphical user interface to work. The GUI is clearly separated from the operating system. However, in this course we work from the GUI interface.

Shutdown. If you select this option, you are asked if you want to shut down or restart your computer:

Figure 2-6

For security reasons, you have to enter the root password because only root is allowed to restart or shut down the computer. If you select Turn off computer and select OK, Linux closes all the (system) programs currently running. Older computers that do not have power management and cannot switch themselves off can be switched off when the following message appears:
Master Resource Control: runlevel 0 has been reached

2-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

If you switch the machine off too soon, this could possibly lead to loss of data.

You should always shut down your computer before you turn it off.

How to Identify KDE Desktop Components


After you log in, your system will by default start the KDE desktop environment. It is composed of

The Desktop The KDE Control Panel (Kicker) The KDE Menu Virtual Desktops

The Desktop

On the desktop you will see only a few icons. You can start the applications associated with these icons by selecting them once with your left mouse button. You can move the icons by dragging them with the mouse.

The KDE Control Panel (Kicker)

The KDE desktop is operated by using the mouse on the KDE control panel (as called the Kicker) located at the bottom of the desktop: Figure 2-7

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-11

SUSE Linux Fundamentals

The following are the most commonly used icons and their functions (from left to right):

Green button with red N: Menu of all congured programs and functions (not of all programs and functions installed on the machine). This menu is called the KDE menu. Blue house: Konqueror, the preferred KDE file manager. Shell in front of monitor: A terminal window in which to type commands directly. Lifesaver with a chameleon head: The SUSE Help Center. Globe with gear wheel teeth: Konqueror, as preferred KDE Web browser. E with letter: The KMail e-mail program. The white and gray box: Virtual desktops. The empty area right of the virtual desktops: Task Manager area. Clipboard with k: Clipboard. Loudspeaker: A sound mixer. Sheet with i: SuSEwatcher for automatic updates. Computer card: SuSEplugger for plug and play. Clock: Current time.

2-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

The KDE Menu

Programs are normally started from the KDE menu. You can select the KDE menu button to open the KDE menu: Figure 2-8

This menu consists of the following 3 sections:

Most frequently used applications. As indicated by the name, this section lists the five most frequently used applications. Accordingly, the listed entries can change from time to time. All applications. This section features an overview of various applications sorted by subjects (such as Multimedia). Actions. This section provides a command line interface, an overview of the bookmarks, an option for locking the screen, and the option for logging out.

A submenu in the KDE menu is marked by a small black arrow in the right-hand corner. To open a submenu, move the mouse cursor over the menu entry. To start a program, select the corresponding entry once with the left mouse button.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-13

SUSE Linux Fundamentals

Virtual Desktops

If you are working with several programs concurrently, the screen can quickly become cluttered with open windows. In Linux, you can bring order to this chaos by changing to another (virtual) desktop. You can switch between the various desktops via the control panel. By default, two virtual desktops are congured. In the KDE control center, you can increase the number of usable virtual desktops up to sixteen. Every virtual desktop can host a virtually unlimited number of applications. Using these virtual desktops, you can easily organize your work.

How to Manage Icons in the KDE Environment


You can nd icons in your KDE environment in 3 areas:

Desktop Kicker KDE Menu

Desktop

You can create a new icon on your desktop in different ways. For simplicity, we will describe only one method. To create an icon for an application on your desktop, select the item in your KDE menu. Hold down the left mouse button, move the mouse pointer to free space on your desktop and release the mouse button. In the menu that appears, select Copy Here.

2-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

Kicker

You can add new programs to the control panel by right-clicking on a free area of the panel, and then selecting Add. You can remove a program from the control panel by right-clicking its icon in the control panel and then selecting Remove program name. You can move icons in the panel by holding down the middle mouse button or by choosing Move from the Context menu.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-15

SUSE Linux Fundamentals

KDE Menu

To make changes in your KDE menu, start the KDE Menu Editor by selecting the KDE menu icon with the right mouse button and selecting Menu Editor. The following appears: Figure 2-9

2-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

How to Use the Konqueror File Manager


Nearly all work on the le system can be carried out with the KDE Konqueror program. To start Konqueror, select the blue house icon in Kicker. The following appears: Figure 2-10

To navigate quickly through the le system, activate the navigation panel (select Window > Show Navigator Panel), which splits the main window and displays the directory tree. The icon with the blue house on the navigation panel displays the directory tree starting from the user's home directory. The icon with the folder displays the directory tree starting from the root directory.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-17

SUSE Linux Fundamentals

The Konqueror window is divided into 3 sections: Figure 2-11

The top section contains a menu bar, a toolbar, and an address panel. The bar to the left is the preset navigation panel, which serves primarily for navigation and orientation. The navigation area is split into a right and left window (after selecting the blue house or folder icon). You can use the left window for quicker navigation through the le system tree. Once you select a directory in the left window, the directory contents (le view) are displayed in the right window. You can use several methods to navigate in the le system. The 3 arrows on the left side of the toolbar represent the simplest way. The current position can be seen in the text window of the URL panel (in the above example, /home/tux/).

2-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

If you select the arrow pointing upwards, you will move from the current directory to the next highest directory (from /home/tux/ to /home/). The arrow pointing to the left returns you to the previously visited location. You can move forward again with the right arrow. You can open a directory and view its contents by selecting the directory in the le view. If you select a normal le, KDE tries to open it or starts a program to open it. Selecting the house symbol in the toolbar takes you directly to your own home directory (for example, /home/tux/). The second method of navigating is provided by the navigation area. If you select a directory in the navigation area, its contents are displayed in the le view. You can double-click the directory in the navigation area to open it and view all subdirectories in it. Double-click the directory again to close it.

If you prefer a detailed list that displays information about each le in the tree, activate the tree view by selecting the second icon from the right in the toolbar.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-19

SUSE Linux Fundamentals

Exercise 2-1

Explore Your KDE Desktop


To explore your KDE desktop, do the following from the GUI login screen (where you were left after installing SLES 9):
1. 2.

In the Username field, enter geeko. In the Password field, enter N0v3ll (use zero; not an uppercase o). For security reasons, asterisks are displayed instead of the actual letters when you enter the password.

3.

Select Login. The KDE desktop environment starts, and initial dialogs appear.

4.

Close the SUSE Linux welcome screen and the Kandolfs Useful Tips dialog by selecting the X in the upper right corner of the windows. (Conditional) If a new hardware dialog appears, deselect Keep me informed about new hardware; then select No. Start the file manager Konqueror by selecting the blue house icon in Kicker. View the navigation area by selecting the red folder icon on the left side of the Konqueror window. View the contents of the /etc/ directory by selecting etc in the side panel (a single mouse click). Copy the file /etc/DIR_COLORS to the directory /tmp/ by scrolling down and selecting the DIR_COLORS file icon, dragging it over the tmp folder icon in the navigation area, and releasing the mouse button.

5.

6.

7.

8.

9.

10. From the popup menu, select Copy Here. 11. View the contents of the directory /tmp/ by selecting tmp in the

side panel (a single mouse click).


12. Rename the copied file by right-clicking the DIR_COLORS file

icon, and then selecting Rename from the popup menu.

2-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

13. For the new filename, type example.txt; then press Enter. 14. Quit Konqueror by selecting the X button in the top right corner

of the window.
15. Open the KDE menu by selecting the leftmost icon in the bottom

panel.
16. Select Logout; then select Logout again.

You are returned to the GUI login screen.


17. Open the Menu drop-down list; then select Shutdown. 18. Select Restart computer; then enter the root password novell in

the Password field and select OK. After the computer has restarted, the login screen appears.
19. Log in as geeko with a password of novell; then select Login. 20. Close all windows that open automatically by selecting the X

button in the top right corner of the window.


(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-21

SUSE Linux Fundamentals

Objective 3

Use the Gnome Desktop Environment


Both GNOME and KDE are comfortable desktop environments. Like KDE, GNOME supports drag and drop. Numerous programs are specically designed for GNOME. To use the GNOME desktop environment, you need to know the following:

How to Start GNOME How to Navigate in GNOME How to Manage Icons in GNOME How to Use the GNOME File Manager (Nautilus)

2-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

How to Start GNOME


Before you select Login at the login screen, you can start GNOME instead of KDE by selecting Session Type > GNOME from the Menu drop-down list. The following appears: Figure 2-12

How to Navigate in GNOME


The GNOME desktop includes the following 2 panels:

Top panel. The panel at the top of the desktop is responsible for launching applications. The following features are available (left to the right):

Applications menu for launching applications

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-23

SUSE Linux Fundamentals

Actions menu for basic actions (such as logging out) The Nautilus le manager (house icon) The terminal emulation window (monitor icon) A clock A speaker icon for volume A menu listing all open windows

Bottom panel. The panel at the bottom of the desktop provides the following:

An icon to close all open windows A task manager A pager for the 4 virtual desktops

You can start a programs with an icon on the desktop by double-clicking the icon. You can set preferences for the desktop environment by selecting the Start Here icon. To quit GNOME, select Actions > Log Out in the GNOME panel. The following appears: Figure 2-13

If you select Save current setup, your current desktop environment settings are saved.

2-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

How to Manage Icons in GNOME


You can nd icons in the following 3 areas on your desktop:

Desktop Panel Application Menu

Desktop

You can create a new icon on your desktop in different ways. For simplicity, we will describe only one method. To create an icon for an application on your desktop, select the item in your application menu, drag it to a free space on your desktop, release the mouse button and select Copy here.

Panel

You can add new programs to the control panel by right-clicking a free area of the panel and then selecting Add to Panel. From the submenus displayed, select the application you want to add. You can remove a program from the control panel by right-clicking its icon in the control panel and then selecting Remove from panel. You can move icons in the panel by holding down the right mouse button and selecting Move from the Context menu.

Application Menu

To add a entry to a menu, do the following:


1.

Double-click the Start Here icon on the desktop. The Start Here location appears.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-25

SUSE Linux Fundamentals

2.

In the file manager window, double-click the icon that represents the menu (Applications or Menu SuSE) you want to add the launcher. Select File > Create Launcher. A Create Launcher dialog is displayed.

3.

4.

Enter the properties of the launcher in the Create Launcher dialog; then select OK.

How to Use the GNOME File Manager (Nautilus)


GNOME provides its own le manager (called Nautilus): Figure 2-14

2-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

You can start Nautilus by selecting the house icon in the top panel or by selecting the username Home icon on the desktop. Although Nautilus does not provide as many features as some other le managers, it contains the features you need for most le navigation tasks. To display the le system tree view, select View > Side Panel; then select Tree from the side panel drop-down list. A display similar to the following appears: Figure 2-15

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-27

SUSE Linux Fundamentals

Exercise 2-2

Explore Your GNOME Desktop


To explore your GNOME desktop, do the following:
1.

From the KDE menu, log out as geeko by selecting Logout > Logout. From the GUI login screen, select the Menu drop-down list; then select Session Type > GNOME. Log in as geeko with a password of N0v3ll (select Login). The GNOME desktop environment starts.

2.

3.

4.

From the GNOME desktop, select the Applications menu (top panel) and view the applications available. Start the Nautilus file manager by selecting the house icon in the top panel. Display the side panel by selecting View > Side Pane. View the file system tree in the side panel by selecting Tree from the drop-down list at the top of the side panel. Display the contents of the directory /tmp/ by expanding Filesystem; then select tmp. Delete the file example.txt by right-clicking the file icon and selecting Move to Trash.

5.

6. 7.

8.

9.

10. Close the Nautilus file manager window. 11. From the top of the Gnome desktop, select the Actions menu;

then select Log Out.


12. Select OK.

You are returned to the GUI login screen.


13. From the Menu drop-down list, select Session Type > KDE. 14. Log in as geeko with a password of N0v3ll (select Login).
(End of Exercise)

2-28

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

Objective 4

Access the Command Line Interface From the Desktop


A classic multiuser environment can be implemented by connecting several terminals (dialog stations)monitor and keyboard unitsto the serial interface of a single computer. You can also connect several terminals to the serial interface in a Linux system. However, because more than one person often uses the same PC, virtual terminals were created in Linux. With virtual terminals, you can work in Linux as if you had several classic terminals available at the same time. You can have up to 6 virtual terminals (F1-F6) running on your computer. By pressing Ctrl+Alt+Fx, you can switch between individual terminals. By pressing Ctrl+Alt+F7, you can switch back to your graphical user interface. You can determine the terminal currently being used from the tty number (tty1tty6). tty is an abbreviation for teletype, which is another word for terminal. When you switch to a virtual terminal, a login prompt appears:
Welcome to SUSE Linux Enterprise Server 9 (i586) - Kernel 2.6.4-27-default (tty1).

da5 login:

From here you can enter your login name and password. To logout enter exit.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-29

SUSE Linux Fundamentals

The le /etc/issue contains the text that is displayed before logging in to the system (see above). When logging in to a host via the network, the contents of the le /etc/issue.net is used. To display a welcome message after the successful login to the system, you can enter the text in the le /etc/motd with the help of a text editor such as vi.

Besides using the virtual terminals, you can start a terminal emulation (called Konsole) from your KDE desktop Kicker by selecting the following icon: Figure 2-16

The terminal opens inside a window with options you can select to modify the display of the terminal (such as font and background color).

2-30

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use the Linux Desktop

Exercise 2-3

Access the Command Line Interface


To access the command line interface, do the following:
1. 2.

Switch to the first virtual terminal by pressing Ctrl+Alt+F1. (Conditional) If you see a SUSE - A Novell Company splash screen, display the command line by pressing F2. Type geeko as a login name and press Enter. Type N0v3ll as the password and press Enter. Switch to the second virtual terminal by pressing Ctrl+Alt+F2. Notice that you are not logged in at this terminal.

3. 4. 5.

6.

Press Ctrl+Alt+F1 to switch back to the first terminal. You are still logged in as geeko.

7. 8.

Log out by entering exit. Switch back to the graphical user interface by pressing Ctrl+Alt+F7.

(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

2-31

SUSE Linux Fundamentals

Summary
Objective
1. Overview of the Linux Desktop

Summary The X Window System consists of a server component (X server) and client applications. You can safely bring your Linux system up and shut it down. You can log in and log out of the KDE system. You can navigate in the KDE desktop environment.

2. Use the KDE Desktop


Environment

3. Use the Gnome Desktop


Environment

You can log in and log out of the GNOME system. You can navigate in the GNOME desktop environment.

4. Access the Command Line


Interface From the Desktop

SUSE Linux Enterprise Server provides the user with six virtual terminals. You can use the key combinations Ctrl+Alt+ F1 to Ctrl+Alt+F6 to switch between the individual terminals. You can switch back to your graphical user interface by pressing Ctrl+Alt+F7.

2-32

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

SECTION 3

Locate and Use Help Resources in the Linux System

Linux is one of the best documented operating systems. This section shows you how to nd and use several sources of help information.

Objectives
1. 2. 3. 4. 5.

Access and Use man Pages Use info Pages Access Release Notes and White Papers Use GUI-Based Help in the Linux System Find Help on the Web

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-1

SUSE Linux Fundamentals

Objective 1

Access and Use man Pages


The most important command for online help is man (an abbreviation of manual or man page). All manual pages are available in English and many have been translated into other languages. Because these translations are often incomplete or not maintained, we recommend using the English versions. If the English man pages are not shown automatically with the command man, you can display the English version of the man page by using the parameter LANG=en_EN. For example to display the English version of the man page for the command man, you would enter the following:
tux@da1:~ > LANG=en_EN man man

Using the parameter LANG=en_EN switches to the English language for the requested man pages only.

3-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

The following is the rst page of the manual pages for the command man:
man(1) Manual pager utils man(1)

NAME man an interface to the on-line reference manuals

SYNOPSIS man [-c|-w|-tZT device] [-adhu7V] [-m system[,...]] [-L locale] [-p string] [-M path] [-P pager] [-r prompt] [-S list] [-e extension] [[section] page ...] ... man -l [-7] [-tZT device] [-p string] [-P pager] [-r prompt] file ... man -k [apropos options] regexp ... man -f [whatis options] page ... DESCRIPTION man is the system's manual pager. Each page argument given to man is normally the name of a program, utility or function. The manual page associated with each of these arguments is then found and displayed. A section, if provided, will direct man to look only in that section of the manual. The default action is to search in all of the available sections, following a pre-defined order and to show only the first page found, even if page exists in several sections.

The header of each manual page contains the command name at the left and right sides and the section number to which the manual page belongs. In the center of the header is the name of the section. The last line usually contains the date of the last changes.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-3

SUSE Linux Fundamentals

A manual page is always divided into the following parts: Table 3-1
Part NAME SYNOPSIS DESCRIPTION OPTIONS COMMANDS Contents Name and short description of the command Description of the syntax Detailed description of the command Description of all available options available Instruction that can be given to the program while it is running Files connected in some way to the command Hints on related commands Possible error messages of the program Examples of calling up a command Known errors and problems with the command

FILES SEE ALSO DIAGNOSTICS EXAMPLE BUGS

The manual pages are organized in the following sections: Table 3-2
Section 1 Contents Executable programs and shell commands (user commands) System calls Functions and library routines Device les Conguration les and le formats Games Macro packages and le formats

2 3 4 5 6 7

3-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

(continued)

Table 3-2

Section 8

Contents System administration commands

For example, entering the following displays general information about the command crontab: man 1 crontab Entering the following displays information about the conguration le for the command crontab (which also has the name crontab): man 5 crontab It is especially important to know to which section a command belongs when there is more than one manual for a command. For example, the command uname is both a user command and a system call. Entering the following displays information about the user command: man 1 uname Entering the following displays information about the system call (such and name and information about the current kernel): man 2 uname You can display a brief description of all the available manual pages for a command or utility by using the command whatis (as in the following):
tux@da1:~ > whatis uname uname (1) - print system information uname (2) - get name and information about current kernel uname (1p) - return system name uname (3p) - get the name of the current system tux@da1:~>

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-5

SUSE Linux Fundamentals

x
Table 3-3

Manual pages whose output is marked with p are POSIX manual pages of the command uname (uname (1p)) and the function (uname (3p)).

To conveniently view manual pages, you can use the command less which displays one screen of information at a time. The following keys are available to use with command less:
Key Command Space b PageDown PageUp Down-arrow, Enter Up-arrow End Home /expression Description Page one screen forward. Page one screen backward. Page half a screen forward. Page half a screen backward. Jump one line forward. Jump one line backward. Go to end of the manual page. Go to beginning of manual page. Search forward from the current cursor position for expression; matching line is displayed as rst line on the screen. Search backwards from current cursor position for expression; matching line is displayed as rst line on the screen. Move to next instance of expression in the search. Move to previous instance of expression in the search. End display of the manual page.

?expression

3-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

In SUSE Linux Enterprise Server, the manual pages are located in the directory /usr/share/man/. If you enter man -k keyword or apropos keyword, a list of manual pages in which the keyword appears in the NAME section is displayed. For example:
tux@da1:~ > man -k printf vasprintf (3) - print to allocated string vwprintf (3p) - wide-character formatted output of a stdarg argument list vfprintf (3) - formatted output conversion snprintf (3) - formatted output conversion format (n) - format a string in the style of sprintf swprintf (3) - formatted wide character output conversion asprintf (3) - print to allocated string vsprintf (3p) - format output of a stdarg argument list printf (3p) - print formatted output sprintf (3p) - print formatted output wprintf (3p) - print formatted wide-character output vdprintf (3) - print to a file descriptor fwprintf (3) - formatted wide character output conversion sprintf (3) - formatted output conversion dprintf (3) - print to a file descriptor wprintf (3) - formatted wide character output conversion printf (3) - formatted output conversion

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-7

SUSE Linux Fundamentals

Exercise 3-1

Access and Use man Pages


To use man pages, do the following:
1. 2.

Select the monitor icon in the Kicker to start Konsole. Find the sections of the man pages for the command info by entering whatis info. Read the first section (executable programs and shell commands) of the man pages of the command info by entering man 1 info. Scroll through the text with the up arrow key and the down arrow key. When you finish viewing the information, exit (quit) the man page by typing q. Leave the Konsole window open for the next exercise.

3.

4.

5.

(End of Exercise)

3-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Objective 2

Use info Pages


Unfortunately, a whole series of GNU programs are no longer provided with manual pages (or the pages have become outdated). Instead, info les are used, which can be read with the command info. In SUSE Linux Enterprise Server, the info les are located in the directory /usr/share/info/. The following is the beginning of the info le for the command info:
File: info.info, Node: Top, Next: Getting Started, Up: (dir) Info: An Introduction ********************* Info is a program, which you are using now, for reading documentation of computer programs. The GNU Project distributes most of its on-line manuals in the Info format, so you need a program called "Info reader" to read the manuals. One of such programs you are using now. If you are new to Info and want to learn how to use it, type the command `h' now. It brings you to a programmed instruction sequence. To learn advanced Info commands, type `n' twice. This brings you to`Info for Experts', skipping over the `Getting Started' chapter. * Menu: * * * * Getting Started:: Getting started using an Info reader. Advanced Info:: Advanced commands within Info. Creating an Info File:: How to make your own Info file. Index:: An index of topics, commands, and variables.

The following are advantages of the info le format:

It uses a structured document setup

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-9

SUSE Linux Fundamentals

Specific sections can be reached directly from the table of contents Specific sections can be linked

The following are the most commonly used key commands for the command info: Table 3-4
Key Command Space, PageDown Description Search in the info page.

Backspace, PageUp b

Page up one screen. Move cursor to the beginning of current info page. Move cursor to the end of current info page. Move cursor to the next reference (*). Follow the reference. Move to the next info page of the same level (Next:). Move to the previous info page of the same level. Move one level higher. Move back to the last text displayed; end help. Page down one screen. Display help. List a summary of commands. End display of info document.

e Tab Enter n

u l s h ? q

3-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Exercise 3-2

Access and Use info Pages


To use info pages, do the following:
1.

From the Konsole terminal window, display the info pages for the command info by entering info info. Move the cursor to the first reference (Getting Started) by pressing Tab. Follow the reference by pressing Enter. Move the cursor to the reference Quitting Info by pressing Tab eight times. Follow the reference by pressing Enter. Return to the page Getting Started by typing l (lowercase L). Exit the info file by typing q. Close the Konsole terminal window.

2.

3. 4.

5. 6. 7. 8.

(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-11

SUSE Linux Fundamentals

Objective 3

Access Release Notes and White Papers


Release notes, white papers and other helpful information are stored in the directory /usr/share/doc/. This directory contains the following:

Release Notes Howtos Help for Installed Packages

Release Notes
When you complete the installation of SUSE Linux Enterprise Server (just before the Login screen is displayed), the release notes appear in a window. If you want to access these release notes later, you can nd them in the directory /usr/share/doc/release-notes/. There are 2 release note les available:

RELEASE-NOTES.en.html RELEASE-NOTES.en.rtf

The content of these les is identical. Only the le format is different.

Howtos
You can nd additional information (including background material) in the howtos. There is a howto for almost every imaginable topic in Linux.

3-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

The howtos are also available in different formats, such as ASCII, PostScript, and HTML. In addition, many of the howtos have been translated into various languages. SUSE Linux Enterprise Server contains a large number of howtos. The howtos of the Linux Documentation Project in HTML format are installed during the installation of SUSE Linux Enterprise Server 9. You can access these les in the directory /usr/share/doc/howto/en/html/. You can also install the howtos in ASCII format (package howto, ASCII format). After installation, you can nd them in the directory /usr/share/doc/howto/en/txt/. You can nd a list of all current howtos (together with available translations) at http://www.tldp.org/.

Help for Installed Packages


Help les are available in the following directory for most installed packages: /usr/share/doc/packages/package-name These help les are written by the programmers of the package. Therefore, the format of these les is not standardized. Some packages provide help les in HTML, while others are in pure ASCII.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-13

SUSE Linux Fundamentals

Exercise 3-3

Access Release Notes and White Papers Pages


To access Release Notes, do the following:
1.

Start the file manager Konqueror by selecting the blue house icon in Kicker. Open the Navigation Panel by selecting the Root Folder icon (red folder) on the left side of the Konqueror window. Display the content of the directory /usr/ by selecting the usr folder icon in the Navigation Panel. Display the content of the directory /usr/share/ by selecting the the share folder icon in File View (right window). Select the icon once; you do not need to double-click.

2.

3.

4.

5.

Display the content of the directory /usr/share/doc/ by selecting the doc folder icon in the File View. Display the content of the directory /usr/share/doc/release-notes/ by selecting the release-notes folder icon in the File View. Read the Release Notes by selecting RELEASE-NOTES.en.html in the File View. Close the Konqueror window.

6.

7.

8.

(End of Exercise)

3-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Objective 4

Use GUI-Based Help in the Linux System


The most important application for getting help in Linux is the web and le browser Konqueror. You can use Konqueror to do the following:

Display the SUSE HelpCenter Use Help Commands With Konqueror

Display the SUSE HelpCenter


SUSE provides its own help systemthe SUSE HelpCenter. To access the HelpCenter, select the lifesaver icon in the Kicker: Figure 3-1

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-15

SUSE Linux Fundamentals

Konqueror starts and displays help information: Figure 3-2

Help programs are available in most KDE applications and can be started by pressing F1. Because the help programs use HTML format, you can follow any embedded hyperlinks by selecting the desired entry in the table of contents.

The rst time you use the Search feature, you see a message telling you that you have to create an index. If you want to use the Search feature, select Yes > OK.

3-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Use Help Commands With Konqueror


Konqueror is also able to display man pages and info pages. To view a man page, enter man:command (such as man:info) in the address bar. Konqueror lists any available man pages for the command: Figure 3-3

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-17

SUSE Linux Fundamentals

To use the info command with Konqueror, enter info:command in the address bar and Konqueror displays the info page: Figure 3-4

3-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Exercise 3-4

Use GUI-Based Help


To use GUI-based help, do the following:
1.

Start the SUSE HelpCenter by selecting the lifesaver icon in Kicker. Create a search index by selecting the Search tab. Start the creation by selecting Yes. Confirm the creation by selecting OK. A dialog appears requesting the root password to create the search index.

2. 3. 4.

5. 6.

Enter a password of novell and select OK. After the creation process finishes, close the dialog window by selecting Close. Get help about printing with Linux by entering printer in the text field above the Search tab; then select Search. In the Help information window (to the right) select the link under the Release Notes heading. To find the paragraph about printer configuration, select Edit > Find.

7.

8.

9.

10. In the Text to find field, enter printer; then select Find. 11. After viewing the information, close the Find dialog by selecting

Cancel.
12. Close the SUSE HelpCenter window.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-19

SUSE Linux Fundamentals

Objective 5

Find Help on the Web


You can nd an extensive collection of information about Linux on the Internet for both for general issues and special issues. The following are some of the more frequently used Linux sites:

http://www.novell.com/linux/suse http://www.linux.org http://www.linux.com http://www.tldp.org http://www.linuxplanet.com http://www.cert.org (especially for security issues) http://www.securityfocus.com (especially for security issues) http://www.kernel.org (especially for issues in connection with the Linux kernel)

To nd other sources of information, you can use a search web site such as Google. Google offers a special search web site for questions about Linux at www.google.com/linux.

Be careful with information you nd on personal home pages. This information can be old or wrong.

3-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Exercise 3-5

Find Help on the Web


To nd help on the web, do the following:
1. 2.

Start Konqueror by selecting the globe icon in Kicker. In the Location bar enter support.novell.com. The Novell support home page appears.

3.

Under Technical Resource Search, select SUSE from the choose a product drop-down list. In the empty search field, enter SLES 9 installation. Notice that you can search the Knowledgebase and Documentation.

4.

5. 6.

Search both by selecting documentation; then select search. (Conditional) If you receive a warning message about unencrypted transmission of data, select Do not ask again; then select Yes. (Conditional) If you see a cookie alert warning message, select All cookies; then select Accept. A Search Results page appears with several pages of links available.

7.

8.

Select one or more links, then select the Back icon arrow until you return to the support home page. Take some time to explore other links such as download patches or Downloads. www.google.com/linux.

9.

10. When you finish, in the Location field enter 11. In the text field at the top of the page, enter kde and sles9; then

select Google Search.


12. Select one or more of the displayed links.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-21

SUSE Linux Fundamentals

13. When you finish, close the Konqueror window.


(End of Exercise)

3-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Summary
Objective
1. Access and Use man Pages

Summary The most important command for online help is man. The manual pages are always divided into parts and arranged according to various sections. Use the command less to view the manual pages.

2. Use info Pages

Many GNU programs are no longer provided with manual pages. Instead, info les are used, which can be read with the command info. The following are advantages of the info format:

Structured document setup is available. Specic sections can be reached directly from the table of contents. Links between specic sections are possible.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-23

SUSE Linux Fundamentals

Objective
3. Access Release Notes and White
Papers

Summary The release notes can be found in the following directory: /usr/share/doc/release-notes/ Howtos are available in HTML after the installation of the SUSE Linux Enterprise Server 9 in the following directory: /usr/share/doc/howto/en/html/ Additionally, you can install Howtos in ASCII format later. These are located in the following directory: /usr/share/doc/howto/en/txt/ For most installed packages, there are help les available in the following directory: /usr/share/doc/packages/packa ge-name

4. Use GUI-Based Help in the Linux


System

SUSE provides its own help system called SUSE HelpCenter. Help programs are available in most KDE applications and can be started by pressing F1. Konqueror is also able to display man pages and info pages by entering the following:

man:command info:command

3-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Locate and Use Help Resources in the Linux System

Objective
5. Find Help on the Web

Summary The Internet is a very extensive source of expert knowledge for general issues and special issues with Linux. The following are a few of the more commonly-used web sites:

http://www.novell.com/linux/suse http://www.linux.org http://www.linux.com http://www.tldp.org http://www.linuxplanet.com http://www.cert.org http://www.securityfocus.com http://www.kernel.org

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

3-25

SUSE Linux Fundamentals

3-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

SECTION 4

Administer Linux with the YaST Management Utility

This section introduces you to the YaST graphical administration tool the most important modules available.

Objectives
1. 2. 3. 4. 5.

Get to Know YaST Manage User Accounts With YaST Install a Printer in the Linux System Understand the YaST Software Management Feature Obtain Hardware Configuration Information from YaST

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-1

SUSE Linux Fundamentals

Objective 1

Get to Know YaST


YaST stands for Yet another Setup Tool. You can use YaST to complete many conguration tasks as a SUSE Linux Enterprise Server administrator. The appearance of the user interface (ncurses or Qt) depends on which command you use to start YaST and on whether you use the graphical system or the command line, as indicated in the following:

Table 4-1

Command yast2 yast

Terminal in X Window Qt ncurses

Command Line ncurses ncurses

In the graphical interface, you can control YaST with the mouse: Figure 4-1

4-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

You control the ncurses interface with the keyboard: Figure 4-2

Press Tab to move from one box to another or to the text buttons. To go back to the previous box, press Alt+Tab. Use the arrow keys to navigate within the box. Mark highlighted menu items by pressing the Spacebar. To select a menu item, press Enter. You can often press Alt and the highlighted letter to access an item directly. Except for the controls and the appearance, the graphical mode and the text mode of YaST are identical. You can list the available modules can be listed with the command yast -l or yast --list. To start an individual module, specify its name. For example, you can enter the following to start the software installation module: yast sw_single

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-3

SUSE Linux Fundamentals

You can enter the software module name with the command yast or yast2, as in the following:

yast sw_single (text mode) yast2 sw_single (graphical mode)

To display a list of YaST options, enter one of the following:


yast --help yast -h

To display a list of YaST modules, enter the following:

yast -l

4-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Exercise 4-1

Get to Know YaST


To use the graphical version of YaST, do the following:
1. 2.

From the KDE desktop, start YaST by selecting the YaST icon. Enter the root password novell in the Run as root dialog; then select OK. The YaST Control Center appears.

3. 4. 5. 6. 7. 8.

Select Misc > View System Log. From the top drop-down list, select /proc/version. Close the log window by selecting OK. Select System > Date and Time. Select Change Time or Date. Enter the current time (such as 08:00:00) and the current date (such as 27.09.2005). Select Apply.

9.

10. Select Accept. 11. Switch to console 1 by pressing Crtl+Alt+F1. 12. Log in as root with a password of novell. 13. View a list of the available YaST modules by entering yast -l. 14. Log out by entering exit. 15. Switch back to the graphical interface by pressing Crtl+Alt+F7. 16. Close the YaST Control Center.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-5

SUSE Linux Fundamentals

Objective 2

Manage User Accounts With YaST


With YaST, you can manage users and groups. To do this, you need to understand the following:

Basics About Users and Groups User and Group Administration With YaST

Basics About Users and Groups


Linux is a multiuser system. In other words, several users can work on the system at the same time. For this reason the system must be able to uniquely identify all users. To achieve this, every user must log in with the following:

A user name A password.

Because the operating system can handle numbers much better than strings, users are handled internally as numbers. The number which a user receives is a UID (UserID). Every Linux system has a privileged user, the user root. This user always has the UID 0. Users can be grouped together based on shared characteristics or activities. For example

Normal users are usually in the group users. All users who intend to create web pages can be placed in the group webedit.

Of course, le permissions for the directory in which the web pages are located must be set so that the group webedit is able to write (save les).

4-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

As with users, each group is also allocated a number internally called the GID (GroupID), and can be one of the following types:

Normal groups All groups used by the system The root group (GID = 0)

User and Group Administration With YaST


You can access YaST user and group account administration in the following ways:

User administration. From the YaST Control Center, select Security and Users > Edit and create users, or from a terminal window, enter yast2 users. Group administration. From the YaST Control Center, select Security and Users > Edit and create groups, or from a terminal window, enter yast2 groups.

If you have selected LDAP for authentication during the installation of the SUSE Linux Enterprise Server, you are asked for the LDAP server administrator password. You can switch back and forth between administering users and administering groups by selecting the Users and Groups radio buttons at the top of the module window.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-7

SUSE Linux Fundamentals

The user account management window lists the existing user accounts (as in the following): Figure 4-3

4-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

To create a new user account, select Add in the administration window. The following appears: Figure 4-4

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-9

SUSE Linux Fundamentals

To set various password parameters (such as duration of a password), select Password Settings. The following appears: Figure 4-5

4-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

To set the properties of the user (such as the UID, the home directory, the login shell, group afliation, and additional user account comments), select Details. The following appears: Figure 4-6

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-11

SUSE Linux Fundamentals

You can modify the settings of an existing user account by selecting Edit in the user account management window. The following appears: Figure 4-7

4-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

You can administer groups from the following window: Figure 4-8

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-13

SUSE Linux Fundamentals

To create a new group, select Add. The following appears: Figure 4-9

4-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

You can edit an existing group to perform tasks such as adding or deleting members of the group by selecting Edit in the group account management window. The following appears: Figure 4-10

The information you enter when creating or editing users and groups with YaST is normally saved to the follow user administration les:

/etc/passwd /etc/shadow /etc/group

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-15

SUSE Linux Fundamentals

Exercise 4-2

Manage User Accounts with YaST


To manage user accounts with YaST, do the following:
1.

From the KDE desktop, select the YaST icon; then enter a password of novell and select OK. The YaST Control Center appears.

2.

From the YaST Control Center, select Security and Users > Edit and create users. Add a new user by selecting Add. Enter the following information:

3. 4.

Full User Name: Tux Linux User Login: tux Password: novell Verify Password: novell

5. 6. 7. 8. 9.

When you finish, select Create. Confirm the first password warning by selecting Yes. Confirm the second password warning by selecting Yes. Save the new settings by selecting Finish. From the KDE menu, log out by selecting Logout > Logout. X Window reboots and the GUI login screen appears.

10. In the Username field enter tux. 11. In the Password field enter novell. 12. Select Login. 13. Close or cancel any displayed dialogs. 14. Start the Konqueror file manager by selecting the blue house

icon in Kicker. The content of Tuxs home directory is displayed.

4-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

15. Browse to the directory /etc/. 16. Select the file passwd.

Notice the entries for users tux and geeko at the end of the le.
17. Close the Konqueror window. 18. From the KDE menu, log out by selecting Logout > Logout. 19. Log in as geeko with a password of N0v3ll. 20. Start YaST from the desktop by selecting the YaST icon. 21. Enter a root password of novell; then select OK. 22. From the YaST Control Center, select Security and Users >

Edit and create users.


23. From the list of users, select tux; then select Delete. 24. Select Delete Home Directory /home/tux; then select Yes. 25. Select Finish. 26. Confirm that the user tux has been removed by doing the

following: a. b. c. Start the Konqueror le manager by selecting the blue house icon in Kicker. The content of Geekos home directory is displayed. Browse to the directory /etc/. Notice the entry for tux has been removed from the end of the le. e. Close the Konqueror window.
27. Close the YaST Control Center.
(End of Exercise)

d. Select the le passwd.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-17

SUSE Linux Fundamentals

Objective 3

Install a Printer in the Linux System


YaST also provides printer installation and conguration functionality. To install a printer, you need to know the following:

When to Configure a Printer How to Change a Printer Configuration

When to Congure a Printer


You can congure your printer at the following times:

During installation. If you are at the Hardware Configuration dialog during installation (see in the following figure) and your automatic detection is not correct, select the Printers link or use the Change... drop-down list:

Figure 4-11

4-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Note that during installation, only locally connected printers are detected automatically and listed under Printers.

After installation. You can change your printer configuration settings from the YaST Control Center by selecting Hardware and selecting Printer.

How to Change a Printer Conguration


After accessing printer conguration during or after installation, you use the same Printer Conguration dialog to congure your printer: Figure 4-12

The upper part of the Printer Conguration dialog lists all automatically detected printers that have not been congured.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-19

SUSE Linux Fundamentals

If the printers cannot be detected automatically or if all printers are already congured, this text area displays only the Other (not detected) option. The lower part of the dialog lists all congured printers. To congure your printer, select Congure. The following appears: Figure 4-13

From here you select your printer type. If the printer is directly connected to your computer, you select one of the following:

Parallel printer USB printer Serial printer IrDA printer

4-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

The other printer types are used to congure a printer inside your network. In the next step, you select the interface your printer is connected to. The dialog can look slightly different, depending on what you have selected before. For example, the following is for conguring a parallel printer connection: Figure 4-14

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-21

SUSE Linux Fundamentals

Select an interface; then select Next. The following appears: Figure 4-15

Enter a name for your print queue in the Name for printing eld. You can also enter a description of your printer in the Description of Printer eld and the printer location in the Location of Printer eld.

4-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Select Next to display the Printer model dialog: Figure 4-16

Select the name of the printer manufacturer from the list on the left side of the window. Select the printer model from the list on the right side of the window.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-23

SUSE Linux Fundamentals

After selecting Next, the nal dialog (Edit conguration) appears: Figure 4-17

From this dialog, you can test your printer conguration by selecting Test. If you want to change any settings, select Edit. For example, you might want to change the default page size or the default paper tray. If everything is correct, select OK.

4-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Exercise 4-3

Change Your Printer Conguration


In this exercise, you change your printer conguration by adding a new printer. Do the following:
1. 2. 3.

Start YaST from the desktop by selecting the YaST icon. Enter a root password of novell and select OK. From the YaST Control Center, select Hardware > Printer. The Printer conguration dialog appears.

4. 5.

Add a new queue for a printer by selecting Configure. For the printer type, make sure Parallel printer is selected; then select Next. Accept First Parallel Port (/dev/lp0) as the printer device by selecting Next. In the Name for printing field, enter hplj4; then continue by selecting Next. A Printer model dialog appears, with a list of manufacturers and a list of models.

6.

7.

8.

From the manufacturer list, select HP; from the model list, select Laserjet 4. When you finish, select Next. An Edit conguration dialog appears.

9.

10. Change the settings of the printing filter by selecting Printing

filter settings; then select Edit.


11. Change the number of pages that should be printed on one sheet

of paper by selecting Pages per sheet in the Options list and 2 in the Values list.
12. When you finish, continue by selecting Next. 13. Return to the list of known print queues by selecting OK.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-25

SUSE Linux Fundamentals

14. Finish the configuration by selecting Finish. 15. Confirm that the printer has been added by doing the following:

a.

From the KDE menu, select Utilities > Printing > Printers. A Printing Manager dialog appears. Notice that hplj4 is listed as a printer.

b. c.

Select one or more tab pages (such as Properties) for the printer. When you nish, close the Printing Manager dialog.

16. Close the YaST Control Center.


(End of Exercise)

4-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Objective 4

Understand the YaST Software Management Feature


To understand the YaST software management feature, you need to know the following:

How to Select Software Packages to Install How to Manage Installation Sources

How to Select Software Packages to Install


After performing a standard SLES 9 installation, you will often need to install additional software. To do this, start the YaST module Software > Install and Remove Software. The installed packages and the packages that are available on the installation media are analyzed and dependencies between packages are checked.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-27

SUSE Linux Fundamentals

After this checking, the following dialog for selecting packages to install appears: Figure 4-18

To help you nd the software you want to install, you can choose from different lters listed in the drop-down list in the top left corner of the window. The following lters are available:

Selections: Displays only the installed packages. Package Groups: Displays all software that is available on the known installation medias. Search: Lets you enter a search term and where you want YaST to search for the software package. Installation Summary: Displays all the packages with a marked status.

To nd a package, enter the package name or parts of the package name or some keywords in the Search eld; then select Search.

4-28

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

The matched packages are listed in the right area. The installation state is shown by a small symbol in front of the package name. The most commonly-displayed symbols include the following: Figure 4-19

To view a list of all possible symbols, select Help > Symbols. Select the symbol of the package you want to install several times until the Install symbol appears; then select Accept. You might see a dialog indicating that the dependencies between the packages cannot be solved and that some other packages need to be installed, too. In most cases you can simply conrm this dialog. If the wrong CD is in your drive, a warning appears.

How to Manage Installation Sources


The software installation dialog lists only the packages that are on the current installation media.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-29

SUSE Linux Fundamentals

If you want to add more installation sources, you need to select Software > Change Source of Installation from the YaST Control Center. The following appears: Figure 4-20

To add a new source, select the Add drop-down list and select the type of installation source. Depending on the type of source, you might have to provide additional information (such as the IP address of an installation server). To edit the conguration of an existing installation source, select the source in the list and select Edit. If you want to disable an installation source temporarily, select the source in the list and select Enable or Disable. To remove an installation source permanently, select the source from the list and select Delete.

4-30

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

YaST uses the rst installation source in the list that has the software package you want to install. To change the order of a source in the list, select the source and Up or Down.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-31

SUSE Linux Fundamentals

Exercise 4-4

Install New Software


To install new software, do the following:
1.

From the KDE desktop, select the YaST icon; then enter a password of novell and select OK. From the YaST Control Center, select Software > Install and Remove Software. From the Filter drop-down list, select Selections. From the left side of the window, highlight Various Linux Tools. Make sure there is no checkmark to the left of Various Linux Tools.

2.

3. 4.

5.

From the right side of the window, select the package findutils-locate. Select Accept. (Conditional) If requested by YaST, insert the appropriate SLES 9 CD; then select OK. Close the YaST Control Center by selecting Close. (Conditional) If you installed from CD, remove the CD from your drive.

6. 7.

8. 9.

(End of Exercise)

4-32

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Objective 5

Obtain Hardware Conguration Information from YaST


To obtain information about the conguration of your hardware, from the YaST Control Center select Hardware > Hardware Information. After scanning the hardware for a few moments, YaST displays a dialog similar to the following that summarizes the information about the detected hardware:

Figure 4-21

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-33

SUSE Linux Fundamentals

Exercise 4-5

Obtain Hardware Conguration Information


To obtain hardware conguration information about your computer, do the following:
1.

Open the YaST Control Center; then select Hardware > Hardware Information. Wait until YaST has scanned your hardware.

2. 3.

Check the results of the detection. When you finish, close the Hardware info window by selecting Close. Close the YaST Control Center.

4.

(End of Exercise)

4-34

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Summary
Objective
1. Get to Know YaST

Summary The appearance of the user interface of YaST depends on the command used for starting:

In the graphical interface, YaST can be controlled intuitively with the mouse. The ncurses interface is controlled exclusively with the keyboard.

Individual modules can also be started directly. Available modules can be listed with the command yast -l or yast --list.
2. Manage User Accounts With YaST Linux is a multiuser system. For

this reason, the system must be able to uniquely identify all users. This is done by assigning each user account a unique internal number: the UID (UserID). Every Linux system has a privileged user, the user root. This user always has the UID 0. As with users, the groups are also allocated a number internally: the GID (GroupID). You can administer user accounts from the YaST Control Center by selecting Security and Users > Edit and create users.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-35

SUSE Linux Fundamentals

Objective
2. Manage User Accounts With YaST
(continued)

Summary You can administer groups from the YaST Control Center by selecting Security and Users > Edit and create groups. The entered information is saved by YaST to the following conguration les:

/etc/passwd /etc/shadow /etc/group

3. Install a Printer in the Linux


System

The printer conguration settings can changed with YaST: Hardware > Printer. The upper part of the Printer Conguration dialog lists all automatically detected printers that have not been congured. The lower part of the dialog lists all congured printers. Automatically detected printers will be congured correctly by an automated process. If the printer is not detected, you have to congure it manually by selecting the Congure... button. The following printer types can be connected directly to your computer:

Parallel printer USB printer Serial printer IrDA printer

4-36

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Administer Linux with the YaST Management Utility

Objective
3. Install a Printer in the Linux
System (continued)

Summary It's possible to congure a printer inside your network. To install new software packages use the YaST module Software > Install and Remove Software. The installation status of a package is indicated by a symbol. A overview about all possible symbols can be reached via the Help > Symbols menu. There are dependencies between the packages. In most cases these dependencies can be resolved automatically. Otherwise they must be resolved manually. To add a new installation source, start the YaST module Software > Change Source of Installation.

4. Understand the YaST Software


Management Feature

5. Obtain Hardware Conguration


Information from YaST

To obtain information about the conguration of your hardware, select the YaST module Hardware > Hardware Information.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

4-37

SUSE Linux Fundamentals

4-38

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

SECTION 5

Manage Directories and Files in the Linux System

In this section you learn about the structure of the Linux le system and the most important le operation commands for working at the command line.

Objectives
1. 2. 3. 4. 5. 6. 7. 8. 9.

Understand the File System Hierarchy Standard (FHS) Identify File Types in the Linux System Change Directories and List Directory Contents Create and View Files Manage Files and Directories Find Files on Linux Search File Content Archive, Compress, and Uncompress Files Manage File Permissions and Ownership

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-1

SUSE Linux Fundamentals

Objective 1

Understand the File System Hierarchy Standard (FHS)


The le system concept of Linux (and, in general, of all UNIX systems) is considerably different than that of other operating systems. To understand the concept of the Linux le system, you need to know the following:

The Hierarchical Structure of the File System FHS (Filesystem Hierarchy Standard) Root Directory / Essential Binaries for Use by All Users (/bin/) Boot Directory (/boot/) Device Files (/dev/) Configuration Files (/etc/) User Directories (/home/) Libraries (/lib/) Mountpoints for Removable Media (/media/*) Application Directory (/opt/) Home Directory of the Administrator (/root/) System Binaries (/sbin/) Data Directories for Services (/srv/) Temporary Area (/tmp/) The Hierarchy Below /usr/ Variable Files (/var/) Process Files (/proc/) System Information Directory (/sys/)

5-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Mountpoint for Temporarily Mounted File Systems (/mnt/) Directories for Mounting Other File Systems

The Hierarchical Structure of the File System


The le system concept of Linux involves a hierarchical le system that can be depicted in the form of a tree. This tree is not limited to a local partition. It can stretch over several partitions, which can be located on different computers in a network. It begins at the root, from where the name for the system administrator comes, and branches out like the branches of a tree. The following is an extract from a typical le system tree: Figure 5-1
/ /bin/ /boot/ /dev/ /etc/ /home/ /lib/ /media/ /mnt/ /opt/ /proc/ /root/ /sbin/ /srv/ /sys/ /tmp/ /usr/ /var/

/home/tux/ /home/geeko/ /media/floppy/ /media/cdrom/ /media/dvd/

A le in this directory tree is uniquely dened by its path. A path refers to the directory names which lead to this le The separation character between individual directory names is the slash (/). The path can be specied in 2 ways:

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-3

SUSE Linux Fundamentals

As a relative path starting from the current directory As an absolute path starting from the root of the entire file system tree.

The absolute path always begins with a slash (/), the symbol for the root directory, as in the following: Figure 5-2
etc / .. absolute:cd /etc relative:cd ../../etc

etc

home

..

tux current working directory

Sometimes it is necessary to specify the absolute path because certain les can only be uniquely addressed in this way. The length of the path cannot exceed 4096 characters, including the slashes.

FHS (Filesystem Hierarchy Standard)


The structure of the le system is described in the Filesystem Hierarchy Standard (FHS). Here, it is specied which directories must be located on the rst level after the root directory and what they contain. The FHS does not specify all details. In some areas it allows leeway for your own denitions. The FHS denes a two-layered hierarchy:

The directories in the top layer (immediately below the root directory /).

5-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

As a second layer, the directories under /usr/ and /var/.

You can nd information about FHS at http://www.pathname.com/fhs/ on the Internet.

Root Directory /
The root directory refers to the highest layer of the le system tree. Normally only directories (not les) are located here. When the system is booted, the partition on which this directory is located is the rst one mounted. Because the kernel cannot fulll all the tasks of the operating system, all programs that are run at the system start must be available on this partition (they cannot be located on another partition). The following directories always have to be on the same partition as the root directory: /bin/, /dev/, /etc/, /lib/, and /sbin/.

Essential Binaries for Use by All Users (/bin/)


The directory /bin/ contains important executable programs that are required when no other le systems are mounted, such as all programs necessary for the system start. These include the various shells, the most important commands for working with les, and several commands for system analysis and conguration.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-5

SUSE Linux Fundamentals

The following table provides an overview of the contents of the /bin/ directory: Table 5-1
File /bin/bash /bin/cat /bin/cp /bin/dd /bin/gzip /bin/mount /bin/rm /bin/vi Description The bash shell Displaying les Copying les Copying les byte-wise Compressing les Mounting le systems Deleting les vi editor

Boot Directory (/boot/)


The directory /boot/ contains static les of the boot loader (GRUB or LILO). These are les required for the boot process (with the exception of conguration les). The backed-up information for the Master Boot Record (MBR) and the system map les are also stored here. These contain information about where exactly the kernel is located on the partition. In addition, this directory contains the kernel. According to the FHS, however, the kernel can also be located directly in the root directory.

5-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Device Files (/dev/)


Each hardware component existing in the system (such as hard drive partitions, CD drives, printer, and mouse) is represented as a le in the directory /dev/. The hardware components are addressed via these les by writing to or reading from one of these les. Two kinds of device les are included:

Character-oriented device files (for devices working sequentially, such as printer, mouse, or tape drive) Block-oriented device files (such as floppy disks and hard drives).

The connection to device drivers in the kernel is implemented via numbered channels, which correspond to the number of the device driver in question. These are referred to as major device numbers. A driver might be responsible for several devices of the same type. To distinguish between these devices, the minor device number is used. Instead of the size of the les, these two numbers are displayed (the les do not occupy any space on the hard drive anyway):
da10:~ # ls -l /dev/hda* brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3, brw-rw---- 1 root disk 3,

0 Mar 22 06:12 /dev/hda 1 Mar 22 06:12 /dev/hda1 10 Mar 22 06:12 /dev/hda10 11 Mar 22 06:12 /dev/hda11 12 Mar 22 06:12 /dev/hda12 13 Mar 22 06:12 /dev/hda13 14 Mar 22 06:12 /dev/hda14 15 Mar 22 06:12 /dev/hda15 16 Mar 22 06:12 /dev/hda16 17 Mar 22 06:12 /dev/hda17 18 Mar 22 06:12 /dev/hda18 19 Mar 22 06:12 /dev/hda19 2 Mar 22 06:12 /dev/hda2 20 Mar 22 06:12 /dev/hda20

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-7

SUSE Linux Fundamentals

In this example, the major device number 3 is listed for all les. This refers to the driver for IDE hard drives. The minor device numbers run from 1 to 15 (for SCSI hard drives) and up to 63 (for IDE hard drives) and refer to the various possible partitions. Many device les are already available by default. Some of these, however, are never needed. If special device les are required for specic devices, these can be generated with the command mknod. The necessary parameters must be provided by the hardware manufacturer. The null device /dev/null is also located in this directory. Program output that would normally be sent to the screen can be redirected to this device (for example, using redirects). The redirected data will be deleted. The following are some important device les: Table 5-2
Device Terminals Device File dev/console /dev/tty1 Description The system console The rst virtual console, reachable with Ctrl+Alt+F1. The rst serial port.

Serial ports

/dev/ttyS0 /dev/ttyS* /dev/lp0 /dev/lp* /dev/fd0 /dev/fd*

Parallel ports

The rst parallel port.

Floppy disk drives

The rst oppy disk drive. If the drives are addressed via the device les fd0 and fd1, the kernel tries to recognize the oppy disk format itself.

5-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

(continued)

Table 5-2

Device IDE hard drives

Device File /dev/hda /dev/hdc

Description The rst IDE hard drive on the rst IDE controller The rst IDE hard drive on the second IDE controller To label the partitions, the device names are given numbers. Numbers 1 to 4 refer to the primary partitions, higher numbers to logical partitions. Example: /dev/hda1 is the rst primary partition on the rst IDE hard drive. The drives are named in the same way as the IDE hard drives. This means that the CD-ROM drive /dev/hdd is the second drive on the second IDE controller. The rst SCSI hard drive With SCSI hard drives, the device names are given numbers to label the various partitions. For example, /dev/sda1 is the rst primary partition on the rst SCSI hard drive. The rst SCSI CD-ROM drive.

/dev/hd*

IDE CD-ROM drives

/dev/hd*

SCSI hard drives

/dev/sda /dev/sda*

SCSI CD-ROM drives

/dev/scd0 /dev/scd*

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-9

SUSE Linux Fundamentals

Conguration Files (/etc/)


This directory and its subdirectories contain system conguration les. Almost all these les are ASCII les, which can be processed with any editor. Normal users can read nearly all of these les, but they cannot edit any of them. According to the FHS, no executable programs can be located here. However, the subdirectories contain many shell scripts. Some important conguration les are listed in the following table: Table 5-3
File /etc/SuSE-release Description Version number of the installed SUSE Linux Enterprise Server Conguration le for the init process Scripts for starting services Conguration le of GRUB Conguration le of the kernel modules Species the colors for ls Conguration le of the X Window System Table of the le systems automatically mounted at the system start Login script of the shell User database; all information except passwords Encrypted passwords of users Database of user groups Files for the CUPS printing system

/etc/inittab /etc/init.d/* /etc/grub.conf /etc/modules.conf /etc/DIR_COLORS /etc/X11/XF86Cong /etc/fstab

/etc/prole /etc/passwd

/etc/shadow /etc/group /etc/cups/*

5-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

(continued)

Table 5-3

File /etc/hosts /etc/motd

Description Allocation of computer names to IP addresses Welcome message after a user logs in (message of the day) Linux welcome message before the login prompt Central conguration les of the system

/etc/issue

/etc/syscong/*

Nearly every installed service has at least one conguration le in the directory /etc/ or a subdirectory.

User Directories (/home/)


Every user on a Linux system has his own area in which to create les and remove them. This area is called the home directory of the user. When a user logs in, he is in his own home directory. Individual conguration les can be found in the user's home directory. These conguration les are hidden les, because they are normally not displayed by the command ls. All these les have names that begin with a dot. The following are the most important les in a user's home directory: Table 5-4
File .prole .bash_history .bashrc Description Private login script of the user Conguration le for bash List of commands previously run in bash

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-11

SUSE Linux Fundamentals

If there are no special settings, the home directories of all users are located beneath the directory /home/. The home directory of a user can also be addressed via the short cut ~, so ~/.bashrc refers to the le .bashrc in the user's home directory. In many cases, the directory /home/ is located on a different partition or can even be located on a different computer (with central administration of home directories).

Libraries (/lib/)
Many programs use specic functions that are also used by other programs. Such standard functions are removed from the actual program, stored in the system, and only called up when the program runs. They are called shared libraries. The directory /lib/ contains the libraries that are used by programs in the directories /bin/ and /sbin/. The kernel modules (hardware drivers not compiled into the kernel) are located in the directory /lib/modules/. You can nd additional libraries below the directory /usr/.

Mountpoints for Removable Media (/media/*)


SUSE Linux creates directories such as the following in the directory /media/ (depending on your hardware) for mounting removable media:

/media/cdrom/. Created for mounting CD-ROMs. /media/cdrecorder/. Created for mounting CDs in a CD burner. /media/dvd/. Created for mounting DVDs. /media/floppy/. Created for mounting floppy disks.

5-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Application Directory (/opt/)


Installed programs can store their static les in the directory /opt/. First, a directory with the name of the application is created. The les are then stored in that directory. Examples include GNOME (/opt/gnome/) and KDE3 (/opt/kde3/).

Home Directory of the Administrator (/root/)


The home directory of the system administrator is not located beneath /home/ like that of a normal user. Preferably, it should be on the same partition as the root directory, /. Only then is it guaranteed that the user root can always log in without a problem and have her own congured environment available.

System Binaries (/sbin/)


The directory /sbin/ contains important programs for system administration. Programs that are run by normal users as well are located in /bin/. Programs in the directory /sbin/ can also, as a rule, be run by normal users, but only to display the congured values. Changes to the conguration can only be made by the user root. The following is an overview of important les in the directory /sbin/: Table 5-5
File /sbin/SuSEcong Description Used to congure the overall system; evaluates entries in the conguration les in the directory /etc/syscong/ and writes further conguration les.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-13

SUSE Linux Fundamentals

(continued)

Table 5-5

File /sbin/conf.d/*

Description Contains more scripts from the SuSEcong family. They are called up by /sbin/SuSEcong. Administration tool for SUSE Linux Enterprise Server. Modies partitions. Checks le systems (le system check). Initializes the system. Creates a le system (formatting). Shuts down the system.

/sbin/yast

/sbin/fdisk /sbin/fsck /sbin/init /sbin/mkfs /sbin/shutdown

Data Directories for Services (/srv/)


The directory /srv/ contains subdirectories lled with data of various services. For example, the les of the Apache web server are located in the directory /srv/www/ and the FTP server les are located in the directory /srv/ftp/.

Temporary Area (/tmp/)


Various programs create temporary les that are stored in /tmp/ until they are deleted.

The Hierarchy Below /usr/


The directory /usr/, in accordance with the FHS, represents a second hierarchical layer.

5-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

This is the location for all application programs, graphical interface les, additional libraries, locally installed programs, and commonly shared directories containing documentation. These include the following: Table 5-6
Directory /usr/X11R6/ /usr/bin/ /usr/lib/ /usr/local/ Description Files of the X Window System Almost all executable programs Libraries Locally installed programs, now frequently found in the directory /opt/ Programs for system administration Documentation The manual pages (command descriptions) Source les of all programs and the kernel (if installed)

/usr/sbin/ /usr/share/doc/ /usr/share/man/ /usr/src/

Variable Files (/var/)


The directory /var/ contains a hierarchy that is described in the FHS. This directory and its subdirectories contain les are located that can be modied while the system is running. The following table provides an overview of the most important directories beneath /var/: Table 5-7
Directory /var/lib/ Description Variable libraries (such as databases for the commands locate and rpm)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-15

SUSE Linux Fundamentals

(continued)

Table 5-7

Directory /var/log/ /var/run/ /var/spool/ /var/lock/

Description Log les for most services Files with information on running processes Directory for queues (printers, email) Lock les to protect devices from multiple use

Process Files (/proc/)


Linux handles process information that is made available to users via the directory /proc/. This directory does not contain any real les and therefore does not occupy any space on the hard disk. It is generated dynamically when it is accessed (for example, with ls /proc/). Each process has its own directory. The values in these directories can be read out as if they were in a le. Some values can also be set by writing to the corresponding les. Changes to this virtual le system only have an effect as long as the system is running, however.

5-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

For example, the process init always has the process number 1. Information about it is therefore found in the directory /proc/1/. This directory contains the following les:
da10:~ # ls -l /proc/1 total 0 dr-xr-xr-x 3 root root dr-xr-xr-x 62 root root dr-xr-xr-x 2 root root -r-------- 1 root root -r--r--r-- 1 root root lrwxrwxrwx 1 root root -r--r--r-- 1 root root -r-------- 1 root root lrwxrwxrwx 1 root root dr-x------ 2 root root -rw------- 1 root root -r--r--r-- 1 root root -rw------- 1 root root -r--r--r-- 1 root root lrwxrwxrwx 1 root root -r--r--r-- 1 root root -r--r--r-- 1 root root -r--r--r-- 1 root root dr-xr-xr-x 3 root root -r--r--r-- 1 root root

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Apr Mar Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr Apr

5 17:28 . 30 15:09 .. 5 17:36 attr 5 17:36 auxv 5 17:28 cmdline 5 17:36 cwd -> / 5 17:36 delay 5 17:36 environ 5 17:28 exe -> /sbin/init 5 17:36 fd 5 17:36 map_base 5 17:36 maps 5 17:36 mem 5 17:36 mounts 5 17:36 root -> / 5 17:28 stat 5 17:36 statm 5 17:36 status 5 17:36 task 5 17:36 wchan

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-17

SUSE Linux Fundamentals

The contents of the les can be viewed with the command cat, which shows the status of the process, as in the following:
da10:~ # cat /proc/1/status Name: init State: S (sleeping) SleepAVG: 26% Tgid: 1 Pid: 1 PPid: 0 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 32 Groups: VmSize: 588 kB VmLck: 0 kB VmRSS: 108 kB VmData: 136 kB VmStk: 8 kB VmExe: 432 kB VmLib: 0 kB Threads: 1 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: ffffffffd770d8fc SigCgt: 00000000288b2603 CapInh: 0000000000000000 CapPrm: 00000000ffffffff CapEff: 00000000fffffeff da10:~ #

In this example, a list is displayed of what the process is called (init), what state it is in (sleeping), and to which user it belongs (Uid: 0 for root). In addition to directories for each individual process, /proc/ also includes directories and les containing information about the state of the system.

5-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

The following are the most important of these: Table 5-8


File /proc/cpuinfo /proc/dma /proc/interrupts /proc/ioports /proc/lesystems /proc/modules /proc/mounts /proc/net/* Description Information about the processor Use of the DMA ports (Direct Memory Access) Use of the interrupt Use of the intrasystem I/O ports File system formats that the kernel understands Active modules Mounted le systems Network-specic information and statistics in human-readable form, for example, ip_fwchains, ip_fwnames, and ip_masquerade (IP rewall chains for kernels older than 2.4, meanwhile replaced by iptables (kernel 2.4 and 2.6)) Existing partitions Existing PCI devices Connected SCSI devices System and kernel information Kernel version

/proc/partitions /proc/pci /proc/scsi/ /proc/sys/* /proc/version

System Information Directory (/sys/)


The directory /sys/ provides information in the form of a tree structure on various hardware buses, hardware devices, active devices, and their drivers.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-19

SUSE Linux Fundamentals

Mountpoint for Temporarily Mounted File Systems (/mnt/)


The standard directory for integrating le systems is /mnt/. It should only be used for temporary purposes. For permanent mounts, you should create an appropriately named directory. In the following example, the hard drive partition /dev/hda7 is mounted at the position /mnt/ in the directory tree using the command mount:
da10:~ # mount /dev/hda7 /mnt

All les on this partition can now be reached via the directory /mnt/. To remove this partition again, you use the command umount:
da10:~ # umount /mnt

If you do not include any options with the command mount, the program tries out several le system formats. If you want to specify a specic le system, use the option -t. If the le system format is not supported by the kernel, the command is aborted, and you receive an error message. In this case, you must compile a new kernel that supports the le system format.

Directories for Mounting Other File Systems


Other le systems such as other hard drive partitions, directories from other computers via the network, or removable media (oppy disk, CD-ROM, removable hard drive) can be mounted to the le system at any point.

5-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

A directory must exist at the point where you intend to mount the le system. This directory is referred to as the mount point. The complete directory structure of the mounted le system can be found beneath this directory. In most cases, only the user root can mount and unmount directories. Removable media, such as oppy disks and CDs, can be changed by a normal user. To mount a le system, enter the command mount, specifying the device le and the directory to which the le system should be mounted. A le system can be removed again with the command umount. The le /etc/mtab, which is updated by the command mount, shows which le systems are currently mounted. You can mount le systems in directories that are occupied. The existing contents of these directories, however, will no longer be accessible. After the le system is removed, this data becomes available again. This feature lets you share certain directories with many computers. This approach is often used for the home directories of users, which are then located centrally on one machine and exported to other computers in the network. The following directories cannot be exported. They must always be located locally on each computer: Table 5-9
Directory /bin/ /boot/ /dev/ /etc/ Description Important programs Kernel and boot les Device les Conguration les

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-21

SUSE Linux Fundamentals

(continued)

Table 5-9

Directory /lib/ /sbin/

Description Libraries Important programs for system administration

The following directories can be shared: Table 5-10


Directory /home/ /opt/ /usr/ Description Home directories Applications The Hierarchy below /usr/

5-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Exercise 5-1

Explore the SUSE Linux File System Hierarchy


To understand the File System Hierarchy Standard, do the following:
1.

Describe what directories the following characters refer to:


/: ~: .: ..:

2. 3. 4. 5.

From the KDE desktop, open a terminal window. Log in as root by entering su - with a password of novell. Insert a SLES 9 CD in your CD-ROM drive. (Conditional) If a dialog appears indicating that a data CD was found, close the dialog by selecting No. Display the content of the directory /media/cdrom/ by entering ls /media/cdrom.
If your CD-ROM drive is also a CD recorder, enter ls /media/cdrecorder.

6.

x
7.

If the CD is mounted automatically, the content of the CD is listed; if not, the directory is empty. Mount the CD manually by entering mount /dev/cdrom /mnt.
If your CD-ROM drive is also a CD recorder, enter mount /dev/cdrecorder /mnt.

x
8.

A message appears indicating that the device is write-protected and is mounted as read only. Display the content of the directory /mnt by entering ls /mnt.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-23

SUSE Linux Fundamentals

The content of the CD is listed.


9.

Try to remove the CD from the drive by pushing the eject button on the drive. The CD unmounts automatically and the CD tray opens.

10. (Conditional) If the CD tray does not open, unmount the CD

manually by entering umount /mnt; then push the eject button.


11. Remove the CD from your CD drive. 12. Display the content of the directory /mnt by entering ls /mnt.

The directory is now empty.


13. Log out as user root by entering exit. 14. Close the terminal window by entering exit.
(End of Exercise)

5-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective 2

Identify File Types in the Linux System


The Linux le system is distinct from the le systems of other operating systems because of the various le types. The le types in Linux referred to as normal les and directories are also familiar to other operating systems. However, the following are additional types of les that are UNIX-specic:

Normal Files Directories Device Files Links Sockets FIFOs

Normal Files
Normal les refer to les as they are also known to other operating systems: a set of contiguous data addressed with one name. This includes all the les normally expected under this term (ASCII texts, executable programs, graphics les, etc.). The names for such les can basically be freely chosen and there is no division into le name and le type (such as report.txt). A number of le names still retain this structure, but these are requirements of the corresponding applications, such as a word processing program or a compiler.

Directories
Directories contain two entries with which the structure of the hierarchical le system is implemented.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-25

SUSE Linux Fundamentals

One of these entries (.) points to the directory itself. The other entry (..) points to the entry one level higher in the hierarchy.

Device Files
Each piece of hardware in a Linux system is represented by a device le. These les represent links between the hardware components or the device drivers in the kernel and the applications. Every program that wants to access hardware must access it through the corresponding device le. The programs write to or read from a device le. The kernel then ensures that the data nds its way to the hardware or can be read from the le.

Links
Links are references to les located at other points in the le system. Data maintenance is simplied through the use of such links. Changes only need to be made to the original le. The changes are then automatically valid for all links.

Sockets
A socket refers to a special le with which data exchange between two locally running processes can be implemented through the le system.

FIFOs
FIFO (rst in rst out) or named pipe is a term used for les used to exchange data between processes. However, the le can only exchange data in one direction.

5-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective 3

Change Directories and List Directory Contents


The prompt of a shell terminal contains the current directory (such as tux@da10:~). The tilde ~ indicates that you are in the user's home directory. You can use the following commands to change the active directory and list the contents of an directory:

ls cd pwd

ls
The command ls (list) lists the specied les. If a directory is included with ls, the directory's contents are displayed. Without an option, the contents of the current directory are listed. The following are the most important options you can use with ls: Table 5-11
Option None Meaning Displays the content of the current directory in several columns (le and directory names only). Also displays hidden les (such as .bashrc) After each name, a character indicates the le type. (/ for directories, * for executable les, | for FIFO les, @ symbolic link) (long list) Gives a detailed list of all les. For each le name, information about permissions, modication time, and size is included.

-a -F

-l

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-27

SUSE Linux Fundamentals

(continued)

Table 5-11

Option -t

Meaning Files are sorted by date of alteration. Combined with the option -r, the output takes place in reverse order (the newest le is displayed last). Output is recursive, including all subdirectories. Sorted by date of last access.

-R -u

The following are examples of using ls:


tux@da10:/ > ls var/ adm cache games lib lock log mail opt run spool tmp X11R6 yp tux@da10:/ > ls -l var/ total 2 drwxr-xr-x 10 root root 272 2004-03-29 12:31 adm drwxr-xr-x 6 root root 144 2004-03-29 11:58 cache drwxrwxr-x 2 games games 48 2004-03-23 18:41 games drwxr-xr-x 22 root root 624 2004-04-13 04:17 lib drwxrwxr-x 4 root uucp 96 2004-04-06 14:45 lock drwxr-xr-x 6 root root 800 2004-04-05 17:29 log lrwxrwxrwx 1 root root 10 2004-03-29 11:23 mail -> spool/mail drwxr-xr-x 3 root root 72 2004-03-29 11:26 opt drwxr-xr-x 12 root root 776 2004-04-08 11:21 run drwxr-xr-x 11 root root 296 2004-03-29 12:00 spool drwxrwxrwt 5 root root 144 2004-04-06 14:44 tmp drwxr-xr-x 4 root root 120 2004-03-29 11:47 X11R6 drwxr-xr-x 3 root root 104 2004-03-29 11:46 yp tux@da10:/ >

cd
You can use the command cd (change directory) to change between directories. Some examples include the following: Table 5-12
Command cd plan Meaning Change to the subdirectory plan.

5-28

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

(continued)

Table 5-12

Command cd /etc

Meaning Change directly to the directory /etc/ (absolute path). Change from any directory to the home directory. Move one directory level higher. Move two directory levels higher. Move to the last valid directory.

cd

cd .. cd ../.. cd -

pwd
You can use the command pwd (print working directory) to display the path of the current directory. If you enter pwd with the -P option, pwd prints the physical directory without any symbolic links:
tux@da10:~ > ls -l doc/ lrwxrwxrwx 1 tux users /usr/share/doc/ tux@da10:~ > cd doc/ tux@da10:~ > pwd /home/tux/doc tux@da10:~ > pwd -P /usr/share/doc tux@da10:~ >

15 2004-02-12 08:43 doc ->

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-29

SUSE Linux Fundamentals

Exercise 5-2

Change Directories and List Directory Contents


To change the active directory and list the directory contents, do the following:
1. 2. 3. 4. 5.

From the KDE desktop, open a terminal window (Konsole). Change to the directory /tmp/ by entering cd /tmp. Change to the home directory by entering cd ~. Display the name of the active directory by entering pwd. Change to the directory /usr/share/doc by entering cd /usr/share/doc. Display the name of the active directory by entering pwd. Change back to the last directory (home) by entering cd -. Display the name of the active directory by entering pwd. Display the content of the current directory by entering ls. files by entering ls -a.

6. 7. 8. 9.

10. Display the content of the current directory including the hidden 11. Display the permissions and the file size of the files starting with

D in the current directory by entering ls -l D*.


12. View the permissions and the file size of all the files in the

current directory by entering ls -la.


13. Close the terminal window by entering exit.
(End of Exercise)

5-30

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective 4

Create and View Files


To create and view les, you need to know how to do the following:

Create a New File with touch View a File with cat View a File with less View a File with head and tail

Create a New File with touch


You can use the command touch to change the time stamp of a le or create a new le with a size of 0 bytes. The following are the most important touch options: Table 5-13
Command -a Description Changes only the time of the last read access (access time). Changes only the time of the last modication (modication time). Sets the time stamp of le instead of the current time. Instead of the current time, sets

-m

-r le -t time

time (structure: [[CC]YY]MMDDhhmm.[ss] ([Century]Year] Month Day Hour Minute [Seconds], two digits in each case)).

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-31

SUSE Linux Fundamentals

The following is an example of using touch:


tux@da10:~> bin Desktop tux@da10:~> tux@da10:~> bin Desktop tux@da10:~> ls Documents public_html touch example ls Documents example public_html

View a File with cat


You can use the command cat to view the contents of a le. The command must include the lename of the le you want to see, as in the following:
tux@da10:~> cat /etc/HOSTNAME da10.digitalairlines.com tux@da10:~>

View a File with less


You can use the command less to displays the contents of a le page by page. Even compressed les (such as .gz and .bz2) can be displayed. You can use the following keystrokes with less: Table 5-14
Keystroke Spacebar b Down arrow Up arrow /pattern Description Move one screen down. Move one screen up. Move one line down. Move one line up. Search for pattern forwards from current cursor position.

5-32

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

(continued)

Table 5-14

Keystroke ?pattern

Description Search for pattern backwards from the current cursor position. Move to the next instance in the search for pattern. Move to the previous instance in the search for pattern

View a File with head and tail


With the command head, you can view only the rst few lines of a le. The command tail shows you only the last few lines of a le. By default, these commands only show ten lines. To change these number, just append the option -number. When used with the command tail, the option -f displays a continuously updated view of the last lines of a le. If a line is added at the end of the le while tail -f is running, the line is displayed. This is a very useful feature for observing log les.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-33

SUSE Linux Fundamentals

The following is an example of using the command head:


tux@da10:~> head /usr/share/doc/release-notes/RELEASE-NOTES.en.html <H1>Release Notes for SUSE Linux Enterprise Server 9 for x86</H1> <P> These release notes cover the following areas: <ul> <li>General: Information that everybody should read.</li> <li>Update: Explains changes that are not mentioned in the Admin Guide, chapter 2.</li> <li>Installation: Additional pertinent information for the Installation.</li> <li>Updates and Features: This sections contains a number of technical changes and enhancements for the experienced user.</li> <li>Providing Feedback</li> tux@da10:~> tail -5 /usr/share/doc/release-notes/RELEASE-NOTES.en.html http://www.suse.com/feedback. </P> <P> Your SUSE Linux Enterprise Team </P> tux@da10:~>

5-34

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Exercise 5-3

Create and View Files


To create and view les or parts of them, do the following:
1.

Open a terminal window, log in as root (su -) with a password of novell. Create a new, empty file by entering touch new_file. Display the content of the file /var/log/messages by entering cat /var/log/messages. Display the content of /var/log/messages page by page by entering less /var/log/messages. Find the first occurrence of the word root by entering /root. Find the next occurrence of the word root by typing n. Navigate through the output by using the cursor keys and the Page Up and the Page Down keys. Quit the display and return to the command line by typing q. Display the first 5 lines of the file /var/log/messages by entering head -n 5 /var/log/messages. /var/log/messages by entering tail -f /var/log/messages.

2. 3.

4.

5. 6. 7.

8. 9.

10. View a continuously-updated display of the last lines of the file 11. Open a second terminal window. 12. Arrange the terminal windows on the desktop so that you can see

the content of both.


13. In the second terminal window, log in as root (su -); then enter an

invalid password (such as suse). Notice that the failed login attempt is logged in the rst terminal window.
14. In the second terminal window, log in as root (su -) with a

password of novell. The login is logged in the rst terminal window.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-35

SUSE Linux Fundamentals

15. Log out as root in the second terminal window by entering exit. 16. Close the second terminal window by entering exit. 17. Stop the tail process in the first terminal window by pressing

Ctrl+C.
18. Log out as root by entering exit. 19. Close the terminal window.
(End of Exercise)

5-36

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective 5

Manage Files and Directories


In this objective, you learn how to do the following to manage les:

Copy and Move Files and Directories Create Directories Delete Files and Directories Link Files

Copy and Move Files and Directories


To copy and move les and directories, you need to know how to do the following:

Move Files With mv Copy Files With cp

Move Files With mv

You can use the command mv (move) to move one or more les to another directory, as in the following: mv *.txt /tmp You can also use the command mv to rename a le, as in the following: mv recipe new_recipe

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-37

SUSE Linux Fundamentals

The following are some important options you can use with mv: Table 5-15
Option -i Description Asks for conrmation before moving or renaming a le. This prevents existing les with the same name from being overwritten. Only moves les that are newer than the target les of the same name.

-u

Copy Files With cp

You can copy les and directories (using the option -r) with the command cp (copy). The syntax for using cp is cp source destination When using the command cp, you need to remember the following:

The command cp overwrites existing files without confirmation. You can avoid automatic overwriting by using the option -i. This option requires confirmation before overwriting occurs. If you want to copy just the contents of a directory (without the directory itself), the target directory must already exist. An example is making a backup copy of a directory using a different name.

For example, to copy the directory /tmp/quarterly-1/ with all its subdirectories to the directory /tmp/expenses/ (which already exists), you would enter the following: cp -R /tmp/quarterly-1 /tmp/expenses The result is a directory /tmp/expenses/quarterly-1/.

5-38

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

To copy the contents of the directory proposals/ (all the les contained in it, including hidden les and subdirectories) to the directory proposals_old/ (this must already exist), you would enter the following:
tux@da10:~ > . .. .hidden quarterly-4 tux@da10:~ > tux@da10:~ > . .. .hidden quarterly-4 ls -a proposals quarterly-1 quarterly-2 quarterly-3 cp -r proposals/. proposals_old ls -a proposals_old quarterly-1 quarterly-2 quarterly-3

To avoid copying the hidden les, you would enter the following:
tux@da10:~ > cp -r proposals/* proposals_old tux@da10:~ > ls -a proposals_old . .. quarterly-1 quarterly-2 quarterly-3 quarterly-4

You can use the following options with cp: Table 5-16
Option -a, --archive Description Copies a directory and subdirectories (compare -R); symbolic links, le permissions, owners, and time stamps are not changed. Displays the options of cp. Asks before overwriting. Links les instead of copying them. Copies directories recursively (the directory and any subdirectories). Makes symbolic links instead of copying Copies a le only when the source le is newer than the destination le or when the destination le is missing.

--help -i, --interactive -l, --link -R, -r, --recursive

-s, --symbolic-link -u, --update

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-39

SUSE Linux Fundamentals

Exercise 5-4

Copy and Move Files and Directories


To copy and move les and directories, do the following:
1.

Open a terminal window and log in as root (su -) with a password of novell. Rename new_file to my_file by entering mv new_file my_file. Verify that the file was renamed by entering ls -l. Copy my_file by entering cp my_file my_file1. Verify that my_file1 was created by entering ls -l my*. Copy the files /usr/bin/rename and /usr/bin/mcopy to the directory /tmp/ by entering the following: cp /usr/bin/rename /usr/bin/mcopy /tmp

2. 3. 4. 5. 6.

7. 8.

Verify that the files were copied by entering ls -l /tmp. Move the file /tmp/mcopy to the home directory by entering mv /tmp/mcopy ~. Verify the move by entering ls -l. mv /tmp/rename ~/my_file2.

9.

10. Move and rename the file /tmp/rename to ~/my_file2 by entering 11. Verify that the file my_file2 exists by entering ls -l. 12. Copy the complete directory /bin/ to the home directory with the

new directory named my_dir by entering the following: cp -r /bin /home/my_dir


13. Verify that the files were copied by entering ls -l /home/my_dir. 14. Close the terminal window.
(End of Exercise)

5-40

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Create Directories
You can use the command mkdir (make directory) to create new directories (such as mkdir proposal). The option -p lets you create a complete path, as in the following: mkdir -p proposal/january

Exercise 5-5

Create Directories
To create directories, do the following:
1.

Open a terminal window and su to root (su -) with a password of novell. Create a directory named new_dir inside the directory my_dir by entering mkdir /home/my_dir/new_dir. Verify that the directory was created by entering the following: ls /home/my_dir

2.

3.

4.

Create a directory new_dir including a new directory empty_dir by entering mkdir -p ~/new_dir/empty_dir. Verify that new_dir was created by entering ls. Verify that empty_dir was created by entering ls new_dir. Close the terminal window.

5. 6. 7.

(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-41

SUSE Linux Fundamentals

Delete Files and Directories


In this section you learn how to do the following:

Use rmdir to Delete Empty Directories Use rm to Delete Files and Directories

Use rmdir to Delete Empty Directories

You can use the rmdir (remove directory) command to remove the indicated the directory or directories (for example, rmdir proposal). The directory or directories must be empty before you can delete them.

Use rm to Delete Files and Directories

You can use the command rm (remove) to delete les, as in the following: rm part* This example deletes all les in the current directory that begin with part without asking for conrmation. If the user does not have sufcient permissions to delete a le, this le is ignored.

x
Table 5-17

Files deleted with the command rm cannot be restored.

The following are some important options you can use with rm:
Option -i -r Description Asks for conrmation before deleting. Allows full directories to be deleted.

5-42

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Exercise 5-6

Delete Files and Directories


To delete les and directories, do the following:
1.

Open a terminal window and su to root (su -) with a password of novell. Try to remove the directory ~/new_dir by entering rmdir new_dir. A message is displayed indicating that the directory cannot be removed. This is because the directory is not empty.

2.

3.

Remove the directory ~/new_dir/empty_dir by entering rmdir new_dir/empty_dir. Verify that the directory /empty_dir has been removed by entering ls new_dir. Remove the directory ~/new_dir by entering rmdir new_dir. Verify that the directory was removed by entering ls. Remove the file /home/my_dir/login by entering the following: rm /home/my_dir/login

4.

5. 6. 7.

8.

Verify that the file has been removed by entering the following: ls /home/my_dir/login

9.

Remove all files with names that begin with a in the directory /home/my_dir/ by entering rm -i /home/my_dir/a*.

10. Confirm every warning by entering y. 11. Remove the directory /home/my_dir/ including its content by

entering rm -r /home/my_dir.
12. Verify that the directory has been removed by entering

ls /home/my_dir.
13. Close the terminal window.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-43

SUSE Linux Fundamentals

Link Files
File system formats in Linux keep data and administration information separate. How data organization takes place differs from one le system format to the next. Each le is described by an inode (index node or information node). To see the inode number you can enter ls -i. Each of these inodes has a size of 128-bytes and contains all the information about this le apart from the le name. This includes information such as details of the owner, access permissions, the size, various time details (time of modication, time of access, time of modication of the inode), and the links to the data blocks of this le. The command ln creates a link. A link is a reference to a le. Through a link, you can access a le from anywhere in the le system using different names for it. This means that the le itself exists only once on the system, but it can be found under different names. Linux recognizes two kinds of links: hard links and symbolic links. You create a hard link by using the command ln, which points to the inode of an already existing le. Thereafter, the le can be accessed under both namesthat of the le and that of the link, and you can no longer discern which name existed rst or how the original le and the link differ.

5-44

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

The following is an example of using the command ln:


tux@da10:~/sell > ls -li total 4 88658 -rw-r--r-- 1 tux users 82 2004-04-06 14:21 old tux@da10:~/sell > ln old new tux@da10:~/sell > ls -li total 8 88658 -rw-r--r-- 2 tux users 82 2004-04-06 14:21 old 88658 -rw-r--r-- 2 tux users 82 2004-04-06 14:21 new tux@da10:~/sell >

Hard links can only be used when both the le and the link are in the same le system, because inode numbers are only unique within the same le system. You can create a symbolic link with the command ln and the option -s. A symbolic link is assigned its own inodethe link refers to a le, so a distinction can always be made between the link and the actual le. The following is an example of creating a symbolic link:
tux@da10:~/sell > ls -li total 4 88658 -rw-r--r-- 1 tux users 82 2004-04-06 14:21 old tux@da10:~/sell > ln -s old new tux@da10:~/sell > ls -li total 4 88658 -rw-r--r-- 1 tux users 82 2004-04-06 14:21 old 88657 lrwxrwxrwx 1 tux users 3 2004-04-06 14:27 new -> old tux@da10:~/sell >

With symbolic links, the limits of the le system can be overcome, because the name of the object is shown, not the object itself. The disadvantage is that a symbolic link can point to a non-existing object if the object and its corresponding name no longer exist.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-45

SUSE Linux Fundamentals

If you erase the le old in the above example, new will be shown as being empty:
tux@da10:~/sell > rm old tux@da10:~/sell > ls -li total 0 88657 lrwxrwxrwx 1 tux users 3 2004-04-06 14:27 new -> old tux@da10:~/sell >

Another advantage of symbolic links is that you can create links to directories.

5-46

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Exercise 5-7

Link Files
To link a le, do the following:
1.

Open a terminal window and su to root (su -) with a password of novell. Enter the following to create a symbolic link to the howto index file in the directory /usr/share/doc/howto/en/html: ln -s /usr/share/doc/howto/en/html/index.html howto-sym

2.

3.

Enter the following to create a hard link to the howto index file in the directory /usr/share/doc/howto/en/html: ln /usr/share/doc/howto/en/html/index.html howto-hard

4.

Display the links by entering ls -l. Notice that the symbolic link identies the le it is linked to.

5.

View the contents of the file /usr/share/doc/howto/en/html/index.html by entering cat howto-hard. Close the terminal window.

6.

(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-47

SUSE Linux Fundamentals

Objective 6

Find Files on Linux


In this objective you learn how to nd les and programs using the following commands:

KFind find locate whereis which type

KFind
Sometimes you need to nd a le so you can edit it, but you do not know exactly where it is located in the le system. You might know the name of this le or only a part of the name. At another time, you might need a list of all les that have been modied in the last two days or that exceed a certain size. You can use the KFind program to nd les with specic features. You can start KFind from the KDE menu with the Find Files entry. You can also start KFind directly in Konqueror by selecting Tools > Find File.

5-48

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

The following is the Knd dialog: Figure 5-3

In the Named eld, enter the name of the le you want to nd. If you don't know the entire name of the le, you can use the wild cards ? for exactly one character and * for none, one, or several characters. Suppose the following les exist:

File file File1 File1a File1b File2

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-49

SUSE Linux Fundamentals

File2a MyFile

The following table shows the results of three different search strings: Table 5-18
Search String File? Files Found File1 File2 File* File File1 File1a File1b File2 File2a ?ile* File le File1 File1a File1b File2 File2a

Enter the directory you want to search in the Look in eld. If you want to include all subdirectories in the search, select Include subfolders.

5-50

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Select the Find button to start the search process. All matching les and directories are shown in the lower window with details of their locations, as in the following: Figure 5-4

You can narrow the search by specify certain criteria in Contents and Properties. In Contents, you can specify the le type, a string contained in the le, or the le size. In Properties, you can specify the date when the le to nd was created or modied.

nd
To search for les on the command line, you can use the command nd. The following is the syntax for the command nd: nd path criterion action

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-51

SUSE Linux Fundamentals

The command has a multitude of options, a few of which are explained here. You can use the following arguments with the command:

path: The section of the file system to search (the specified directory and all its subdirectories). If nothing is specified, the file system below the current directory is used. criterion: The properties the file should have (refer to the following):
Option --ctime [+/-]days Description Searches for les whose last change took place no later than (no earlier than) a specied number of days ago. Searches for les with the numeric GID (Group ID) number. Searches for les that are owned by the group name. Instead of a name, the numeric GID is allowed. Searches for les whose names contain the given pattern. If the pattern contains meta characters or wild cards, it must be enclosed by quotation marks. Otherwise it will be interpreted by the shell and not by nd. Matches les that are above or below a certain size. As an argument, the size (in blocks of 512 byte) is given. The sufx c switches to byte and k to blocks of 1024 byte. A preceding + stands for all larger les and a - for all smaller les. Searches for a le type. A le type can be one of the following: d for a directory, f for a le, or l for a symbolic link.

Table 5-19

--gid number --group name

--name pattern

--size [+/-]size

--type le_type

5-52

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

(continued)

Table 5-19

Option --uid number --user name

Description Searches for les with the numeric UID (User ID) number. Searches for les, which are owned by user name. Instead of a name, the numeric UID is allowed.

action: Options that influence the following conditions or control the search as a whole, such as the following:

--print --exec command

With the option -exec, you can call up another command. This option is frequently used to link nd and grep as in the following:
tux@da10:~ > find ~ -name 'letter*' -type f -exec grep appointment {} \; -print appointment for next meeting: 23.08. /home/tux/letters/letter_Meier tux@da10:~ >

In this example, the command nd searches for les containing letter in their names, and then passes the names of the les found with -exec to the following command (in this case grep appointment {}). The two brackets {} stand as placeholders for the le names which are found and passed to the command grep. The semicolon closes the -exec instruction. Because this is a special character, it is masked by placing a backslash in front of it. When grep is used alone, it searches for a specic expression in a le whose exact position in the le system is known. When used in combination with nd, the search is for a le that contains a certain expression, but whose location is unknown.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-53

SUSE Linux Fundamentals

locate
The command locate is an alternative to nd -name (the package ndutils-locate must be installed). The command nd must search through the selected part of the le system, a process that can be quite slow. On the other hand, locate searches through a database previously created for this purpose (/var/lib/locatedb), making it much faster. The database is automatically created and updated daily by SUSE Linux Enterprise Server. But changes made after the update has been performed are not taken into account by locate, unless the database is updated manually using the command updatedb. The following example shows the output of locate:
tux@da10:~ > locate letter_Miller /home/tux/letters/letter_Miller

5-54

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

The following example shows that a search with locate returns all les whose names contain the search string:
tux@da10:~ > locate umount /bin/umount /lib/klibc/bin/umount /opt/kde3/share/icons/crystalsvg/scalable/devices/3floppy_ umount.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/5floppy_ umount.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/camera_u mount.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/cdaudio_ umount.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/cdrom_um ount.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/cdwriter _umount.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/dvd_umou nt.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/hdd_umou nt.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/mo_umoun t.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/nfs_umou nt.svgz /opt/kde3/share/icons/crystalsvg/scalable/devices/zip_umou nt.svgz /usr/bin/humount /usr/bin/smbumount /usr/share/man/man1/humount.1.gz /usr/share/man/man2/umount.2.gz /usr/share/man/man2/umount2.2.gz /usr/share/man/man8/smbumount.8.gz /usr/share/man/man8/umount.8.gz tux@da10:~ >

To learn more about locate, enter man locate.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-55

SUSE Linux Fundamentals

whereis
The command whereis returns the binaries (option -b), manual pages (option -m), and the source code (option -s) of the specied command. If no option is used, all this information is returned, provided the information is available. This command is faster than nd, but it is less thorough. The following is an example of using whereis:
tux@da10:~ > whereis grep grep: /bin/grep /usr/bin/grep /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz tux@da10:~ > whereis -b grep grep: /bin/grep /usr/bin/grep tux@da10:~ > whereis -m grep grep: /usr/share/man/man1/grep.1.gz /usr/share/man/man1p/grep.1p.gz tux@da10:~ > whereis -s grep grep: tux@da10:~ >

For more information about whereis, enter man whereis.

which
The command which searches all paths listed in the variable PATH for the specied command and returns the full path of the command. The command which is especially useful if several versions of a command exist in different directories and you want to know which version is executed when entered without specifying a path.

5-56

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

The following is an example of using the command which:


tux@da10:~ > which find /usr/bin/find tux@da10:~ > which cp /bin/cp tux@da10:~ > which grep /usr/bin/grep tux@da10:~ >

For more information on which, enter man which.

type
The command type command can be used to nd out what kind of command is executed when command is entereda shell built in command or an external command. The option -a delivers all instances of a command bearing this name in the le system. The following is an example of using the command type:
tux@da10:~ > type type type is a shell built in tux@da10:~ > type grep grep is /usr/bin/grep tux@da10:~ > type -a grep grep is /usr/bin/grep grep is /bin/grep tux@da10:~ >

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-57

SUSE Linux Fundamentals

Exercise 5-8

Find Files on Linux


To nd les and directories, do the following:
1. 2. 3.

Open a terminal window (you do not need to su to root). Find the type of the command ll by entering type ll. Find the manual pages of the command find by entering whereis -m find. Find the path of the program KFind by entering which kfind. Start KFind by entering kfind &. A Find Files dialog appears on the KDE desktop.

4. 5.

6.

Find all files in the home directory whose names start with my by entering my* in the Named field; then select Find. Find all files in the directory /bin/ whose names consist of 2 characters by entering ?? in the Named field and /bin in the Look in field; then select Find. Find all files in the directory /tmp/ that were changed or created in the last 24 hours by doing the following: a. b. c. e. Enter * in the Named eld and /tmp in the Look in eld. Select the Properties tab. Select Find all les created or modied. Select Find.

7.

8.

d. Select during the previous; then enter 24 in the text eld.


9.

Close the Find Files dialog. home directory whose names start with my by entering the following: nd ~ -name my*

10. From the terminal window command line, find all files in the

5-58

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

11. Find all files in the directory /tmp/ that were changed or created

in the last 24 hours by entering the following: nd /tmp -ctime -1


12. Su to root (su -) with a password of novell. 13. Create the locate database by entering updatedb.

Notice that the updatedb utility also searches for any les located on your cdrom or oppy drive to add to the database.
14. When the database is updated, find all files in your file system

whose names start with my by entering locate my*.


15. Log out as root by entering exit. 16. Close the terminal window by entering exit.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-59

SUSE Linux Fundamentals

Objective 7

Search File Content


Suppose you have dozens of text les and you need to nd all les that include a particular word, phrase, or item. To scan these les without opening them in an editor, you need to know the following:

How to Use the Command grep How to Use Regular Expressions

How to Use the Command grep


The command grep and its variant egrep are used to search les for certain patterns using the syntax grep search_pattern lename. The command searches lename for all text that matches search_pattern, and prints the lines that contains the pattern. You can also specify several les, in which case the output will not only print the matching line, but also the corresponding le names. Several options are available to specify that only the line number should be printed, for instance, or that the matching line should be printed together with leading and trailing context lines. You can specify search patterns in the form of regular expressions, although the basic grep command is limited in this regard. To search for more complex patterns, use the egrep command (or grep -E) instead, which accepts extended regular expressions. As a simple way to deal with the difference between the two commands, make sure you use egrep in all of your shell scripts. The regular expressions used with egrep need to comply with the standard regex syntax. You can read details of about this topic in the manual page of grep. To avoid having special characters in search patterns interpreted by the shell, enclose the pattern in quotation marks.

5-60

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

The following is an example of using egrep and grep:


tux@da10:~> egrep (b|B)lurb file* bash: syntax error near unexpected token `|' tux@da10:~> grep "(b|B)lurb" file* tux@da10:~> egrep "(b|B)lurb" file* file1:blurb filei2:Blurb

The following are options you can use with the command grep: Table 5-20
Option -i -l Description Ignores case. Shows only the names of les that contain the search string. Searches entire directory trees recursively. Gives all lines that do not contain the search string. Shows the line numbers.

-r -v

-n

How to Use Regular Expressions


Regular expressions are strings consisting of metacharacters and literals (regular characters and numerals). In the context of regular expressions, metacharacters are those characters that do not represent themselves but have special meanings. They can act as placeholders for other characters or can be used to indicate a position in a string. Many commands (such as egrep) rely on regular expressions for pattern matching. It is important to remember, however, that some metacharacters used by the shell for lename expansion have a meaning different from the one discussed here.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-61

SUSE Linux Fundamentals

To learn more about the structure of regular expressions, read the corresponding manual page with man 7 regex. The following table presents the most important metacharacters and their meanings: Table 5-21
Character ^ Meaning Example

Beginning of the line ^The: The is matched if at the beginning of the line End of the line eighty$: eighty is matched if at the end of line \<thing\>:matches the whole word thing \<thing\>:matches the whole word thing {abc]: matches any one of a, b, and c [a-z]: matches any one character from a to z [-:+]: any one of -, : and +

\<

Beginning of the word End of the word

\>

[abc]

One character from the set Any one from the specied range

[a-z]

[^xyz]

None of the characters

[^xyz]: x, y, and z are not matched

Any single character le.: matches le1 and le2, but not le10 One or more of the preceding expression Any number (including none) of preceding single character [0-9]+: matches any number

le.*: matches le, le2, and le10

5-62

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

(continued)

Table 5-21

Character {min,max}

Meaning The preceding expression min times at minimum and max times at maximum The expression before or after Enclose alternatives for grouping with others Zero or one of the preceding Escape the following metacharacter to remove its special meaning

Example [0-9]{1,5}: matches any one-digit to ve-digit number

le|File: matches le and File

( ...)

(f|F)ile: matches le and File

le1?2: matches both le2 and le12 www\.novell\.com: matches www.novell.com, literally (with the dot not being treated as a metacharacter); this is also necessary for parentheses, e.g., matching a parenthetical pattern would require the expression \([a-zA-Z]+\)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-63

SUSE Linux Fundamentals

Exercise 5-9

Search File Content


To search le content, do the following:
1. 2.

Open a terminal window. Find all HTML headings of hierarchy 2 in the file /usr/share/doc/release-notes/RELEASE-NOTES.en.html by entering the following (on one line): grep "<H2>" /usr/share/doc/release-notes/RELEASE-NOTES.en.html

3.

Find all locations in the HTML files of the directory /usr/share/doc/packages/cups/ that include the word management by entering the following: grep management /usr/share/doc/packages/cups/*.html

4.

Find all locations in the HTML files of the directory /usr/share/doc/packages/cups/ that include lines beginning with a number by entering the following: egrep ^[0-9] /usr/share/doc/packages/cups/*.html

5.

Find all locations in the HTML files of the directory /usr/share/doc/packages/cups/ that include lines beginning with a four digit number by entering the following: egrep ^[0-9]{4} /usr/share/doc/packages/cups/*.html

6.

Close the terminal window.

(End of Exercise)

5-64

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective 8

Archive, Compress, and Uncompress Files


To save a part of the le system structure, you need to create archives. When attaching les to an email or saving les on a removable storage, it is useful to compress them to conserve space. In this objective, you learn how to do the following to archive les:

Archive Files With ark Archive Files With tar Compress With gzip Uncompress Files with gunzip Compress Files With bzip2 Uncompress Files With bunzip2 View Compressed Files With zcat

Archive Files With ark


With the program Ark, you can collect multiple les or even entire directories into an archive. This can be very useful for doing the following:

Backing up data Preparing data to be sent via floppy disk or email

One big advantage of using Ark to back up les is that the directory structure in an archive is recreated when the archive is unpacked.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-65

SUSE Linux Fundamentals

You can start Ark from the KDE menu by selecting Utilities > Archiving. The following appears: Figure 5-5

Before you can begin archiving les, you must rst create a new archive. Select File > New to open a window in which to specify the path and name of the archive. The standard le format for archives in Linux is .tar (from tape archiver; originally this was developed for data backup on magnetic tape). Tar les can become quite large, but you can compress them. Ark carries out archiving and compressing in one step if you use .tar.gz as the le format. Ark can also handle the .zip format that is commonly used in Windows environments. Ark supports le formats such as the following:

Tar archives (*.tar, *.tar.gz, *.tar.Z, *.tar.bz2, etc.) Compressed files (*.gz, *.bz, *.bz2, *.lzo, *.Z) Zip archives (*.zip) Lha archives (*.lzh) Zoo archives (*.zoo)

5-66

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Rar archives (*.rar) Ar archives (*.a)

When you select Save, an empty archive is created at the given location. To ll the archive, drag the les you want to archive with the mouse from Konqueror into the empty window. You can open an existing archive (whether it is compressed or not) by selecting the le in Konqueror or by starting Ark and then selecting File > Open. The contents of the archive are displayed: Figure 5-6

With the mouse, you can drag individual les from the archive window and place them in a Konqueror window. You can also unpack the entire archive by selecting Action > Extract.

Archive Files With tar


The program tar (tape archiver) is the most commonly used tool for data backup. It archives les in a special format, either directly to a corresponding medium (such as magnetic tape or formatted oppy disk) or to a so-called archive le.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-67

SUSE Linux Fundamentals

Normally, the data is not compressed. By convention, names of archive les end in .tar. If archive les are compressed (usually with the command gzip, then the extension of the le name is either .tar.gz or .tgz. The command tar requires an option (which is why you don't need to use a minus sign), the name of the archive (or the device le) to be written to, and the name of the directory to be backed up. All directories and les beneath the specied directory are also saved. Directories are typically backed up with a command similar to the following: tar -cvf /dev/st0 /home This command backs up the complete contents of the directory /home to the tape device /dev/st0 (this is the rst SCSI tape drive). The option -c (create) creates the archive. The option -v (verbose) provides a detailed list; that is, the name of each le just backed up is displayed. The name of the archive to be created is specied after the option -f (le). This can either be a device le (such as a tape drive) or a standard le, as in the following: tar -cvf /backup/etc.tar /etc In this example, the archive etc.tar is created. It contains all les from the directory /etc. When an archive is created, absolute paths are by default made relative; that is, the leading / is removed and the following message appears:
tar: Removing leading `/' from member names

To repackage the les from an archive, you can enter a command similar to the following: tar -xvf /dev/st0

5-68

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

This causes all les in the archive to be written to the current directory. Because of the relative path specications in the tar archive, the directory structure is created in the current directory. If you want to extract the les to another directory, you can use the option -C, followed by the directory name. If you want to extract a single le, you need to specify the name of the le, as in the following:
da10:~ # tar -xvf /test1/test.tar -C /test2 home/user1/.bashrc

You can use the following options with tar: Table 5-22
Option -c Description Creates an archive.

-C -d

Changes to the specied directory. Compares les in the archive with those in the le system. Uses the specied archive le or device. Directly compresses or decompresses the tar archive using bzip2 (see below). Appends les to an archive. Only includes les in an archive which are newer than the version in the archive (update). Displays the les which are being processed (verbose mode). Extracts les from an archive. Excludes les listed in a le.

-f -j

-r -u

-v

-x -X

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-69

SUSE Linux Fundamentals

(continued)

Table 5-22

Option -z

Description Directly compresses or decompresses the tar archive using gzip (see below).

If you want to exclude specic les from the backup, you must create a le that lists the names of the les to exclude, with each lename on a separate line. You then specify this list with the option -X, as in the following:
da10:~ # cat exclude.files /home/user1/.bashrc /home/user2/Text* da10:~ # tar -cvf /dev/st0 /home -X exclude.files

In this example, the le /home/user1/.bashrc and all les in the directories of the user user2 which start with the string Text are not saved to tape. You can display the contents of an archive by entering a command similar to the following command: tar -tvf /dev/st0 If you want to back up only les which are more recent than a specic le, then you should use a combination of the commands nd and tar, as in the following:
da10:~ # find /home -type f -newer last_backup -print0 | \ tar --null -cvf neu.tar -T -

In this example, the command archives all les (-type f) in the directory /home/ which are younger than the le last_backup. The options -print0 and --null ensure that les featuring spaces in their names are also archived. The option -T - determines that les piped to stdin are supposed to be included in the archive.

5-70

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Exercise 5-10

Archive Files
To archive les, do the following:
1.

Start the Ark utility from the KDE menu by selecting Utilities > Archiving. An Ark dialog appears on the KDE desktop.

2.

From the dialog, create a new archive by doing the following: a. b. c. e. Select File > New. A Create New Archive - Ark dialog appears. Change to the geeko home directory by selecting the up arrow button once. In the Location eld, enter unzipped_le. Select Save.

d. From the Archive format drop-down list select Tar Archive.


3.

Copy all the files in the directory /bin to the tar archive by doing the following: a. b. c. Start Konqueror by selecting the icon in the Kicker. Display the les in directory /bin. Select all les in the directory by selecting Edit > Selection > Select All (or press Ctrl+A).

d. Copy the les in the directory /bin to the Ark window by dragging and dropping the les. e.
4. 5. 6.

Close the Konqueror window.

From the Ark dialog, select File > Quit; then select Save (twice). Open a terminal window (do not su to root). Create a zipped archive of the same files at the command line by entering tar czvf zipped_file.tar.gz /bin. Start Konqueror by selecting the blue house icon in the Kicker. Select the icon of the file zipped_file.tar.gz.

7. 8.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-71

SUSE Linux Fundamentals

9.

Select the bin directory icon. left side of the Konqueror window.

10. View the navigation area by selecting the red folder icon at the 11. Copy the file df to the directory /tmp by using drag-and-drop. 12. Close the Konqueror window. 13. From the terminal window, copy the file unzipped_file.tar to the

directory /tmp by entering cp unzipped_file.tar /tmp.


14. Switch to the directory /tmp by entering cd /tmp. 15. Verify that the file was copied by entering ls -l un*. 16. Extract the files of the archive /tmp/unzipped_file.tar by entering

tar xvf unzipped_file.tar.


17. Switch to the home directory by entering cd -. 18. Close the terminal window.
(End of Exercise)

5-72

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Compress With gzip


Linux offers various tools for compressing and decompressing data. One tool is called gzip, which uses the following syntax: gzip options le The command gzip can be used to compress and decompress data. The compressed data is marked with the sufx .gz. This command is only suitable for compressing individual les. To save several les or entire directories in a compressed le, use the command tar. The following are some useful options of gzip: Table 5-23
Option -c, --stdout, --to-stdout Description Compresses the le without modifying the original le. The result is written to the standard output (usually the screen). From there, it can be redirected to a le with >. Decompresses the specied le (compare gunzip; see below). Controls the compression speed: -1 means --fast and causes a quick compression but produces larger les, -9 corresponds to --best and requires more computing time but produces smaller les. The default setting is -6. Compresses and decompresses les in all subdirectories.

-d, --decompress, --uncompress

-1 to -9, --fast, --best

-r, --recursive

In the following example, the command gzip compresses all .tex les in the current directory, resulting in les with the sufx .tex.gz:

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-73

SUSE Linux Fundamentals

gzip *.tex In the following example, the command gzip compresses the le price_list: gzip -c price_list > price_list_backup.gz The le itself is not modied. The result of the compression is written to the le price_list_backup.gz.

Uncompress Files with gunzip


The command gunzip decompresses a le compressed with gzip and removes the sufx .gz. This function corresponds to the command gzip -d le. The syntax for the command gunzip is: gunzip le.gz.

Compress Files With bzip2


The command bzip2 is another command for compressing les, resulting in les that are usually about twenty to thirty percent smaller than the les compressed with gzip. The syntax for the command bzip2 is: bzip2 options le. The disadvantage of using this command is that more computing time is required for the compression.

5-74

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

The following are some important options you can use with bzip2: Table 5-24
Option -c, --to-stdout Description Compresses the le without modifying the original le. The result is written to the standard output (usually the screen). From there, it can be redirected to a le with > (see gzip above). Decompresses the specied le (compare bunzip2; see below). Determines how much memory is allocated for the compression: -1 requires 1.1 MB; -9 requires 6.7 MB. The default setting (which is -9) produces the best result.

-d, --decompress, --uncompress

-1 to -9

Uncompress Files With bunzip2


The command bunzip2 decompresses a le compressed with bzip2 and removes the sufx bz2. Its function corresponds to the command bzip2 -d le. The syntax for the command bunzip2 is: bunzip2 le.bz2.

View Compressed Files With zcat


The command zcat can be used to decompress les compressed with gzip and write them to the standard output (usually the screen). The compressed le is not modied. The function of zcat corresponds to the command gunzip -c -d. The syntax for the command zcat is: zcat le.gz.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-75

SUSE Linux Fundamentals

Exercise 5-11

Compress and Uncompress Files with gzip and bzip2


To compress and uncompress les, do the following:
1. 2.

Open a terminal window. Copy the file /usr/share/doc/release-notes/RELEASE-NOTES.en.html to the home directory by entering the following (on one line): cp /usr/share/doc/release-notes/RELEASE-NOTES.en.html ~ The tilde (~) indicates to copy the le to the home directory.

3.

Verify that the file was copied by entering ls RELEASE-NOTES.en.html. Compress with gzip the file RELEASE-NOTES.en.html by entering the following: gzip RELEASE-NOTES.en.html

4.

5.

Verify that the file was compressed by entering ls. Notice that the le RELEASE-NOTES.en.html.gz has replaced RELEASE-NOTES.en.html.

6.

Display the content of the file RELEASE-NOTES.en.html.gz by entering the following: zcat RELEASE-NOTES.en.html.gz

7.

Decompress the file RELEASE-NOTES.en.html.gz with gunzip by entering the following: gunzip RELEASE-NOTES.en.html.gz

8.

Verify that the file was decompressed by entering ls. Notice that the le RELEASE-NOTES.en.html has replaced RELEASE-NOTES.en.html.gz.

5-76

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

9.

Compress the file unzipped_file.tar in the geeko home directory using bzip2 by entering the following: bzip2 unzipped_le.tar

10. Compare the size of the files unzipped_file.tar.bz2 and

zipped_file.tar.gz by entering the following: ls -l *zipped_le.tar.*


11. Close the terminal window.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-77

SUSE Linux Fundamentals

Objective 9

Manage File Permissions and Ownership


You can change the current values associated with ownership and permissions by knowing how to do the following:

Change the File Permissions With chmod Change the File Ownership With chown and chgrp

Change the File Permissions With chmod


You can use the command chmod to add (+) or remove (-) permissions. Both the owner of a le and root can use this command. The following are examples of using the command chmod: Table 5-25
Example chmod u+x Result The owner is given permission to execute the le. All group members can read and write. The owner receives all permissions. All permissions for the owner, read and write for the group, read for all other users. All users (owner, group, others) receive executable permission (depending on umask). All users (owner, group, others) receive executable permission (a for all).

chmod g=rw

chmod u=rwx

chmod u=rwx,g=rw,o=r

chmod +x

chmod a+x

5-78

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

In the following example, the user tux allows the other users in the group users to write to the le hello.txt by using chmod:
tux@da10:~ -rw-r--r-tux@da10:~ tux@da10:~ -rw-rw-r-> 1 > > 1 ls -la hello.txt tux users 0 2004-04-06 12:40 hello.txt chmod g+w hello.txt ls -la hello.txt tux users 0 2004-04-06 12:40 hello.txt

With the option -R and a specied directory, you can change the access permissions of all les and subdirectories under the specied directory. Besides using letters (rwx), you can also use the octal way of representing the permission letters with groups of numbers: Table 5-26
Owner rwx 421 Group rwx 421 Others rwx 421

By using number equivalents, you can add the numbers together, as in the following: Table 5-27
Owner rwx 421 (4+2+1=7) Group rwx 42- (4+2=6) Others r-x 4-1 (4+1=5)

The following are examples of using numbers instead of letters: Table 5-28
Example chmod 754 hello.txt Result All permissions for the owner, read and execute for the group, read for all other users.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-79

SUSE Linux Fundamentals

(continued)

Table 5-28

Example chmod 777 hello.txt

Result All users (user, group, others) receive all permissions.

Change the File Ownership With chown and chgrp


The user root can use the command chown to change the user and group afliation of a le by using the following syntax: chown new_user.new_group le To change only the owner, not the group, you can use the following command syntax: chown new_user le To change only the group, not the user, you can use the following command syntax: chown .new_group le As root, you can also change the group afliation of a le with the command chgrp using the following syntax: chgrp new_group le A normal user can use the command chown to allocate a le that he owns to a new group by using the following syntax: chown .new_group le The user can also do the same with chgrp using the following syntax: chgrp new_group le The user can only change the group afliation of the le that he owns if he is a member of the new group.

5-80

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

In the following example, root changes the ownership of the le hello.txt from tux to the user newbie by using chown:
da10:/tmp # ls -la hello.txt -rw-r--r-- 1 tux users 0 2004-04-06 12:43 hello.txt da10:/tmp # chown newbie.users hello.txt da10:/tmp # ls -la hello.txt -rw-r--r-- 1 newbie users 0 2004-04-06 12:43 hello.txt da10:/tmp #

In the following example, chown is used to limit access to the le list.txt to members of the group advanced:
da10:/tmp # ls -la list.txt -rw-r----- 1 tux users 0 2004-04-06 12:43 list.txt da10:/tmp # chown .advanced list.txt da10:/tmp # ls -la list.txt -rw-r----- 1 tux advanced 0 2004-04-06 12:43 list.txt da10:/tmp #

Of course, root and the le owner continue to have rights to access the le. Although the group has changed, the owner permissions remain the same.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-81

SUSE Linux Fundamentals

Exercise 5-12

Manage File Permissions and Ownership


To manage le permissions and ownership, do the following:
1. 2.

Open a terminal window (do not su to root). Allow only the user geeko to read and write the file unzipped_file.tar.bz2 by entering the following: chmod 600 unzipped_le.tar.bz2

3.

Verify that the change was made by entering ls -l. Notice that geeko is the owner of the le, and that the only permissions assigned to the le are rw for the le owner. Also notice that others can read (r) the contents of the le zipped_le.tar.gz.

4.

Remove the read permission for others of the file zipped_file.tar.gz by entering the following: chmod o-r zipped_le.tar.gz

5.

Make sure that the permissions are correct by entering ls -l *zipped_le.tar.*

6. 7. 8.

Su to root (su -) with a password of novell. Create a file df by entering touch df. Verify that the file was created by entering ls -l df. Notice that the owner of the le is root, and that the le group is also root.

9.

Change the owner of the file df to nobody by entering chown nobody df. chgrp nogroup df.

10. Change the group of the file df to nogroup by entering 11. Make sure that the settings are correct by entering ls -l df. 12. Log out as user root by entering exit.

5-82

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

13. Close the terminal window.


(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-83

SUSE Linux Fundamentals

Summary
Objective
1. Understand the File System
Hierarchy Standard (FHS)

Summary The Linux le system involves a hierarchical le system that can be depicted in the form of a tree. This tree is not limited to a local partition, but can stretch over several partitions, which can be located on different computers in a network. The separation character between individual directory names is the slash (/). The path can be specied in two ways:

As a relative path As an absolute path

The structure of the le system is described in the Filesystem Hierarchy Standard (FHS).
2. Identify File Types in the Linux
System

The 6 le types in Linux include the following:


Normal les Directories Links Device les Sockets FIFOs

5-84

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective
3. Change Directories and List
Directory Contents

Summary The current directory is shown in the prompt of a shell terminal: tux@da10:~. The tilde ~ shows, you are in the user's home directory. With cd (change directory), change between directories. The command pwd (print working directory) shows the path of the current directory. The command pwd combined with the option -P prints the physical directory without any symbolic links. The command ls (list) lists the les specied. If a directory is specied, its contents are displayed. Without an option, the contents of the current directory are shown.

4. Create and View Files

With touch, change the time stamp of a le or create a new le with a size of 0 bytes. With the command cat, the contents of the le can be displayed. The command needs the lename of the le you want to see. less displays the contents of a le page by page. Even compressed les (.gz, .bz2 ...) can be displayed.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-85

SUSE Linux Fundamentals

Objective
4. Create and View Files (continued)

Summary With head you can view only the rst few lines. The opposite is the command tail, which shows you only the last few lines of a le. By default ten lines are shown by the two commands. To change these number, just append the option -number. With the option -f, tail shows you permanent the last lines of a le.

5. Manage Files and Directories

mv (move) moves one or more les to another directory or renames a le. Copying les and directories (with the option -r) is done with the command cp (copy): cp source destination. Existing les are overwritten without conrmation. With mkdir (make directory), create new directories. The option -p allows you to create a complete path. With rmdir (remove directory) the directory or directories given are deleted. The directory or directories must be empty. The command rm (remove) is used to delete les. With the option -i you are asked for conrmation before deleting.

5-86

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective
5. Manage Files and Directories
(continued)

Summary The option -r you allows full directories to be deleted. Files that are deleted with this command cannot be restored. A link is a reference to a le

Hard links can only be used when both the le and the link are in the same le system, because the inode numbers of link and target are identical.
A symbolic link is assigned its own inodethe link refers to a le, so distinction can always be made between the link and the actual le. A symbolic link can made with the option -s.
6. Find Files on Linux

The KFind program can be used to nd les with specic features. KFind can be started from the KDE menu with the Find Files entry or directly in Konqueror using the menu item Tools > Find File... To search for les, the command nd is helpful: nd path criterion action The command has a multitude of options, the most important option is -name, which searches for les with the given name.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-87

SUSE Linux Fundamentals

Objective
6. Find Files on Linux (continued)

Summary An alternative to nd -name is the command locate (package ndutils-locate must be installed). locate searches through a database previously created for this purpose, thus making it much faster. The database is automatically created and updated daily by SLES or manually using the command updatedb. whereis command returns the binaries (option -b), manual pages (option -m), and the source code (option -s) of the specied command. which command searches all paths listed in the variable PATH, for the specied command and returns the full path of the command. The command type command (a shell built in) can also be used to nd out what kind of command is executed when command is entered, a shell built in or an external command.

5-88

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective
7. Search File Content

Summary The command grep and its variant egrep are used to search les for certain patterns, according to this syntax: grep search_pattern lename The command prints lines that contains the given search pattern. It is also possible to specify several les, in which case the output will not only print the matching line, but also the corresponding le names. Search patterns can be supplied in the form of regular expressions, although the bare grep command is limited in this regard. To search for more complex patterns, use the egrep command (or grep -E) instead, which accepts extended regular expressions. Regular expressions are strings consisting of metacharacters and literals. In the context of regular expressions, metacharacters are those characters that do not represent themselves but have special meanings:

^: beginning of the line

$: end of the line \<: beginning of the word \>: end of the word

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-89

SUSE Linux Fundamentals

Objective
7. Search File Content (continued)

Summary [abc]: one character from the set [a-z]: any one from the specied range [^xyz]: none of the characters .: any single character +: one or more of the preceding expression *: any number (including none) of preceding single character {min,max}: the preceding expression min times at minimum and max times at maximum |: the expression before or after (...): enclose alternatives for grouping with others ?: zero or one of the preceding \: escape the following metacharacter to remove its special meaning

8. Archive, Compress, and


Uncompress Files

With the program Ark, You can collect multiple les or even entire directories into an archive. The directory structure in an archive is recreated after unpacking. You can start Ark from the KDE menu by selecting Utilities > Archiving. tar (tape archiver) is the most commonly used tool for data backup at the command line.

5-90

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective
8. Archive, Compress, and
Uncompress Files (continued)

Summary Without a special option, the data is not compressed. Some options:

-c: Creates an archive. -C: Changes to the specied directory. -d: Compares les in the archive with those in the le system. -f name: Uses the specied archive le or device. -j: Directly compresses or decompresses the tar archive using bzip2. -r: Appends les to an archive. -u: Only includes les in an archive which are newer that the version in the archive (update). -v: Displays the les, which are being processed (verbose mode). -x: Extracts les from an archive. -X: Excludes les listed in a le. -z: Directly compresses or decompresses the tar archive using gzip.

gzip is a tool for compressing and decompressing data. Some options:

-c: Compresses the le without modifying the original le. -d: Decompresses the specied le.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-91

SUSE Linux Fundamentals

Objective
8. Archive, Compress, and
Uncompress Files (continued)

Summary

-n: Controls the compression speed. -1 means --fast and causes a quick compression but produces larger les. -9 corresponds to --best and requires more computing time but produces smaller les. The default setting is -6. -r: Also compresses and decompresses les in all subdirectories.

The command gunzip decompresses a le compressed with gzip. bzip2 is another command for compressing les, resulting in les that are usually about twenty to thirty percent smaller than the les compressed with gzip. The most options are equal to gzip. bunzip2 decompresses a le compressed with bzip2. zcat can be used to decompress les compressed with gzip and write them to the standard output. The compressed le is not modied.

5-92

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage Directories and Files in the Linux System

Objective
9. Manage File Permissions and
Ownership

Summary File permissions can be changed with chmod and can be given as addition (adds permissions), subtraction (removes permissions), or explicitly. With the option -R and a specied directory it is possible to change the access permissions of all les and subdirectories under this directory. root can use the command chown to change the user and group afliation of a le.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

5-93

SUSE Linux Fundamentals

5-94

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

SECTION 6

Work With the Linux Shell and Command Line

In this section you learn about the basic features of the bash shell. In addition, you are introduced to some important administration commands.

Objectives
1. 2. 3. 4. 5. 6. 7. 8.

Get to Know the Command Shells Understand Command Syntax and Special Characters Execute Commands at the Command Line Get to Know Common Command Line Tasks Use Piping and Redirection Manage User Accounts Execute RPM Package-Related Operations Use the Basic Linux mail Command

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-1

SUSE Linux Fundamentals

Objective 1

Get to Know the Command Shells


You cannot communicate directly with the operating system kernel. You need to use a program that serves as an interface between the user and operating system. In the operating systems of the UNIX family, this program is called the shell. The shell accepts a user's entries, interprets them, converts them to system calls, and delivers system messages back to the user, making it a command interpreter. To understand command shells, you need to know the following:

Types of Shells Bash Configuration Files File Name Restrictions Completion of Commands and File Names

Types of Shells
UNIX has a whole series of shells, most of which are provided by Linux in freely usable versions. The following are examples of some popular shells:

The Bourne shell (/bin/sh) The Bourne again shell (/bin/bash) The Korn-Shell (/bin/ksh) The C-Shell (/bin/tcsh) The TC-Shell (/bin/tcsh)

The various shells differ in the functionality they provide.

6-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Every shell can be started like a program and you can switch at any time to a different shell. For example, you can switch to the C shell by entering csh or tcsh; you can switch to the TC shell by entering bash or to the bash shell by entering sh. Unlike most other programs, the shell does not close on its own. You need to enter the command exit to return to the previous shell. A shell is started at a text console right after a user logs in. This is called the login shell. Which shell is started for which user is determined in the user database. The standard Linux shell is bash, so we will only cover bash shell in this objective.

Bash Conguration Files


To customize bash for an interactive session, you need to know about the conguration les and about the order in which they are processed. To understand how shells work, you need to know the difference between the following:

Login Shells Non-Login Shells

Login Shells

A login shell is started whenever a user logs in to the system. By contrast, any shell started from within a running shell is a non-login shell. The only differences between these two are the conguration les read when starting the shell.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-3

SUSE Linux Fundamentals

A login shell is also be started whenever a user logs in through an X display manager. Therefore, all subsequent terminal emulation programs run non-login shells. The following les are read when starting a login shell:

/etc/profile. A system-wide configuration file read by all shells. It sets global configuration options. ~/.profile. A file created for each new user by default on the SUSE Linux Enterprise Server. Any user-specific customizations can be stored in it. It will be read not only by bash, but also by other shells. ~/.bashrc. A read-only configuration file in which users store their customizations. ~/.bash_profile. The first user-level configuration file that bash tries to find. It contains user customizations (for example, to change the command prompt). By default, this file is not present on the SUSE Linux Enterprise Server. ~/.bash_login. The second user-specific file that bash tries to find. By default, this file is not created on the SUSE Linux Enterprise Server. The counterpart to the le ~/.bash_login is the le ~/.bash_logout. The actions to be performed when the user logs out can be set in this le. By default, this le is not created on the SUSE Linux Enterprise Server.

Non-Login Shells

Only the ~/.bashrc le is read when a non-login shell is started: Most Linux distributions have a default setup that ensures users do not see any difference between a login shell and a non-login shell. In most cases, this is achieved by also reading the ~/.bashrc le when a login shell is started.

6-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

If you change any settings and want them to be applied during the same shell session, the changed conguration le needs to be read in again. The proper way to read in a changed conguration le and to apply the changes to the current session is by using the internal shell command source, as in the following example: source .bashrc You can also use the short form of this command, which happens to be included in many conguration les, where it is used to read in other conguration les, as in the following (with a space between the periods): . .bashrc

File Name Restrictions


A lename in Linux can be up to 255 characters long. It can contain any number of special characters (_ or %, for example). Certain special characters (the dollar sign $, the semicolon ;, or the space, for example) have a specic meaning. If you want to use one of these characters without the associated special meaning, the character must be preceded by a \ (backslash) so its special meaning is masked (switched off). Umlauts, letters with diacritical marks, or other country-specic characters can be used. Using them, however, can lead to problems when exchanging data with people in other countries using other settings if these characters are not present on their keyboards. Linux differentiates between upper-case and lower-case letters. For example, Invoice, invoice, and INVOICE identify three different les.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-5

SUSE Linux Fundamentals

Completion of Commands and File Names


The bash shell supports a function of completion commands and le names. Just enter the rst characters of a command (or a lename) and press the Tab key. The bash shell completes the name of the command. If there is more than one possibility, the bash shell shows all possibilities when you press the Tab key a second time. This feature makes entering long lenames very easy.

6-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective 2

Execute Commands at the Command Line


If you do not have a graphical user interface, you can use the following to help make entering shell commands to administer SUSE Linux Enterprise Server much easier:

History Function Switch to User root

History Function
bash stores the commands you enter so you have easy access to them. By default, the commands are written in the le .bash_history in the user's home directory. In SUSE Linux Enterprise Server, the size of this le is set to 1000 entries. You can display the content of the le by using the command history. You can display the commands stored in the history cache (one at a time) by using the arrow keys. The up-arrow shows the previous command; the down-arrow shows the next command. After nding the desired command, edit it as needed then execute it by pressing Enter. When browsing the entries of the history, you can also select specic commands. Typing one or several letters, or pressing Page Up or Page Down, displays the preceding or next command in the history cache beginning with this letter. If you enter part of the command (not necessarily the beginning of the command), pressing Ctrl+R searches the history list for matching commands and displays them. Searching starts with the last command executed.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-7

SUSE Linux Fundamentals

Switch to User root


If you are working with a shell, you can become root by entering the su - command and the root password. If you want to start a graphical application from the shell, you have to use the sux - command instead, as in the following: Figure 6-1

You can check to make sure you are root by entering id or whoami. To leave the root administrator shell, you enter the command exit.

6-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

If you are working with Konsole, you can start a separate root shell by selecting Session > New Root Console: Figure 6-2

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-9

SUSE Linux Fundamentals

Exercise 6-1

Execute Commands at the Command Line


To execute commands at the command line, do the following:
1. 2. 3.

Open a terminal window. View the history cache by entering history. Press Up-arrow until you see an ls command you would like to execute; then press Enter. Type h and press Page Up once. You should see the command history at the command line again.

4.

5. 6. 7.

Press Enter to execute the history command. Switch to root by entering sux ; then enter a password of novell. Start YaST by entering yast2. YaST should start in QT mode.

8. 9.

Quit YaST by selecting Close. Become the user geeko again by entering exit.

10. Su to root by entering su ; then enter a password of novell. 11. Check to make sure you are logged in as root by entering id. 12. Start YaST by entering yast2.

YaST should start in ncurses mode.


13. Quit YaST by entering Alt+Q. 14. Log out as root by entering exit. 15. Close the terminal window by entering exit.
(End of Exercise)

6-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective 3

Get to Know Common Command Line Tasks


Two features make working with the bash shell more powerful:

Variables Aliases

Variables
With shell and environment variables, you are able to congure the behavior of the shell and to adjust its environment to your own requirements. The convention is to write variables such as PATH in uppercase letters. If you set your own variables, they should also be written in capitals for the sake of clarity. Environment variables are used to control the behavior of a program that is started from a shell. Shell variables, on the other hand, are used to control the behavior of shell itself. Some important environment variables include the following:

PATH. When a program is called up, the program is searched for in the directories specified here (each separated by :). The order in which directories are listed is important, since they are searched in turn. HOME. The user's home directory. USER. The login name of the actual user.

To display the value of a shell or environment variable, enter echo variable, as in the following:
tux@da1:~ > echo $HOME /home/tux

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-11

SUSE Linux Fundamentals

To set the value of a variable or to crate a new variable, use the syntax variable=value, as in the following:
da1:~ # MYVAR=myvalue da1:~ # echo $MYVAR myvalue da1:~ #

The value can be a number, a character or a string. If the sting includes a space, you have to write the value in full quotes, as in the following:
da1:~ # MYVAR=my value da1:~ # echo $MYVAR my value da1:~ #

Aliases
Dening aliases allows you to create shortcuts for commands and their options or to create commands with entirely different names. On a SUSE system, whenever you enter the commands dir, md, or ls, for instance, you will be using aliases. You can nd out about the aliases dened on your system with the command alias. This will show you that dir, for instance, is an alias for ls -l and that md is an alias for mkdir -p. The following are examples of aliases through which new commands are dened:
tux@da1:~> alias md alias md='mkdir -p' tux@da1:~> alias dir alias dir='ls -l'

6-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

To see whether a given command is an alias for something else, use the type command. For each command specied, type will tell you whether it is a built-in shell command, a regular command, a function, or an alias. For regular commands, the output of type lists the path to the corresponding executable. For aliases, it lists the elements aliased:
tux@da1:~> type -a ls ls is aliased to `/bin/ls $LS_OPTIONS' ls is /bin/ls

The above example shows that ls is an alias although, in this case, it is only used to add some options to the command. The -a option was used with type to show both the contents of the alias and the path to the original ls command. The output shows that ls is always run with the options stored in the variable LS_OPTIONS. These options cause ls to list different le types in different colors (among other things). Most of the aliases used on a system-wide basis are dened in the le /etc/bash.bashrc. Aliases are dened with the alias command and can be removed with the unalias command. For example, entering unalias ls removes the alias for ls, causing ls to stop coloring its output. The following is the syntax for dening aliases: alias aliasname="command options"

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-13

SUSE Linux Fundamentals

An alias dened in this way is only valid for the current shell and will not be inherited by subshells, as in the following:
tux@da1:~> tux@da1:~> Hello tux@da1:~> tux@da1:~> PID TTY 858 pts/0 895 pts/1 ... alias ps="echo Hello" ps bash ps TIME CMD 00:00:00 bash 00:00:00 bash

To make an alias persistent, you need to store the denition in one of the shell's conguration les. On the SUSE Linux Enterprise Server, the le ~/.alias is created for personal aliases dened by each user. This le is read in by ~/.bashrc, where a command is included to that effect. Aliases are not relevant to shell scripts at all, but can be a real time saver when using the shell interactively.

6-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Exercise 6-2

Perform Common Command Line Tasks


To understand common command line tasks, do the following with the command alias:
1. 2. 3.

Open a terminal window. View all defined aliases by entering alias. Define a new alias by entering the following: alias hello='echo hello $USER'

4. 5.

Check the functionality of the alias hello by entering hello. Check the command type of the command hello by entering type hello. Remove the alias by entering unalias hello. Close the terminal window.

6. 7.

(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-15

SUSE Linux Fundamentals

Objective 4

Understand Command Syntax and Special Characters


You can use specic characters to provide special functionality. Using them can save you a lot of time and effort. In this objective you will learn about the following:

Name Expansion Using Search Patterns Prevent the Shell from Interpreting Special Characters

Name Expansion Using Search Patterns


Occasionally, you might want to perform operations on a series of les without having to name all the les. In this case, you could make use of the following search patterns: Table 6-1
Search Pattern ? * Description Any single character (except /). Any string length, including zero characters (except . at the beginning of a le name and /). Any of the characters enclosed (here: lowercase letters from a to z). Any character from the ranges a-e and k-s. Any of these characters. None of these characters.

[a-z]

[a-ek-s] [abcdefg] [!abc]

6-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

The following is an example of using some of these search patterns:


tux@da1:/usr/X11/bin > ls xc* xcalc xclipboard xclock xcmsdb xconsole xcursorgen xcutsel tux@da1:/usr/X11/bin > ls xc[alo]* xcalc xclipboard xclock xconsole tux@da1:/usr/X11/bin > ls xc[!o]* xcalc xclipboard xclock xcmsdb xcursorgen xcutsel tux@da1:/usr/X11/bin > ls xc*l* xcalc xclipboard xclock xconsole xcutsel

If search patterns (wild cards) are given on the command line, the shell tries to compare these with the lenames in the le system and, if they match, the expression is replaced with all the lenames found.

Prevent the Shell from Interpreting Special Characters


To prevent the shell from interpreting special characters in the command line, these characters must be masked by using the following:

\: The backslash protects exactly one character from being interpreted by the shell, as in the following: mkdir new \ directory

"...": Double quotes protect all special characters except $, \, and ` (back tick) from being interpreted by the shell, as in the following:
tux@da1:~ > echo "$HOME" /home/tux tux@da1:~ >

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-17

SUSE Linux Fundamentals

'...' Apart from regular expressions, variables are also protected with single quotes, as in the following:
tux@da1:~ > echo '$HOME' $HOME

6-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Exercise 6-3

Work With Command Syntax and Special Characters


To understand how to use command syntax and special characters, do the following:
1. 2.

Open a terminal window. List all filenames in the directory /bin/ that start with the character a by entering ls /bin/a*. List all file names in the directory /bin/ that consist of 4 characters by entering ls /bin/????. List all filenames in the directory /bin/ that consist of 4 or more characters by entering ls /bin/????*. List all filenames in the directory /bin/ that do not start with one of the characters from a to r by entering ls /bin/[!a-r]*. Start the file manager Konqueror by selecting the blue house icon in Kicker. Create a new file by right-clicking the file view window and selecting Create New > File > Text File. Enter a filename of My; then select OK. Create a new file by right-clicking the file view window and selecting Create New > File > Text File.

3.

4.

5.

6.

7.

8. 9.

10. Enter a filename of File; then select OK. 11. Create a new file by right-clicking the file view window and

selecting Create New > File > Text File.


12. Enter a filename of My File; then select OK. 13. Close the Konqueror window. 14. From the terminal window, list the files My and File by entering

ls -l My File.
15. List the file My File by entering ls -l My\ File. 16. Remove the files My, File, and My File by entering

rm My File My\ File.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-19

SUSE Linux Fundamentals

17. Verify that the files have been removed by entering ls -l. 18. Close the terminal window.
(End of Exercise)

6-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective 5

Use Piping and Redirection


Linux has three standard data channels:

Figure 6-3

Standard input 0

command

Standard output 1

>_

Standard error output >_

The following describes these channels:

Standard input (stdin). The program currently running reads the input from this channel (usually the keyboard). Standard output (stdout). The program sends its output to this channel (usually the screen). Standard error (stderr). Errors are issued through this channel (usually to the monitor).

These input and output channels are assigned the following numbers: Table 6-2
Channel Standard input (stdin) Standard output (stdout) Standard error output (stderr) Number Assigned 0 1 2

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-21

SUSE Linux Fundamentals

Each channel can be redirected by the shell. For example, stdin can come from a le or stdout and stderr can be piped to a le. The following are the redirection characters: Table 6-3
Redirection Character < > Description Redirects standard input. Redirects standard output (> without a preceding number is just an abbreviation for 1>). Redirects standard error output.

2>

> overwrites an existing le. If the output should be appended to an existing le, you have to use >> or 2>>.

The following is an example of a standard input, standard output, and standard error output:
tux@da1:~ > ls /opt /recipe /bin/ls: /recipe: No such file or directory /opt: gnome kde3

If the standard error output is redirected to /dev/null, only the standard output is displayed on the screen:
tux@da1:~ > ls /opt /recipe 2> /dev/null /opt: gnome kde3

To redirect standard output and standard error output to a le (such as list), enter the following: ls /opt /recipe > list 2>&1

6-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

First, the standard output is redirected to the le list (> list); then the standard error output is directed to the standard output (2>&1). The & refers to the le descriptor that follows (1 for the standard output). You can display the contents of the le list by using the command cat, as in the following:
ux@da1:~> cat list /bin/ls: /recipe: No such file or directory /opt: gnome kde3

This option of process communication is available not only in the shell, but can also be used in programs directly. One process uses the standard output of another process as its standard input. All known les in the system can be used as input or output. Occasionally, you might want to give programs that expect input from the keyboard data from a le instead. To do this, the standard input is redirected, as in the following:
da1:~ # echo "Hello Tux, > > how are you? > Is everything okay?" >greetings da1:~ # mail tux < greetings

First, the text is redirected to the le greetings through the command >. The mail program, mail, receives its input from the le greetings (not the keyboard), and then the email program sends the email to the user tux. The output of one command can be used as the input for another command by using the pipe ( | ): command1 | command2

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-23

SUSE Linux Fundamentals

In a pipe, a maximum of 4 KB of not yet processed data can exist. If the process creating the output tries to write to a full pipe, it is stopped and only allowed to continue if the writing process can be completed. On the other side, the reading process is stopped if it tries to read an empty pipe.
tux@da1:~ > ls -l /etc | less

Occasionally the user might want output from a command displayed on the screen and written to a le. This can be done using the command tee: ls -l | tee output In this example, the output of the command is displayed on the screen as well as written to the le output. To redirect the output of several consecutive commands on the command line, the commands must be separated with semi-colons (;) and enclosed in parentheses:
tux@da1:~> (id ; ls ~) > output tux@da1:~> cat output uid=1000(tux) gid=100(users) groups=14(uucp),16(dialout),17(audio),33(video),100(users) bin Desktop Documents output public_html tux@da1:~>

The shell starts a separate subshell for processing the individual commands. To redirect the linked commands, the shell must be forced to execute the command chain in the same subshell by enclosing the expression in parentheses.

6-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Upon completion, every program returns a value that states the success of the execution. If this return value is 0, the command completed successfully. If an error occurred, the return value is greater than 0. (Depending on the program, different return values indicate different errors.) You can use the command echo $? to display a return value. The return value can be used to trigger the execution of another command: Table 6-4
Link Result

command1 && command2

command2 is only executed if command1 is completed without any errors. command2 is only executed if command1 is completed with an error.

command1 || command2

The following illustrates using both || and &&::


tux@da1:~> ls recipe || ls ~ /bin/ls: recipe: No such file or directory bin Desktop Documents output public_html tux@da1:~> ls recipe && ls ~ /bin/ls: recipe: No such file or directory tux@da1:~>

test

The le recipe does not exist and the command ls recipe leads to an error. Because of this the command ls ~ in the rst line is executed and in the fourth line not.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-25

SUSE Linux Fundamentals

Exercise 6-4

Use Piping and Redirection


To understand piping and redirection, do the following:
1. 2.

Open a terminal window. Pipe the output of the ls command for the home directory (~) to a file by entering ls ~ > home_directory. Display the content of the file by entering cat home_directory. Append the output of the ls command for the root directory (/) to the file home_directory by entering ls / >> home_directory. Display the content of the file by entering cat home_directory. Overwrite the file home_directory with the output of the ls command by entering ls / > home_directory. Display the content of the file by entering cat home_directory. Write the output of the ls command on the screen and into the file home_directory by entering ls ~ | tee home_directory. Count the number of files in your home directory by entering ls ~ | wc -l. rm home_directory.

3. 4.

5. 6.

7. 8.

9.

10. Remove the file home_directory by entering 11. Verify that the file was removed by entering ls -l. 12. Close the terminal window.
(End of Exercise)

6-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective 6

Manage User Accounts


In addition to YaST, you can use the following commands to add, change, and delete users and groups:

useradd passwd usermod userdel

useradd
You can use the command useradd to add users to the system. In the simplest case, you enter a username as an argument, as in the following: useradd geeko By entering useradd geeko, the user geeko is created in /etc/passwd and /etc/shadow. In the past, UNIX/Linux users were handled in a single le: /etc/passwd. The user name, the UID, the home directory, the standard shell, and the encrypted password were all stored in this le. The password was encrypted using the function crypt (man 3 crypt). In principle, the plain text password cannot be deciphered from the encrypted password. However, there are programs (such as john) which use dictionaries to encrypt various passwords with crypt, and then compare the results with the entries in the le /etc/passwd. With the calculation power of modern computers, the rst passwords can be guessed within minutes.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-27

SUSE Linux Fundamentals

The main problem with the le /etc/passwd is that it has to be readable by a user or administrator. It is from the le /etc/passwd that a user nds out to whom a specic le belongs. In addition, he must be able to allocate the UID to a user name (because only the UID is saved in the inode of a le). This allocation takes place in the le /etc/passwd. The logical consequence of this has been to store the password eld in its own le (/etc/shadow) which can only be read by root, as shown in the following:
da1:~ # ls -l /etc/passwd /etc/shadow -rw-r--r-- 1 root root 2757 Jul 19 17:40 /etc/passwd -rw-r----- 1 root shadow 1262 Aug 16 14:01 /etc/shadow

The following diagram shows the structure of a line in the le /etc/shadow: Figure 6-4
tux:khNXCG8NPkeg2:11568:0:99999:7:0:12134: Day on which account is locked (days since 1.1.1970) For how many days is password valid, although password has expired. How many days before password expires should user be warned? Days after which password must be changed Days after which password can be changed Date of last change (days since 1.1.1970) Encrypted password User name

The above diagram shows the entry for the user tux with the encrypted password. The plain text password is suse. The encrypted password is coded with the crypt function and is always 13 characters in length.

6-28

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

The encrypted word consists of letters, digits, and the special characters . (dot) and / (slash). If an invalid character (such as * or !') occurs in the password eld, then that user has an invalid password. Many users, such as wwwrun or bin have an asterisk (*) in the Password eld. These users cannot log in to the system. Instead they play a role for specic programs. For example, the user wwwrun is required to run the Apache Web server. If the Password eld is empty, then the user can log in to the system without giving a password. A password should always be set in a multiuser system. The line from the le /etc/shadow shows that there is only an exclamation mark ! in the password eld. This means that the user does not have a valid password. If you look in the directory /home, you will see that the user directory has not been created:
da1:~ # ls /home . .. geeko

If no option is specied, the command useradd creates a user without a home directory and without a valid password. The following are the most important options of the command useradd:

-m: This option automatically generates the home directory for the user. Without further arguments, the directory is created under /home/. In addition, a series of les and directories are copied to this directory. The directory /etc/skel/ (from skeleton) is used as a template for the user home directory.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-29

SUSE Linux Fundamentals

-c: When creating a new user, you can enter text for the comment field by using the option -c (comment):
da1:~ # ls /home . .. geeko

-g: This option defines the primary group of the user. You can specify either the GID or the name of the group. -p: This option lets you create a password for a new user. The following is an example: useradd -m -p "ghvkuzfFGW6cw" geeko

The encrypted password must be given here, not the plain text password. The program mkpasswd can be used to generate encrypted passwords. The program is located in the package whois.

-e: The option -e (expiredate) lets you set an expiration date for the user account, in the form of YYYY-MM-DD, as in the following: useradd -m -e 2002-03-21 geeko

You can display a description of additional options by entering man 8 useradd. The quickest way to create a new user from a command line is to use useradd and passwd, as in the following:
da1:~ # useradd -m -c "Geeko Chameleon" geeko da1:~ # passwd geeko New password: Re-enter new password: Password changed

With useradd the user is created, and with passwd the password is entered.

6-30

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

When creating a user account, the necessary standard conguration information (effective group, location of the home directory, default shell, etc.) is derived from the les /etc/default/useradd (which is also used by YaST as described below) and /etc/login.defs. The following is an example of the le /etc/default/useradd:
GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel

passwd
You can change a user's password of a user with the command passwd. If a user enters passwd without a username as an argument, the user can change her own password. Besides being able to change a user password, the passwd command provides the following features:

Locking a user account: With the option -l (lock), a user can be locked out, and with the option -u (unlock), he can be reactivated:
da1:~ # passwd -l tux Password changed.

Status of a user account: The option -S lists the status of a user account:
da1:~ # passwd -S tux tux LK 04/19/2004 0 99999 7 0

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-31

SUSE Linux Fundamentals

The status follows directly after the username. In the above example, LK (locked) means that the user is unable to log in. Other options are NP (no password) or PS (valid password). These are followed by the date of the last password change, the minimum length of validity, the maximum length of validity, and the warning periods and inactivity periods when a password expires.

Changing password times: You can change the various password times by using the following options:
Option -i number -n number -w number -x number Description Disable an account after the password has been expired for number of days. Sets the minimum number of days before a password can be changed. Warns the user that in number of days his password will expire. Sets the maximum number of days a password remains valid. After number of days the password must be changed.

Table 6-5

The following is an example: passwd -x 30 -w 5 tux In this example, the password of the user tux remains valid for 30 days. After this time, the password is required to be changed by tux. Tux receives a warning 5 days before password expiration.

6-32

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

When the command passwd is used to establish or change the password of a user account, the le /etc/default/passwd is checked for the encryption method to be used:
# This file contains some information for # the passwd (1) command and other tools # creating or modifying passwords. Define default crypt hash # CRYPT={des,md5,blowfish} CRYPT=des ...

The default setting for the variable CRYPT is des. Other possible encryption methods include MD5 and Blowsh. YaST also uses the le /etc/default/passwd.

usermod
With usermod, you can modify information such as the UID, the standard shell, the home directory, and the primary group in an existing user account. The usermod options are nearly the same as the options of the command useradd. The following are some examples of usermod:

Changing the home directory: usermod -d /newhome/tux -m tux

Changing the UID: usermod -u 504 tux

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-33

SUSE Linux Fundamentals

userdel
The nal important command for user administration is userdel. With userdel, you can remove user accounts from the system (as in the following): userdel tux Without options, userdel removes the user from the les /etc/passwd, /etc/shadow and /etc/group. However, the home directory is not deleted. If you want to delete the home directory, you need to use the option -r: userdel -r tux

6-34

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Exercise 6-5

Manage User Accounts


To manage user accounts, do the following:
1.

Open a terminal window; then su to root (su -) with a password of novell. Create a new local user by entering the following: useradd -c Tux Linux -m tux

2.

3.

Verify that a home directory for tux was created by entering ls /home. Verify that there is a entry for the tux user in /etc/passwd by entering cat /etc/passwd. Notice the x in the second eld, indicating that there is no password for tux. You did not use the option p when creating tux, so there is no password set.

4.

5.

Add a password for the user tux by entering passwd tux. Enter the password suse twice. Log out as root by entering exit. Log in as tux by entering su - tux. Enter the tux password (suse).

6. 7. 8. 9.

10. Change the password of the user tux by entering passwd. 11. Enter the old password of the user tux (suse). 12. Try to change the password to novell by entering novell.

You receive a warning that the password is too simple.


13. Enter d1g1t@l as new password (twice). 14. Log out as user tux by entering exit. 15. Switch to user root (su -) with a password of novell. 16. Delete the user tux by entering userdel -r tux.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-35

SUSE Linux Fundamentals

17. Verify that the home directory for tux has been removed by

entering ls /home.
18. Verify that there is no entry for tux in /etc/passwd by entering

cat /etc/passwd.
19. Close the terminal window.
(End of Exercise)

6-36

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective 7

Execute RPM Package-Related Operations


The software included on the SUSE Linux distribution is available in the form of RPM Package Manager (RPM) packages. These packages use the lename extension .rpm. They are packed in a special binary form and, apart from the executable programs, they also contain information about the conguration of the software package, such as information about dependencies on other packages, such as shared libraries. The distribution also includes source packages, called source RPMs, which have the lename extension .src.rpm (.spm or .srpm are also possible). When a package is to be installed, the RPM database is checked to see if all dependencies are fullled (source packages, however, are not included in this database or are not recorded). The package is only installed if these dependencies are fullled. Otherwise, the missing packages are listed in an error message. The database contains precise details of what packages are installed in which version. In addition, the database lists every le belonging to the package. The les of the RPM database are stored in the directory /var/lib/rpm/. A package usually contains documentation and sometimes prepared conguration les. SUSE RPM packages frequently contain start scripts. When you install an RPM package, the executable programs, documentation les, conguration les, and start scripts are copied to the appropriate points in the le system. For example, the start script is copied to /etc/init.d/, executable les are copied to /usr/bin/, and manual pages are copied to /usr/share/man/.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-37

SUSE Linux Fundamentals

If you uninstall a package, all les except modied conguration les are removed from the system with the help of the RPM database. This ensures a clean uninstall. You can install software in the RPM format by using YaST or by using the command rpm. YaST ensures the automatic resolution of dependencies, while rpm only controls them. Resolution must be performed by hand. Using the rpm command, you can install software (rpm -i), uninstall software (rpm -e), and query information from the RPM database (rpm -q). The following are examples of using rpm:

rpm -qa. Displays a list of all installed packages,

6-38

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

rpm -qi package. Displays summary information about the specified package, for example:
da1:~ # rpm -qi howto-2004.3.21-1 Name : howto Relocations: (not relocatable) Version : 2004.3.21 Vendor: SuSE Linux AG, Nuernberg, Germany Release : 1 Build Date: Mon Mar 22 14:35:05 2004 Install date: Mon Apr 5 16:20:55 2004 Build Host: giles.suse.de Group : Documentation/Howto Source RPM: howto-2004.3.21-1.nosrc.rpm Size : 9101523 License: Unknown, GPL Signature : DSA/SHA1, Mon Mar 22 14:44:14 2004, Key ID a84edae89c800aca Packager : http://www.suse.de/feedback Summary : Collection of HOWTOs Description : Documentation on many tasks relating to the setup and operation of Linux software. English version, ASCII format hese documents will be installed in /usr/share/doc/howto. You can read it with `less <filename>`. Distribution: SuSE SLES-9 (i586) da1:~ #

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-39

SUSE Linux Fundamentals

For information about a package that has not been installed, add the option -p and specify the complete path to the package in question. Entering rpm -qpl/software/package.rpm lists all the les in package.rpm, as in the following example:
da1:~ # rpm -qpl /media/cdrom/suse/src/samba-3.0.2a-37.src.rpm ldapsmb-1.3.tar.bz2 libsmbclient-fixes.diff nmbstatus samba-3.0.2a.files.tar.bz2 samba-3.0.2a.tar.bz2 samba-com_err.diff samba-ia64.diff samba-s390.diff samba-vscan-0.3.4.tar.bz2 samba.reg samba.spec smbprngenpdf syscall.diff da1:~ #

You can also use the following options with the rpm command: Table 6-6
Option --checksig Description Makes sure a package is complete and correct (PGP signature check). Uninstalls a package. Updates a package only if the package is already installed in an older version. Lists options for the rpm command. Installs a package. Installs a package even if rpm says that the package is already installed. Installs a package regardless of unresolved dependencies.

-e or --erase -F or --freshen

--help -i or --install -i --force

-i --nodeps

6-40

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

(continued)

Table 6-6

Option -qa -qf -qi

Description Lists all installed packages. Displays which package a le belongs to. Gives brief information about the given package. Lists all les that belong to a package. Lists all les of a package that is not installed. Updates a package. (In contrast to -f the package is installed, even if there is no older version of the package installed.) Installs an older version, even if the newer version is already installed (downgrade). Compares information about the installed les in the package with information about the les taken from the original package and stored in the rpm database. Among other things, verifying compares the size, permissions, type, owner, and group of each le. Any discrepancies are displayed.

-ql -qpl -U or --upgrade

-U --oldpackage

-V or --verify

A complete summary of all options can be found in the manual page (man rpm). In general, it is simpler to install software in RPM format and, above all, to remove it again cleanly from the system than to use software that is not organized in packages. The global RPM conguration le of the rpm command is /usr/lib/rpm/rpmrc. However, when the rpm command is updated, all changes to this le are lost.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-41

SUSE Linux Fundamentals

To prevent the changes from being lost, write them to /etc/rpmrc les (for the system conguration) or to a le ~/.rpmrc (for the user conguration).

6-42

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Exercise 6-6

Execute RPM Package-Related Operations


To execute RPM package-related operations, do the following:
1.

From a terminal window, su to root (su -) with a password of novell. Insert SLES 9 CD 3 in your CD-ROM drive. List all files included in the not yet installed package gcal by entering the following: rpm -qpl /media/cdrom/suse/i586/gcal-3.01-581.1.i586.rpm

2. 3.

4.

Install the package gcal by entering the following: rpm -ihv /media/cdrom/suse/i586/gcal-3.01-581.1.i586.rpm

5. 6.

Remove the CD from your drive. (Conditional) If the CD drive does not open, enter umount /media/cdrom; then try again. Test the installation of the software package by entering gcal. List all files included in the installed package gcal by entering rpm -ql gcal. Remove the package gcal by entering rpm -e gcal. rpm -ql gcal.

7. 8.

9.

10. Verify that the package is no longer installed by entering 11. Log out as root by entering exit. 12. Close the terminal window.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-43

SUSE Linux Fundamentals

Objective 8

Use the Basic Linux mail Command


You can use the command mail in one of two ways:

Read Status Mail Use the Simple Mail Client

Read Status Mail


Some programs send status mail messages or notes to the user root. If you log in at a virtual terminal, you get a notication if there are mail messages for you:
da1 login: root Password: You have new mail in /var/mail/root. Last login: FRI Jul 18 13:23:51 from 10.0.0.6 da1:~ #

To read these messages, you can use the command mail:


da1:~ # mail mailx version nail 10.6 11/15/03. Type ? for help. "/var/mail/root": 3 messages 3 new >N 1 root@da1 Wed Jul 9 15:02 28/894 SuSEconfig: xntp.caveats N 2 root@da1 Wed Jul 9 15:02 43/1836 SuSEconfig: SuSEfirewall2 N 3 root@da1 Wed Jul 9 15:02 151/5888 SuSEconfig: openssh-chang ?

6-44

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

The prompt of mail is a ?. At the prompt, you can use the following commands: Table 6-7
Command t message_list n e message_list f message_list d message_list u message_list R message_list r message_list m user_list q x Purpose Type messages. Go to and type the next message. Edit messages. Give headlines of messages. Delete messages. Undelete messages. Reply to message senders. Reply to message senders and all recipients. Mail to specic users. Quit, saving unresolved messages in mbox. Quit, do not remove system mailbox.

A message_list consists of integers, ranges of integers, or user names separated by spaces. If omitted, mail uses the last message typed. A user_list consists of user names or aliases separated by spaces. Aliases are dened in .mailrc in your home directory.

Use the Simple Mail Client


You can use the program mail as an normal mail client on the command line. The simplest form of using mail is mail mail_address.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-45

SUSE Linux Fundamentals

Instead of mail_address you can enter a username of a person inside your local network. (For sending messages to other users than the local users you need to congure a mail server on your local host.) mail rst asks you for the subject of the mail and after this you can enter the body of your message. To nish the text you have to enter a single full stop in the last line:
tux@linux:~ > mail root Subject: A simple Mail This is just a test mail. The body of the text ends with an single full stop. .

mail conrms the end of the text body with EOT (end of text) and sends the mail immediately. The following are the most important options of mail: Table 6-8
Option -a le -b list -c list -q le -s subject Description Attach the given le to the message. Send blind carbon copies to list. List should be a comma-separated list of names. Send carbon copies to list of users. Start the message with the contents of the specied le. Can be given in send mode only. Specify subject on command line (only the rst argument after the -s ag is used as a subject; be careful to quote subjects containing spaces). Specify reply-to address on command line. Only the rst argument after the -R ag is used as the address.

-R address

6-46

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

(continued)

Table 6-8

Option -F

Description Read emails are stored in the le ~/mbox. With -F mail opens this le to read these old email messages.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-47

SUSE Linux Fundamentals

Exercise 6-7

Send Mail to root


To send mail to root, do the following:
1. 2. 3. 4.

Open a terminal window. Enter mail root. Enter the subject My first email with mail. Enter the following 3 lines of text (press Enter after each line): I have just installed SLES 9 on my computer and am ready for administration training.

5. 6. 7.

When you finish, press Ctrl+D. Su to root by entering su -; then enter a password of novell. Enter mail. In the last line of the list you should nd the mail message you just sent to root.

8.

To read the message, enter the number in the second column of the table. Delete the message by entering d and the number of the message (such as d 4).

9.

10. Quit mail by entering q. 11. Verify that the message was deleted by entering mail; then exit

mail by entering q.
12. Log out as root by entering exit. 13. Close the terminal window.
(End of Exercise)

6-48

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Summary
Objective
1. Get to Know the Command Shells

Summary The shell serves as an interface between a user and an operating system. Linux uses the Bourne again shell (/bin/bash) as the default shell. One important distinction needs to be made between the 2 types of shells:

Login Shells Non-login Shells

The following les are read when starting a login shell:


/etc/prole ~/.bash_prole ~/.bash_login ~/.prole

The following le is read when starting a non-login shell:

~/.bashrc

To read in a changed conguration le and to apply the changes to the current session use the internal shell command source or its short form ..

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-49

SUSE Linux Fundamentals

Objective
2. Execute Commands at the
Command Line

Summary The bash shell stores commands that have been entered so the user has easy access to them. By default, the commands are written in the le .bash_history in the user's home directory. The content of the le can be displayed with the command history. Commands stored in the history cache can be ipped through with the arrow keys. One or several letters and Page Up or Page Down goes to the preceding or next command in the history beginning with the specied letter. If you enter part of the command, Ctrl+R will retroactively search the history for matching commands To become root, you can enter the following:

su command sux command

You can also start a separate root shell from Konsole by selecting Session > New Root Console.

6-50

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective
3. Get to Know Common Command
Line Tasks

Summary Two types of variables are used with commands:

Environment variables inuence the behavior of a program which is started from a shell. Shell variables control the behavior of the shell itself.

The value of a variable can be seen with the command echo. Dening aliases lets you create shortcuts for commands and their options or to create commands with entirely different names. For each command specied, type will tell you whether it is a built-in shell command, a regular command, a function, or an alias. Most of the aliases used on a system-wide basis are dened in the le /etc/bash.bashrc. Aliases are dened with the alias command and can be removed with the unalias command.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-51

SUSE Linux Fundamentals

Objective
4. Understand Command Syntax
and Special Characters

Summary To perform operations on a series of les without having to name all the les, you can use of various search patterns:

?: stands for any character (except /). *: stands for 0 or more characters (except . at the beginning of a le name and /). [a-z]: a character from the range a-z. [a-ek-s]: a character from the ranges a-e and k-s. [abcdefg]: any of these characters. [!abc]: none of these characters.

To prevent the shell from interpreting special characters in the command line, these characters must be masked:

\: The backslash protects exactly one character. "...": Double quotation marks protect all special characters except $, \, and ` (back tick). '...': Apart from regular expressions, variables are also protected single quotation marks.

6-52

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective
5. Use Piping and Redirection

Summary Linux has three standard data channels:


0: Standard input (stdin) 1: Standard output (stdout) 2: Standard error (stderr)

Each channel can be redirected:


<: Redirects standard input. >, 1> or >>: Redirects standard output. 2>: Redirects standard error output.

The contents of a le can be displayed by entering the command cat lename, Using the pipe (|), the output from one command can be used as the input for another command. The command tee can be used to split the standard output.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-53

SUSE Linux Fundamentals

Objective
6. Manage User Accounts

Summary The command useradd is used to add users to the system. With useradd the user is created in /etc/passwd and /etc/shadow. useradd with the option -m generates the home directory for the user. The directory /etc/skel/ is used as a template creating the user's home directory. The standard conguration for a new user account is derived from the les /etc/default/useradd and /etc/login.defs. You can change a user's password with the command passwd. With usermod, you can modify an existing user account. The command for deleting a user is userdel. If you also want the home directory deleted, then include the option -r.

6-54

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Work With the Linux Shell and Command Line

Objective
7. Execute RPM Package-Related
Operations

Summary RPM packages are packed in a special binary form. Apart from the executable programs, they also contain information about the conguration of the software package, such as information about dependencies on other packages (including shared libraries). You can use the command rpm to install software packages (rpm -i), uninstall software packages (rpm -e), and query information from the RPM database (rpm -q).

8. Use the Basic Linux mail


Command

Some programs write status mail messages or notes to the user root. If you log in at a virtual terminal you are notied if there are messages waiting for you. You can use the command mail to read the messages. You can also use the program mail as a mail client on the command line. To nish the text body, you have to enter a single full stop in the last line.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

6-55

SUSE Linux Fundamentals

6-56

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

SECTION 7

Use Linux Text Editors

A text editor is one of the most important tools a Linux system administrator uses. This section introduces a graphical text editor and a command line editor.

Objectives
1. 2. 3.

Get to Know Linux Text Editors Use Command Line Editors to Edit Files in the Linux System Use Desktop Editors to Edit Files in the Linux System

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-1

SUSE Linux Fundamentals

Objective 1

Get to Know Linux Text Editors


Because most of the services of a Linux computer are congured by editing a ASCII le, you need a text editor. The following are some examples of the text editors available in Linux:

vi emacs xemacs joe e3 xedit kedit kwrite kate gedit jedit nedit pico

Every text editor has advantages and disadvantages. Most editors are much more powerful than the text editor Notepad from Windows. Two kinds of editors are available:

Command line editors Graphical editors

The main advantage of command line editors is that you do not need a graphical user interface to use them.

7-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

Objective 2

Use Command Line Editors to Edit Files in the Linux System


The advantage of command line editors is that you can use them without having a graphical desktop environment installed. A large number of command line editors available for Linux. The most frequently used editors are

vi emacs

Although many factors can be involved when selecting an editor for everyday use, the reason vi is used by most administrators is that it is available on every Linux and UNIX system. Because of this, you should be able to use vi. In SUSE Linux Enterprise Server, vim (vi improved) by Bram Moolenaar is the standard vi editor. When you enter vi, vim is started via a link to it. In this objective, you learn how to do the following:

Start vi Use the Editor vi Get to Know the Working Modes

Start vi
You can start vi by entering vi or vim, followed by various options, and the name of a le to edit, as in the following example: vi exercise

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-3

SUSE Linux Fundamentals

If a le does not yet exist, it is created. The text of the le appears in an editor at the command line: Figure 7-1

The sign ~ indicates lines that do not exist yet. The cursor is on the rst line.

Use the Editor vi


You can move the cursor with the k, j, h, and l keys (k one line up, j one line down, h to the left, l to the right) or by using the arrow keys (Up-arrow, Down-arrow, Left-arrow, Right-arrow).

7-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

Get to Know the Working Modes


In contrast to many other editors, vi is mode-oriented. When vi is rst started, it is in command mode. Anything you enter in this mode is considered a command. You must switch to input mode before you can type any text. This can be frustrating to users who are unfamiliar with vi. In addition to switching modes, you must learn which keys perform which actions because you cannot use the mouse. The number of commands needed for everyday work is fairly small, however, and you can get used to them quickly. When vi starts, it is in command mode. Everything now entered is interpreted by vi as a command. To enter text, you must rst switch the editor to input mode by typing i (insert) or pressing the Insert key. At the bottom of the screen, you see the message --INSERT--. Press Esc once to take you back to the command mode. From command mode you can switch to command-line mode by entering :. The cursor jumps to the last line after : and waits for a command entry. A command will only be carried out in command-line mode after you press Enter. Then you are automatically back in command mode. The following is a summary of the available modes:

Command mode: When vi starts, it is automatically in this mode. In command mode, vi can be given commands. The command i puts it into insert mode and the command : switches it to command-line mode. Insert mode: In this mode (keyword --INSERT--), vi accepts all input as text. Return to command mode with Esc.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-5

SUSE Linux Fundamentals

Command-line mode: In this mode (keyword :), vi accepts commands from the command line. Pressing Enter causes the command to be executed and automatically switches back to the command mode.

You can use the following commands in command mode: Table 7-1
Command i or Insert x or Delete dd Result Switches vi to insert mode. Deletes the character where the cursor is. Deletes the line in which the cursor is located and copies it to the buffer. Deletes the rest of the current line from the cursor position. Copies the line in which the cursor is located to the buffer. Inserts the contents of the buffer after/before current cursor position. Saves the current le and ends vi. Undoes the last operation. Searches forward from the cursor position for pattern. Searches backward from the cursor position for pattern. Repeats the search in the same direction. Repeats the search in the opposite direction.

yy

p, P

zz u /pattern ?pattern

n N

If you want to use a command for several units, place the corresponding number in front of the command. For example, 3x deletes three characters, 5dd deletes ve lines, and 7yy copies seven lines to the buffer.

7-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

You can use the following commands in command-line mode: Table 7-2
Command :q :q! :wq or :x :w :w le Result Ends vi (if no changes were made). Ends vi without saving changes in the le. Saves the current le and ends vi. Saves the current le. Saves the current le under the name le. (Note: You continue editing the original le, not the new le.)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-7

SUSE Linux Fundamentals

Exercise 7-1

Use Command Line Editors to Edit Files in the Linux System


To use the command line editor vi, do the following:
1. 2. 3. 4.

Open a terminal window. Start vim by entering vi. Switch to the insert mode by typing i. Type the following 2 paragraphs of text (press Enter at the end of each line): Administrator training for SLES 9 will be held in Training Room 4 of Building B on Tuesday of next week. Make sure you bring your SLES 9 Administration Manual. There will be wireless Internet access available in the training room.

5. 6.

Exit the insert mode by pressing Esc. Move the cursor to the middle of the second line of the first paragraph. Delete text to the right of the cursor by typing D (uppercase d). Undo the deletion by typing u. Delete the character directly under the cursor by pressing Delete.

7. 8. 9.

10. Copy the current line to the internal buffer by typing y twice. 11. Move the cursor to the beginning the first line of the second

paragraph.
12. Insert the content of the internal buffer after the current line by

typing p.
13. Save the file with filename vi_test by entering :w vi_test. 14. Exit vi by entering :q.

7-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

15. Close the terminal window.


(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-9

SUSE Linux Fundamentals

Objective 3

Use Desktop Editors to Edit Files in the Linux System


Several desktop editors can be used to edit les in Linux. In this objective, we focus on the editor Kate because it is part of the default KDE desktop environment. Kate is a comfortable, easy-to-use editor that is similar to well-known text processing applications. To start Kate from the KDE menu, select Utilities > Editor > Kate. The File menu lets you save, print, and perform many familiar le management tasks. The Edit menu also contains many familiar functions (such as Undo, Cut, Copy, and Paste). The icons in the toolbar are the same as those used in other editors or word processing programs. The tools menu contains many useful functions including the following:

Read Only Mode: If you select this option, you cannot mistakenly change the content of the file. Highlight Mode: This mode recognizes commands from different programming languages and displays them in a different text format. End of Line: Different operating systems use different kinds of end-of-line encoding. This feature lets you choose which end-of-line encoding you want to use. Spelling: Checks your spelling. Indent/Unindent: Indents or unindents the marked lines. With Clean Indentation, you can remove all indentations you made in the marked lines. Comment/Uncomment: Inserts the command markers at the beginning of each marked line. The type of command markers depends on the file type.

7-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

Uppercase/Lowercase/Capitalize: Changes the characters in the marked area to uppercase or lowercase. Capitalize only changes the first character of each word to uppercase. Join Lines: Merges two or more lines to one line. Word Wrap Document: Wraps the lines after 80 characters.

One feature that distinguishes Kate from many other editors is the ability to concurrently manage multiple open les and split text windows as often as necessary, such as selecting View > Split Horizontal in the following example: Figure 7-2

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-11

SUSE Linux Fundamentals

The items inside the Project menu and the MainDock button do not work. They are reserved for future versions of Kate.

7-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

Exercise 7-2

Use Desktop Editors to Edit Files in the Linux System


To use the desktop editor Kate, do the following:
1.

Start Kate from the KDE menu by selecting Utilities > Editor > Kate. Select File > Open. Select the up arrow button once to switch to the home directory for geeko. Select the file vi_test; then select OK. Select File > Open. Navigate to the directory /usr/share/doc/howto/en/html/, select the file 3-Button-Mouse.html; then select OK. Note that the le is identied as HTML document and the syntax highlighting is activated automatically.

2. 3.

4. 5. 6.

7. 8.

Split the window by selecting View > Split Horizontal. Display the file vi_test in one of the windows by selecting the top icon in the left icon bar; then select vi_test. Select a line in the HTML document with your mouse. file vi_test by doing one of the following:

9.

10. Click in the vi_test window; then paste the marked text into the

Two-button mouse: press both buttons simultaneously. or Three-button mouse: press the middle mouse button.

11. Exit Kate by selecting File > Quit. 12. Save the changes to the file vi_test by selecting Save.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-13

SUSE Linux Fundamentals

Summary
Objective
1. Get to Know Linux Text Editors

Summary Most of the services of a Linux computer are congured by editing an ASCII le. For this reason, you need a text editor. There are 2 types of editors:

command line editors graphical editors

2. Use Command Line Editors to


Edit Files in the Linux System

The vi command line editor is available on every Linux and UNIX system. vi has the following modes:

Command mode: vi can be given commands. The command I puts it into insert mode and the command : into command-line mode. Insert mode: vi accepts all input as text. Return to command mode with Esc. Command-line mode: vi accepts commands from the command line. Enter causes the command to be executed and automatically switches back to the command mode.

:q! ends vi without saving changes in the le.

7-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Use Linux Text Editors

Objective
3. Use Desktop Editors to Edit Files
in the Linux System

Summary The Kate desktop editor is accessed from the KDE menu. Its Tools menu provides a large number of useful features, including the following:

Read Only Mode Highlight Mode End of Line Spelling Indent/Unindent/Clean Indentation Comment/Uncomment Uppercase/Lowercase/Capitalize Join Lines Word Wrap Document

Kate allows you to concurrently manage multiple open les and split text windows (such as View > Split Horizontal) as often as necessary.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

7-15

SUSE Linux Fundamentals

7-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

SECTION 8

Understand and View Processes in the Linux System

This objective introduces you to basic process management, including runlevels and multitasking in Linux.

Objectives
1. 2. 3.

View Processes from the GUI and the Command Line Interface Understand the Runlevel Concept Multitask in the Linux System

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-1

SUSE Linux Fundamentals

Introduction
In a multitasking system, the kernel allocates individual processes (programs when they are running) computer time in fractions of a second, one after the other. This slows down the processes slightly, but it means that a process does not have to wait until another one is completely nished before it can start or continue running itself. In this way, several processes can run simultaneously without any noticeable interruption. Administering processes can, in part, be done through the bash shell. The command jobs returns all processes that have been started from that shell and run in the background. This means that the shell works as a controlling terminal. Processes running in the background (daemons), which are either started automatically when the system is booted or started manually via a start script, cannot, in principle, be inuenced by this, because they are not allocated to any controlling terminal.

8-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

Objective 1

View Processes from the GUI and the Command Line Interface
In this objective, you learn how to do the following:

View Processes from the GUI View Processes from the Command Line Interface

View Processes from the GUI


To display currently running processes, use KDE System Guard, which can be found in the KDE menu under System > Monitor > KDE System Guard. After the KDE System Guard starts, you can view the system load (the load on the processor and the memory) on the right side of the window. To see the process table, select the Process Table tab: Figure 8-1

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-3

SUSE Linux Fundamentals

The following information is displayed in columns in the Process table: Table 8-1
Column Name PID User% System% Description Name of the process Number of the process (process ID) Processor load caused by the process Processor load caused by system processes required for the process Priority of the process when allocated computer time by the kernel Virtual size of the process Actual memory occupied Login name of the owner The start command for this process

Nice

VmSize VmRSS Login Command

By default, the list is sorted by the name of the process. By selecting the head of a column, you can sort the list according to that column. To end a process, select the corresponding line and then select Kill.

Every user (except for the system administrator root) can kill only his own processes.

8-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

View Processes from the Command Line Interface


Commands in a shell can be started in the foreground or in the background. Processes in the foreground can receive transmitted signals directly. For example, you can start xeyes in the foreground by entering the following:
tux@da50:~ > xeyes

You can stop a process (such as xeyes) by pressing Ctrl+Z, as in the following:
[1]+ Stopped tux@da50:~ > xeyes

You can continue operating a stopped program in the background by entering the command bg. In the following, the stopped program xeyes continues running in the background by entering bg:
tux@da50:~ > bg [1]+ xeyes & tux@da50:~ >

In this example, the ampersand character & in the output means that the process is now running in the background. Appending an ampersand character to a command starts it in the background directly, as in the following:
tux@da50:~ > xeyes & [2] 10982 tux@da50:~ >

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-5

SUSE Linux Fundamentals

Because the process is running in the background, you are returned to the shell prompt to continue entering commands. Notice that both the job ID (2) and the process ID of the program (10982) are returned. Each process started from the shell is assigned a job ID by the job control of the shell. The command jobs lists the contents of job control, as in the following:
tux@da50:~ > jobs [1]+ Stopped [2] Running [4]- Running tux@da50:~ >

xeyes xeyes & sleep 99 &

In this example, the process with job ID 3 is already terminated. The processes 2 and 4 are running in the background (indicated by a trailing ampersand & character). Notice that process 1 is stopped. A next process started in the background will be assigned the job ID 5 (highest current number +1). Gaps are not lled. Besides using bg to start a stopped process and switch it to the background, you can switch a process running in the background to the foreground by using the command fg with the job ID, as in the following:
tux@da50:~ > fg 1 xeyes

The shell also informs you about the termination of a process running in the background:
[4]- Done sleep 99

8-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

In this example, the job ID is displayed in square brackets. Done means the process terminated properly. Terminated would indicate instead that the process was asked to terminate. Killed would indicate a forceful termination of the process. To see running processes, use the command ps (process status), as in the following:
tux@da50:~ > ps PID TTY TIME CMD 1301 tty2 00:00:00 -bash 1349 tty2 00:00:00 ps tux@da50:~ >

If you include the option x, terminal-independent processes are also shown, as in the following (the 1344 process):
tux@da50:~ > ps x PID TTY STAT TIME COMMAND 1301 tty2 R 0:00 -bash 1344 ? S 0:00 sleep 99 1348 tty2 R 0:00 ps x tux@da50:~ >

The command ps uses options with and without ''.

Each process contains a system-wide unique process identication number (PID). PID 1 always belongs to the init process. The process init is the rst process started on the system and it creates a number of other processes, which, in turn, can generate further processes. When the maximum process number has been reached, the next process is allocated the lowest available number (processes run for different lengths of time and after one process has ended, its number again becomes available).

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-7

SUSE Linux Fundamentals

The following are options you can use with the command ps: Table 8-2
Option x a Description Lists terminal-independent processes. Lists all terminal-independent processes, including those of other users. (wrap) Provides detailed output; long lines are not truncated, but spread over several lines. (long) Provides more information about processes. (user) Lists processes ordered according to their owners. Lists processes hierarchically (in the form of a tree).

l u

For example, entering ps axl displays information similar to the following:


tux@da50:~ > ps axl F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND 000 10376 1800 10035 11 0 5488 3512 do_sel S ? 0:00 xterm 000 10376 1801 1672 14 0 2716 1532 wait4 S pts/2 0:00 bash 000 10376 1859 1672 9 0 1452 500 nanosl S pts/2 0:00 sleep 99 000 10376 1860 1858 17 0 2892 1924 R pts/2 0:00 ps axl

However, entering ps aux displays the following:


USER tux tux tux tux PID 1800 1801 1859 1860 %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 0.0 1.3 5488 3512 ? S 14:35 0:00 xterm 0.0 0.6 2716 1532 pts/2 S 14:35 0:00 bash 0.0 0.1 1452 500 pts/2 S 14:43 0:00 sleep 99 0.0 0.6 2584 1652 pts/2 R 14:44 0:00 ps aux

8-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

The essential difference is that with option -l, you see the process ID of the father process (PPID), the process priority (PRI), and the nice value (NI) of the individual processes. With the option -u, you see the load percentage (%CPU, %MEM). You can include formatting instructions with ps to present a customized display of the information, as in the following:
tux@da50:~ > ps ax cputime %CPU, nice cputime 0.0, nice cputime 0.0, nice cputime 0.0, nice --format "cputime %C, nice %n, name %c" NI, name COMMAND 0, name bash 0, name sleep 0, name ps

You can display a detailed summary of how to use ps by entering man ps. The output of ps includes the following columns of information: Table 8-3
Column UID PID PPID TTY PRI Description User ID Process ID Parent process ID Number of the controlling terminal Priority; the lower it is, the more computer time is allocated to the process. (nice) Inuences the dynamic priority adjustment. Overall memory usage of the program Current process status Computer time used Name of the command

NI SIZE STAT TIME COMMAND

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-9

SUSE Linux Fundamentals

The process state in the STAT column uses the following codes: Table 8-4
Code R S Description (runnable) Process can be run. (sleeping) Process is waiting for an external event (such as data arriving). (uninterruptable sleep) Comparable to S. The process cannot be terminated at the moment. (traced or stopped) Process is suspended. (zombie) Process has terminated itself, but its return value has not yet been requested.

T Z

You can use the command pstree to display a list of processes in the form of a tree structure. This gives an overview of the hierarchy of a process. To end a series of processes, nd the appropriate father process in the tree and end that instead. You can use the option -p to display the PID of the processes, and the option -u to display the user ID (if the owner has changed). Because the list of processes is often long, we recommended using less to display information, as in the following: pstree -up | less You can use the command lsof (/usr/bin/lsof; list open les) to see which les are opened by processes. You can view a description of the command and possible options by entering man lsof.

8-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

You can use the command top to nd out how much computing time processes use, as in the following:
top - 16:21:13 up 7 days, 1:11, 3 users, load average: 0.01, 0.03, 0.00 Tasks: 49 total, 1 running, 47 sleeping, 1 stopped, 0 zombie Cpu(s): 0.7% us, 0.3% sy, 0.0% ni, 98.3% id, 0.7% wa, 0.0% hi, 0.0% si Mem: 126508k total, 112568k used, 13940k free, 8452k buffers Swap: 265064k total, 3252k used, 261812k free, 46820k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 11677 tux 17 0 1760 900 1544 R 0.3 0.7 0:00.13 top 1 root 16 0 588 108 444 S 0.0 0.1 0:09.62 init 2 root 34 19 0 0 0 S 0.0 0.0 0:00.04 ksoftirqd/0 3 root 5 -10 0 0 0 S 0.0 0.0 0:01.01 events/0 4 root 5 -10 0 0 0 S 0.0 0.0 0:00.23 kblockd/0 25 root 15 0 0 0 0 S 0.0 0.0 0:00.00 kapmd 27 root 5 -10 0 0 0 S 0.0 0.0 0:02.67 pdflush 30 root 15 -10 0 0 0 S 0.0 0.0 0:00.00 aio/0 29 root 15 0 0 0 0 S 0.0 0.0 0:02.94 kswapd0 177 root 25 0 0 0 0 S 0.0 0.0 0:00.00 kseriod 216 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0 217 root 15 0 0 0 0 S 0.0 0.0 0:00.00 ahc_dv_0 242 root 5 -10 0 0 0 S 0.0 0.0 0:03.13 reiserfs/0 491 root 6 -10 0 0 0 S 0.0 0.0 0:00.00 kcopyd/0 17689 root 15 0 0 0 0 S 0.0 0.0 0:00.00 khubd 18025 root 16 0 1524 676 1348 S 0.0 0.5 0:00.08 syslogd ...

The command top displays a list of the running processes, sorted by computing time. The display is updated every ve seconds. You can terminate top by typing q.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-11

SUSE Linux Fundamentals

You can view the process management commands available in top by entering ? or h. The following are some of the more commonly-used commands: Table 8-5
Command r k N P Description Assign a new nice value to a running process. Send a running process a signal. Sort by process ID. Sort by CPU load.

Processes can be controlled by signals. If a process has no connection to a controlling terminal, it cannot be inuenced by keyboard signals. Externally generated signals are needed to terminate it. Such signals are generated by the commands kill and killall.

System processes started automatically when the system boots are examples of processes that are not controlled from a terminal.

The command kill requires the PID of the process (use ps or top to nd the PID). The command killall needs the command name of the process. The signal to end the process can also be sent in top (using k). A list of all available signals can be viewed by entering kill -l (list). Because the commands kill and killall try to terminate a process in a controlled manner, clean-up is possible. If the process cannot be killed in this way, kill and killall can be used with the option -9 (or -SIGKILL). This signal should be used with caution, because although the operating system closes all les that are still open, data in buffers is no longer processed.

8-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

The best way to end a process is to do the following:

First use the command kill with the PID, as in the following: kill 1810 You can also use killall and the command name of the process. Wait a few moments for things to be cleaned up.

If the process is still there, send a SIGKILL, as in the following examples: kill -SIGKILL 1810 or kill -9 1810 You can also use killall and the command name of the process.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-13

SUSE Linux Fundamentals

Exercise 8-1

View Processes from the GUI and the Command Line Interface
To manage processes, do the following:
1.

Start KDE System Guard from the KDE menu by selecting System > Monitor > KDE System Guard. Display the process table by selecting the Process Table tab. Change the order of the process list by selecting the System% column heading. The processes that require the most processor load are now shown at the bottom of the list.

2. 3.

4. 5. 6.

Scroll to the bottom of the list. Open a terminal window. Position KDE System Guard window and the terminal window so you can view the entire Process Table. In the terminal window, enter find / -name novell. Notice that the processes with the names konsole and nd move to the bottom of the list.

7.

x
8. 9.

You might need to repeat the nd command more than once to see the processes konsole and nd move to the bottom of the list.

From the process table, select the Name column heading; then find and select the Konsole line. Select Kill.

10. Confirm that you want to kill the process by selecting Kill.

Notice that the Konsole terminal window disappears.


11. Close the KDE System Guard window. 12. Open a terminal window.

8-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

13. Start the program xeyes by entering xeyes. 14. Stop the process by pressing Ctrl+Z. 15. Move the xeyes process into the background by entering bg. 16. Verify that the process is running by entering jobs. 17. Kill xeyes by entering killall xeyes. 18. Display all running processes by entering ps aux | less. 19. Scroll through the output by pressing the Down Arrow and Up

Arrow keys.
20. Return to the command line by typing q. 21. Close the terminal window by entering exit.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-15

SUSE Linux Fundamentals

Objective 2

Understand the Runlevel Concept


In this objective, you learn the following about runlevels:

The init Program The Runlevels

The init Program


The system is initialized by /sbin/init, which is started by the kernel as the rst process of the system. This process, or one of its child processes, starts all additional processes. In addition, because init is the last process running, it ensures that all other processes are correctly ended. This means that init controls the entire booting up and shutting down of the system. Because of this position of priority, signal 9 (SIGKILL), with which all processes can normally be ended, has no effect on init. The main conguration le of init is /etc/inittab. This le determines what happens in the individual runlevels. Various scripts are started by init, depending on these entries. All these scripts are located in the directory /etc/init.d/.

The Runlevels
In Linux, various runlevels dene the state of the system. Which runlevel the system starts in when it is booted is dened in the le /etc/inittab by the entry initdefault. The standard default runlevel is normally 3 or 5. However, it is also possible to boot to another runlevel. The boot manager GRUB offers at system startup (by default), the following choices:

Linux

8-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

Floppy Failsafe

When you select one of these, the respective options are displayed in the eld boot options. For example, options for Linux might be root=/dev/hdx which tells the kernel the location of the root partition of the system. The option vga=x, indicating the resolution for the frame buffer device, is often specied. At this point, the runlevel to which the system should boot can be added. This parameter is passed to init. The following is an example entry in boot options:
root=/dev/hda4 vga=791 1

In this example, the root partition parameter of /dev/hda4 is sent to the kernel. The frame buffer is congured (vga=791), the system boots to runlevel 1 (single user mode for administration). After the system boots, you can switch to another runlevel by using the command init, as in the following: init 3 In the same way, you can change back to the standard runlevel (such as init 5) in which all programs needed for operation are run and where individual users are able to log in to the system. The following are the available runlevels: Table 8-6
Command 0 1 2 Description Halt Single-user mode Multiuser mode without network server services

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-17

SUSE Linux Fundamentals

(continued)

Table 8-6

Command 3 4 5 6

Description Multiuser mode with network Not used Multiuser mode with network and display manager Reboot

The command runlevel displays the runlevel you are currently in (second number) and the previous runlevel (rst number), as in the following:
da50:~ # runlevel N 5 da50:~ #

If the partition /usr/ of a system is mounted via NFS, runlevel 2 should not be used, because NFS le systems are not available in this runlevel.

You can shutdown the system by entering the following: init 0 You can reboot (restart) the system by entering the following: init 6

8-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

You can change the standard runlevel with the YaST runlevel editor (yast2 > System > Runlevel Editor > Expert Mode): Figure 8-2

If the standard runlevel is 5, users can log in through the GUI login screen. If it is set to 3, no graphical login is available.

You should take great care when making changes to the le /etc/inittab. If the le is corrupted, the system will no longer boot correctly. If an error does occur, it is still possible to boot the system. To do so, insert init=/bin/bash:root=/dev/hda1 vga=791 init=/bin/bash in the GRUB boot menu is place of the runlevel. In this way, the init process is replaced by a shell (so inittab is not read) and you can then repair the system manually.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-19

SUSE Linux Fundamentals

Exercise 8-2

Work With Runlevels


To understand the runlevel concept, do the following:
1.

Log out from KDE from the KDE menu by selecting Logout > Logout. Switch to the first virtual terminal by pressing Ctrl+Alt+F1. Log in as root with a password of novell. Reboot by entering init 6. When the boot menu is displayed, press the Spacebar to stop the timer. In the Boot Options field type 3; then press Enter to boot the Linux system to runlevel 3. When the login prompt appears, log in as root with a password of novell. Display the current runlevel by entering runlevel. Switch to runlevel 5 by entering init 5.

2. 3. 4. 5.

6.

7.

8. 9.

10. Switch back to the virtual terminal by pressing Ctrl+Alt+F1. 11. Log out as root by entering exit. 12. Switch back to the graphical user interface by pressing

Ctrl+Alt+F7.
13. Log in as geeko with a password of N0v3ll.
(End of Exercise)

8-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

Objective 3

Multitask in the Linux System


Many tasks, such as updating a database or backing up data, need to be carried out regularly on a running system. You can automate such tasks in Linux using the following services:

cron: Allows you to schedule tasks regularly. at: Allows you to run tasks once only.

Regular jobs are carried out in Linux via the cron service. This service runs as a daemon and checks once a minute to see if jobs have been dened for this time. You can dene 2 kinds of jobs with cron:

System Jobs Jobs of Individual Users

System Jobs
System jobs are controlled with the le /etc/crontab. This le, however, does not contain the scripts or commands needed to run the job. These are found in the following directories depending on how often they should be run: Table 8-7
Directory /etc/cron.hourly/ /etc/cron.daily/ /etc/cron.weekly/ /etc/cron.monthly/ Interval Jobs are run on an hourly basis. Jobs are run on a daily basis. Jobs are run on a weekly basis. Jobs are run on a monthly basis.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-21

SUSE Linux Fundamentals

If a job cannot be run at the specied time (the computer was turned off overnight), it is automatically run later. This is only valid for jobs dened in a script in one of the above directories.

Jobs of Individual Users


The jobs of individual users (including root) are stored in the directory /var/spool/cron/tabs/ in les matching the user names. These les always belong to the user root. The command crontab is used to edit them. You can use the following options with crontab to manage these jobs: Table 8-8
Option crontab -e Description Creates or edits jobs. For this, the vi editor is used. The specied le contains a list of jobs. Displays current jobs. Deletes all jobs.

crontab le crontab -l crontab -r

In the le used with crontab to list specic jobs, each line is used to dene a different job with 6 elds of information about the job. The rst 5 elds dene the time, while the nal eld contains the command to run. This can be any type of command or shell script. However, it cannot accept any interactive input (such as from the keyboard). You learn how to create your own cron jobs in the 3037 - SUSE Linux Administration course.

8-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

Exercise 8-3

View crontab Processes


To see the processes that run automatically, do the following:
1.

Open a terminal window; then su to root (su-) with a password of novell. Display all the scripts running automatically once a day by entering ls /etc/cron.daily/. Verify that the personal crontab of the user root is empty by entering crontab -l. Log out as root by entering exit. Close the terminal window by entering exit.

2.

3.

4. 5.

(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-23

SUSE Linux Fundamentals

Summary
Objective
1. View Processes from the GUI and
the Command Line Interface

Summary The KDE System Guard can be found in the KDE menu under System > Monitor > KDE System Guard. A program can be stopped by pressing Ctrl+Z. A stopped program can continue operating in the background with bg or in the foreground with the command fg. Appending an ampersand character to a command when calling it starts it directly in the background. To see all running processes, use the command ps. Each process contains a system-wide unique process number (PID). PID one always belongs to the init process. With the command pstree view a list of processes in the form of a tree structure. Use the command lsof to see which les are opened by processes. You can use the command top to see which process uses how much computing time.

8-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Understand and View Processes in the Linux System

Objective
1. View Processes from the GUI and
the Command Line Interface (continued)

Summary Processes can be controlled by signals. Such signals are generated by the commands kill and killall. The initialization of the system is done by /sbin/init, which is started by the kernel as the rst process of the system. The central conguration le of init is /etc/inittab. Various scripts are started by init. These scripts are located in the directory /etc/init.d. In Linux, various runlevels dene the state of the system. The system administrator can change to another runlevel with the command init. The following runlevels are available:

2. Understand the Runlevel Concept

0: Halt 1: Single-user mode 2: Multiuser mode without network server services 3: Multiuser mode with network 4: Not used 5: Multiuser mode with network and display manager 6: Reboot

The command runlevel displays the current and previous runlevels.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

8-25

SUSE Linux Fundamentals

Objective
3. Multitask in the Linux System

Summary Regular jobs are carried out via the cron service. System jobs are controlled via the le /etc/crontab. This le calls the commands in the following directories:

/etc/cron.hourly/ /etc/cron.daily/ /etc/cron.weekly/ /etc/cron.monthly/

The jobs of individual users can be edited by the command crontab.

8-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

SECTION 9

Manage the Network Conguration

Linux is designed to work in a network environment. This section explains how to congure network settings with YaST and introduces some basic commands that you can use to test the network connection.

Objectives
1. 2.

Manage the Network Configuration Information from YaST Get to Know Network-Related Command Line Commands

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-1

SUSE Linux Fundamentals

Introduction
A large network usually includes exchange network components (such as routers, hubs, and switches) that ensure the correct forwarding of data trafc. As the number of components installed in a network increases, so does the number of possible sources of error. To be able to analyze and correct errors, you need suitable diagnosis tools. This section introduces the most important diagnostic tools needed for daily work in a TCP/IP-based network.

9-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

Objective 1

Manage the Network Conguration Information from YaST


The YaST module for conguring network cards and the network connection can be accessed from the YaST Control Center by selecting Network Devices > Network Card:

Figure 9-1

Any uncongured network cards are listed in the top frame. The bottom frame displays congured network cards. Select the card you want to congure; then select Congure (if the card is being set up for the rst time) or Change (if you want to modify an existing conguration). Usually the card is autodetected by YaST, and the correct kernel module is used.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-3

SUSE Linux Fundamentals

If the card is not recognized by YaST, the required module must be entered manually in YaST. Select Other (not detected) and then select Congure. A Manual Card Setup dialog appears: Figure 9-2

From this dialog, you enter details of the interface to congure such as Network Device Type (Ethernet) and Conguration Name (0). Under Kernel module, enter the name of the module to load. You can select the card model from a list of network cards. Some kernel modules can be congured more precisely by adding options or parameters for the kernel. Details about parameters for specic modules can be found in the kernel documentation.

9-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

After selecting Next, the following dialog appears: Figure 9-3

From this dialog you enter the following information to integrate the network device into an existing network:

Automatic address setup (via DHCP). Select this option if the network card should receive an IP address from a DHCP server. Static address setup. If you choose this option, you need to enter the IP address of the network interface or of the computer in the network under IP Address. Each computer in the network has at least one address for each network interface, which must be unique in the entire network. According to the currently valid standard (IPv4), this address consists of a sequence of 4 bytes, separated by dots (such as 10.10.0.69).

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-5

SUSE Linux Fundamentals

When choosing the IP address, you need to know if the computer will be directly connected to the Internet. In this case, use an assigned ofcial IP address must be used. Otherwise, use an address from a private address space.

Network mask. The network mask (referred to as subnet mask in YaST), determines in which network an IP address is located. The mask divides the IP address into a network section and a host section, thus dening the size of a network. All computers within the network can reach each other directly without a router in between.

Host name and name server. Computers in the network can be addressed directly using their IP addresses or with a unique name. A name server (DNS) must exist for the resolution of names into IP addresses and vice versa.

9-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

After selecting Host name and name server, the following appears: Figure 9-4

This dialog lets you enter the following:

Host name. Enter a name with which the computer can be addressed. This name should be unique within the network. Domain name. This is the name of the DNS domain to which the computer belongs. Domains help to divide networks. All computers in a dened organizational area normally belong to the same domain. A computer can be addressed uniquely by giving its FQDN (Fully Qualied Domain Name). This consists of the host name and the name of the domain, such as da1.digitalairlines.com. In this case, the domain would be digitalairlines.com.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-7

SUSE Linux Fundamentals

List of name servers. To address other computers in the network with their host names, identify the name server, which guarantees the conversion of computer names to IP addresses and vice versa. You can specify a maximum of 3 name servers. Domain search list. In the local network, it is more appropriate to address other hosts not with their FQDN, but with their host names. The domain search list species up to 3 domains with which the system can expand the host name to the FQDN. This complete name is then passed to the name server to be resolved. For example, da2 is expanded with the search list digitalairlines.com to the FQDN da2.digitalairlines.com. This name is then passed to the name server to be resolved. If the search list contains several domains, the completion takes place one after the other, and the resulting FQDN is passed to the name server until an entry returns an associated IP address.

Routing. If the computer is intended only to reach other computers in the same subnet, then it is not necessary to enter any routes.

9-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

However, if you need to enter a default gateway or create a routing table, select Routing from the Network address setup dialog. The following appears: Figure 9-5

You can dene the following:

Default Gateway. If the network has a gateway (a computer that forwards information from a network to other networks), its address can be specied in the network conguration. All data not addressed to the local network is then forwarded directly to the gateway.

Routing Table. You can create entries in the routing table of the system after selecting Expert Conguration.

All the necessary information is now available to activate the network card.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-9

SUSE Linux Fundamentals

After you save the conguration with YaST, the ethernet card should be available in the computer. You can verify this with the command ifcong. If you run this command as a user other than root, you must enter the absolute path to the command, as in the following: /sbin/ifcong The output of ifcong should contain a data block in the rst line of the new interface with the symbolic name, as in the following example for eth0:
eth0 Link encap:Ethernet HWaddr 00:E0:7D:9E:02:E8 inet addr:192.168.0.20 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fec0::1:200:1cff:feb5:6516/64 Scope:Site inet6 addr: fe80::200:1cff:feb5:6516/10 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:2 txqueuelen:100 RX bytes:3225244 (3.0 Mb) TX bytes:23756 (23.1 Kb) Interrupt:10 Base address:0x7f00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:25829 errors:0 dropped:0 overruns:0 frame:0 TX packets:25829 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2667809 (2.5 Mb) TX bytes:2667809 (2.5 Mb)

9-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

You can also display network device conguration information with the command ip, as in the following:
da1:~ # ip address show 1: lo: <LOOPBACK,UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 brd 127.255.255.255 scope host lo inet6 ::1/128 scope host 2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100 link/ether 00:e0:7d:9e:02:e8 brd ff:ff:ff:ff:ff:ff inet 10.10.0.69/16 brd 10.10.255.255 scope global eth0 inet6 fec0::1:200:1cff:feb5:6516/64 scope site dynamic valid_lft 2591994sec preferred_lft 604794sec inet6 fe80::200:1cff:feb5:6516/10 scope link 3: sit0@NONE: <NOARP> mtu 1480 qdisc noop link/sit 0.0.0.0 brd 0.0.0.0

In this example, the interface eth0 was congured. Two network devices are always set up by default-the loopback device (lo) and the device sit0@NONE, which is needed for integrating cards in networks with Ipv6. However, the command ifcong does not display this network interface information by default.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-11

SUSE Linux Fundamentals

Exercise 9-1

Manage the Network Conguration Information from YaST


To manage the network conguration information from YaST, do the following:
1.

Open a terminal window and su to root (su -) with a password of novell. Use the ifconfig eth0 and hostname commands to record the following information for your SLES 9 server:

2.

IP address: Hostname:

3. 4.

Close the terminal window. From the KDE Desktop, select the YaST icon; then enter a password of novell and select OK. The YaST Control Center appears.

5.

Start the network card module by selecting Network Devices > Network Card. Your network card is listed under Already congured devices.

6.

Change the configuration of your network card by selecting Change. Your network card is displayed in a list of congured cards.

7. 8. 9.

Make sure your network card is selected; then select Edit. Switch the setup by selecting Static address setup. In the IP Address field, enter the IP address from Step 2.

10. In the Subnet mask field, enter 255.255.255.0. 11. Select Host name and name server. 12. (Conditional) If a dialog appears indicating that the resolv.conf

files has been temporarily modified, continue by selecting Modify.


13. In the Host Name field, enter the hostname from Step 2.

9-12

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

14. In the Domain Name field, enter digitalairlines.com. 15. In the Name Server 1 field, enter the IP address of your DNS

server (10.0.0.254).
16. If there are values in the other Name Server text fields, remove

them.
17. In the Domain Search 1 field, enter digitalairlines.com. 18. If there are values in the other Domain Search text fields, remove

them.
19. Select OK. 20. Select Routing. 21. In the Default Gateway field, enter the IP address of your Internet

gateway (10.0.0.254).
22. Select OK. 23. Select Next. 24. Select Finish. 25. Close the YaST Control Center.
(End of Exercise)

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-13

SUSE Linux Fundamentals

Objective 2

Get to Know Network-Related Command Line Commands


In this objective, you are introduced to the following commands and how to use them to test your network connection:

Determine Connectivity Between Hosts Using ping List Currently Active Network Connections With netstat Display the Route Between Hosts With traceroute Update Network Interfaces Configuration Using ifup and ifdown Display the Routing Table Using route

Determine Connectivity Between Hosts Using ping


The command /bin/ping is a simple diagnosis tool you can use to check network connections. It is normally available on all hosts which contain a TCP/IP stack and should always be the rst tool you use to diagnose network errors. To effectively use ping, you need to understand the following:

Common Uses of ping Problem Analysis

Common Uses of ping

The command ping lets you check network connections in a simple way between 2 hosts. The hosts can be located in the same or in remote networks. If the ping command works, then both the physical and logical connections are correctly set up between the two hosts.

9-14

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

In the simplest scenario, you enter ping host, which causes the host to send an ICMP datagram to the target host with the message echo request. If this ICMP datagram can be received by the target host, it will answer the initiating host with an ICMP datagram, and the message echo reply. When the message is sent using the ICMP protocol, no higher-level protocols, such as TCP or UDP, are used. This means that incorrect congurations within the higher protocols do not automatically lead to a reply failing. A typical output of the ping command looks like the following:
da1:~ # ping da2 PING da2.digitalairlines.com (10.0.0.2) from 10.0.0.254 : 56(84) bytes of data. 64 bytes from da2.digitalairlines.com (10.0.0.2): icmp_seq=1 ttl=255 time=0.309 ms 64 bytes from da2.digitalairlines.com (10.0.0.2): icmp_seq=2 ttl=255 time=0.191 ms 64 bytes from da2.digitalairlines.com (10.0.0.2): icmp_seq=3 ttl=255 time=0.194 ms -- da2.digitalairlines.com ping statistics --3 packets transmitted, 3 received, 0% loss, time 2010ms rtt min/avg/max/mdev = 0.191/0.231/0.309/0.056 ms

A total of three ICMP datagrams were sent to the host da2.digitalairlines.com (echo request). The datagrams were answered with a message (echo reply). The output shows the following details:

The IP address of the target host (da2 is resolved to da2.digitalairlines.com, and da2.digitalairlines.com is resolved to 10.0.0.2). The size of an ICMP datagram (dates, ICMP header and IP header): 56(84) bytes of data.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-15

SUSE Linux Fundamentals

The sequence number of each reply datagram (icmp_seq, starting with 1 and increasing by 1 each time). The TTL (ttl, time to live) of the datagram. When the datagram is sent, it has the value 255 in Linux. Each time it passes through a router in the Internet, it is decreased by 1. If the TTL reaches the value 0, then the packet is discarded. You can often deduce how many routers a datagram has passed through from the destination host by using the TTL value.

The time (time) each round-trip needs. In other words, the amount of time needed to transmit an echo request datagram and receive the corresponding echo reply datagram.

A statistical output of the round-trip times: min/avg/max/mdev (minimum/average/maximum/median deviation).

If a network connection fails, a typical output of the ping command looks like the following:
da1:~ # ping da2 PING da2.digitalairlines.com (10.0.0.2) from 10.0.0.254 : 56(84) bytes of data. From da1.digitalairlines.com (10.0.0.254): icmp_seq=1 Destination Host Unreachable From da1.digitalairlines.com (10.0.0.254) icmp_seq=1 Destination Host Unreachable --- 10.0.0.2 ping statistics --2 packets transmitted, 0 received, +2 errors, 100% loss, time 2010ms, pipe 3

In the above output, the ping command tried to send a total of 2 ICMP (echo request) datagrams to the target host da2.digitalairlines.com, but the sending host received no answer from the target host within a given period of time.

9-16

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

The command ping has a series of parameters which are covered in the course SUSE Linux Administration (3037). A description of all possible parameters can be found in the manual page for ping (man 8 ping).

Problem Analysis

If you want to examine communication between two hosts, then you should start by checking the internal host network (ping localhost). Then you should check the network interface connected to your own host (ping interface_addr). If these checks of the host-internal network and the connected network interface are successful, then you should check the network segment associated with the next closest network element (such as the default gateway router) in the direction of the target host. You would then check the network section containing the next but one segment, and so on, until the check ends at the target host. If, during this check, no reply datagram is returned at a dened point, you should assume that at least one error is located in the last segment (such as cables, hub, switch, router, conguration) checked. As a rule, using such a procedure can help you narrow down the source of the error.

List Currently Active Network Connections With netstat


The command /bin/netstat is a tool that can help you determine the status of all network connections, routes, and interfaces on a host. To effectively use the command, you need to understand the following:

Common Use of netstat Problem Analysis

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-17

SUSE Linux Fundamentals

Common Use of netstat

The command netstat displays the status of all open sockets (network connections) and analyzes all network connections the host. In the simplest scenario, you can enter netstat by itself to display information similar to the following:
da1:/ # netstat Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 da1.digitalairlines.com:604 da10.digitalairlines.com:966 TIME_WAIT tcp 0 0 da1.digitalairlines.com:1023 da10.digitalairlines.com:ssh ESTABLISHED Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 8 [ ] DGRAM 746 /dev/log unix 2 [ ] DGRAM 748 /var/lib/dhcp/dev/log unix 2 [ ] DGRAM 81109 unix 3 [ ] STREAM CONNECTED 8214 /tmp/.X11-unix/X0 unix 3 [ ] STREAM CONNECTED 8213 unix 3 [ ] STREAM CONNECTED 8199 /tmp/.X11-unix/X0 unix 3 [ ] STREAM CONNECTED 8191 ...

netstat provides information on all active network connections (sockets). This output displays two blocks with the following information:

In the first block, each socket is listed on a separate line:

The rst line involves a socket between the hosts da1.digitalairlines.com (Local Address) and da10.digitalairlines.com (Foreign Address) via the TCP protocol (Proto). The connection was established between the ports 604 (da1) and 966 (da10).

9-18

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

The information below Recv-Q and Send-Q shows that no data is waiting to be collected by the process in the receive queue for this host and that no data is waiting for the host da10.digitalairlines.com in the send queue. All available data until now has already been processed. Finally, the information under State provides details of the socket's current condition. TIME_WAIT signals that the socket still needs to be cleared up but is almost closed. An active socket is referred to as ESTABLISHED.

The second block provides information on the UNIX domain sockets active on this host. Each line stands for one socket:

The protocol (Proto) is always unix. The reference counter (RefCnt) shows the number of active processes which are connected to the matching socket. Special ags (Flags) are not set (possible ags: SO_ACCEPTION = ACC, SO_WAITDATA = W, SO_NOSPACE = N). For details, see man netstat. The type for all sockets listed is STREAM, because this is a connection-oriented socket. All listed sockets are connected (State, CONNECTED). Finally, the inodes (I-Node) of the sockets and the pathname (Path) of the process connected to them are listed.

netstat has a large number of possible parameters. These are covered in the course SUSE Linux Administration (3037). A description of all possible parameters can be found in the manual page for netstat (man 8 netstat).

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-19

SUSE Linux Fundamentals

Problem Analysis

You can use netstat to monitor the use of resources for network sockets on a host. If a number of clients access a server simultaneously, it is possible that the number of sockets available or the resources for these are no longer sufcient. In these cases, netstat provides detailed information on existing and available network sockets or resources.

Display the Route Between Hosts With traceroute


You can use the command /usr/sbin/traceroute to help you follow the route taken by an IP datagram to the given target host. To effectively use the traceroute command, you need to understand the following:

Common Use of traceroute Problem Analysis

Common Use of traceroute

The command traceroute is primarily used to check routings between different networks and to illustrate the routings involved between the various TCP/IP-based networks. To achieve this task, traceroute sends datagrams with an increasing TTL (Time To Live) value to the destination host. First, 3 packets with a TTL=1 are sent to the host, then three packets with a TTL=2, and so on.

9-20

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

Since the TTL is reduced by one when the UDP datagram passes through a router (hop) and this datagram is discarded at TTL=0, a gateway at TTL=0 sends an ICMP datagram with the message time to live exceeded back to the sender. If the UDP datagram reaches the target host, it will reply with an ICMP datagram port unreachable, since the target port for the UDP datagrams is set to values for which no services from the target host are normally offered. From the ICMP message port unreachable, the sender recognizes that the target host has now been reached. traceroute evaluates the information collected and also provides some statistical information on the standard output. In the simplest scenario, you can perform a check of routing to the target host by entering the following: traceroute host A typical output of traceroute looks like the following:
da1: # traceroute pluto traceroute to pluto.digitalairlines.com (192.168.2.1), 30 hops max, 40 byte packets 1 da1.digitalairlines.com (10.0.0.254) 0 ms 0 ms 0 ms 2 antares.digitalairlines.com (192.168.1.254) 14 ms 18 ms 14 ms 3 pluto.digitalairlines.com (192.168.2.1) 19 ms * 26 ms

In the example, a total of 3 nodes were detected in the network across which the datagrams were routed to the target host. The output shows the following details:

The IP address of the target host, Pluto, is resolved to pluto.digitalairlines.com; and pluto.digitalairlines.com is resolved to 192.168.2.1.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-21

SUSE Linux Fundamentals

The maximum TTL of a UDP packet is 30 (30 hops max), which means that a maximum of 30 steps over routers/gateways can be detected on the path to the destination host. A UDP datagram has a length of 40 bytes. The time for a round-trip for a total of three packets sent in succession by each router/recipient is displayed in milliseconds (ms). The second UDP datagram to reach pluto.digitalairlines.com directly was not answered within the given timeout of three seconds (*).

You can use the command traceroute with a whole range of additional parameters. These are covered in the course SUSE Linux Administration (3037). A description of all possible parameters can be found in the manual page for traceroute (man traceroute).

Problem Analysis

If communication between two networks is defective, the transport path between these two networks might contain errors. traceroute is an ideal tool to check routers which are located on this transport path. It provides detailed information about the path which a datagram must take to the target network. It also provides information on the availability of the routers installed on this path. If you enter traceroute with the parameter target host, you can see at a glance at which hop a data package can move along the transport path without a problem and at which point the transport path is faulty.

9-22

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

Update Network Interfaces Conguration Using ifup and ifdown


To save the network conguration parameters permanently, you need to edit the respective conguration les. You can nd all relevant conguration les in the directory /etc/syscong/network/. This directory contains a conguration le for each congured network adapter. The conguration le includes details of a device such as /etc/syscong/network/ifcfg-eth-id-00:00:1c:b5:55:74 for a network card with the hardware address 00:00:1c:b5:55:74 and /etc/syscong/network/ifcfg-lo for the loopback device. To understand the structure of the conguration les, you need to understand how the network device is activated when the system boots. All network interfaces and congured routes are activated at boot by the script /etc/init.d/network, which is run in runlevels 2, 3, and 5. Based on the content of the conguration les in the directory /etc/syscong/network/, the script knows which interfaces need to be activated or, if the computer is shut down, deactivated. The le /etc/syscong/network/cong contains a number of general variables that inuence the behavior of the script. For example, a parameter might indicate whether a search should be made for existing connections when the interface is deactivated and if these should be automatically terminated. The directory /etc/syscong/network/scripts/ contains additional scripts that are run by the script /etc/init.d/network, depending on the type of interface. The network interfaces are activated or deactivated when the script /sbin/ifup runs from the script /etc/init.d/network.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-23

SUSE Linux Fundamentals

The /sbin/ifup script evaluates the interface conguration les and activate the network cards with the command ip. /sbin/ifdown deactivates network interfaces and /sbin/ifstatus displays the status of network interfaces. These are symbolic links to the script /etc/sbin/ifup. If the start script /etc/init.d/network is used, all congured network interfaces are activated or deactivated, or the status of all congured network interfaces is given. To activate a single interface with the precongured values, to nd out the status of a single interface, or to deactivate only one interface, you can use the commands ifup, ifstatus and ifdown. The following is an example of using ifup: ifup eth0 In this example, the rst ethernet card eth0 is activated. The following is an example of using ifdown: ifdown eth1 In this example, the network device eth1 is deactivated.

9-24

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

The following is an example of using ifstatus:


da1:~ # ifstatus eth0 2: eth0: <BROADCAST,MULTICAST,NOTRAILERS,UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:00:1c:b0:a2:85 brd ff:ff:ff:ff:ff:ff inet 10.0.0.20/24 brd 10.0.0.255 scope global eth0 inet6 fe80::200:1cff:feb0:a285/64 scope link valid_lft forever preferred_lft forever eth0 IP address: 10.0.0.20/24 Configured routes for interface eth0: default 10.0.0.254 - 169.254.0.0 - 255.255.0.0 eth0 Active routes for interface eth0: 10.0.0.0/24 proto kernel scope link src 10.0.0.20 0 of 2 configured routes for interface eth0 up

In this example, the status is displayed for the rst ethernet card. When the interfaces are activated via the scripts /etc/init.d/network or ifup, the values are read from the conguration le for that particular network card. The following is an example of the contents of the conguration le /etc/syscong/network/ifcfg-eth-id-00:00:1c:b5:55:74:
BOOTPROTO='static' BROADCAST='10.0.0.255' IPADDR='10.0.0.69' MTU='' NETMASK='255.255.255.0' NETWORK='10.00.0.0' REMOTE_IPADDR='' STARTMODE='onboot' UNIQUE='bSAa.+xOL8ZCSAQC' _nm_name='bus-pci-0000:00:0a.0'

These parameters are evaluated by /sbin/ifup (see man 8 ifup). The script calls up /sbin/ip with the evaluated parameters to assign address, network mask, and so on, for that particular network interface, and to set routes.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-25

SUSE Linux Fundamentals

The parameter UNIQUE contains a unique hash value that is required by YaST to identify which card to activate. In the above conguration le, a static address is assigned (BOOTPROTO='static'). In a conguration for a dynamic allocation via DHCP, the value dhcp would be given here. The onboot option in the start mode species that this interface should be activated when the script /etc/init.d/network is run. The values IPADDR='10.0.0.69', NETMASK='255.255.255.0', and NETWORK='10.0.0.0' specify the IP address, network mask, and network address for the network card. If the conguration is implemented via DHCP, these entries remain empty or are deleted entirely. You can nd documentation about network conguration in the directory /usr/share/doc/packages/syscong/ and in the manual pages for the individual commands. To congure IP aliases permanently, you must add the aliases to the respective conguration le of the network card. An example is available in the le /etc/syscong/network/ifcfg.template. When the network script /etc/init.d/network is executed, the associated interface is also activated. You cannot dene IP aliases with YaST.

Display the Routing Table Using route


You can use the command route (/sbin/route) to check and edit the routing table. The command route returns a table of activated routes. The parameter -n displays the listed addresses in numerical form (no name server query). The command route functions are covered by the command ip in the script for starting the network.

9-26

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

The destination for each TCP/IP data packet generated on the computer is compared line for line, from top to bottom, with the entries in the routing table. When a dened destination network in the routing table matches the receiver IP address of the data packet, the data packet is delivered via the corresponding interface and, possibly, forwarded directly to the dened gateway. If no route exists for the target address of the data packet, this packet is discarded.

Routes dened with the command route are entered directly in the kernel routing table. They no longer exist when the server is rebooted. For a permanent denition, the respective conguration les must be edited.

Using the route command to set and delete routes is covered in the course SUSE Linux Administration (3037). You can nd a description of all possible parameters in the manual page for route (man route). If you enter the command route without any options, the current routing table is displayed, as in the following:
da10:~ # route Kernel IP routing table Destination Gateway Genmask lags Metric Ref Use Iface 10.0.0.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 0 0 0 eth0 loopback * 255.0.0.0 U 0 0 0 lo default da1.digitala 0.0.0.0 UG 0 0 0 eth0

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-27

SUSE Linux Fundamentals

Exercise 9-2

Use Network-Related Commands


To understand network-related command line commands, do the following:
1. 2. 3. 4. 5.

Open a terminal window. Su to root (su -) with a password of novell. Test the connection to DA1 by entering ping 10.0.0.254. Stop the ping process by pressing Ctrl+C. Test the connection to the host www.novell.com by entering ping 130.57.4.27. Test the connection to the host www.novell.com by entering traceroute 130.57.4.27. View the status of all open sockets by entering netstat. View the actual routes by entering route. Log out as root by entering exit.

6.

7. 8. 9.

10. Close the terminal window by entering exit.


(End of Exercise)

9-28

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Manage the Network Configuration

Summary
Objective
1. Manage the Network
Conguration Information from YaST

Summary The YaST module for conguring the network card and the network connection can be found at Network Devices > Network Card. The following details are then needed to integrate the network device into an existing network:

Method of network setup Static IP address Network mask Host name Name server Routing (gateway)

After you save the conguration with YaST, the ethernet card should be available in the computer. You can verify this with the command ifcong.

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

9-29

SUSE Linux Fundamentals

Objective
2. Get to Know Network-Related
Command Line Commands

Summary You can use several diagnostic tools to check your network connection. The command ping causes the executing host to send an ICMP datagram to the target host. If this datagram can be received by the target host, it will also answer with another ICMP datagram. The command netstat displays the status of all open sockets (network connections) and allows an analysis of all network connections on this host to be made. The diagnosis tool traceroute is primarily used to check routings between different networks and to identify the routings involved between the various TCP/IP-based networks. The command route returns a table of activated routes. The parameter -n displays the listed addresses in numerical form (no name server query).

9-30

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Novell CLP and LPI Requirements

APPENDIX A

Novell CLP and LPI Requirements

This appendix provides information about the LPI Level I objectives covered in this and the other Novell CLP certication courses. LPI objectives named 1.xxx.y are part of exams 101 and 102 (LPI Certication Level 1). LPI objectives named 2.xxx.y are part of exams 201 and 202 (LPI Certication Level 2). CLP courses include the section (such as 3037/3 for Course 3037 Section 3). Because the Novell CLP courses use SUSE Linux exclusively, there are some differences in the software used in those courses and those covered by the LPI objectives (such as CUPS for printing in SLES 9 and lpr in the LPI objectives). Table A-1
LPI Objective Topic 101: Hardware & Architecture 1.101.1 Congure fundamental BIOS settings not applicable CLP Courses

1.101.3 Congure modem and sound cards not applicable 1.101.4 Setup SCSI devices 1.101.5 Setup different PC expansion cards 1.101.6 Congure communication devices 1.101.7 Congure USB devices not applicable not applicable

not applicable not applicable

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

A-1

SUSE Linux Fundamentals

(continued)

Table A-1

LPI Objective Topic 102: Linux Installation and Package Management 1.102.1 Design hard disk layout 1.102.2 Install a boot manager 1.102.3 Make and install programs from source 1.102.4 Manage shared libraries 1.102.5 Use Debian package management 1.102.6 Use RPM Package Manager (RPM)

CLP Courses

3037/3, 3038/1 3037/5, 3038/5 3038/7

3037/4 not applicable 3036/5, 3037/4

Topic 103: GNU and Unix Commands 1.103.1 Work on the command line 1.103.2 Process text streams using lters 1.103.3 Perform basic le management 1.103.4 Use streams, pipes, and redirects 1.103.5 Create, monitor, and kill processes 1.103.6 Modify process execution priorities 1.103.7 Search text les using regular expressions 1.103.8 Perform basic le editing operations using vi 3036/3, 3036/5 3036/6 3036/6 3036/5, 3036/6 3036/8, 3037/6, 3038/8 3036/8, 3037/6, 3038/8 3036/6

3036/7

A-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Novell CLP and LPI Requirements

(continued)

Table A-1

LPI Objective Topic 104: Devices, Linux Filesystems, Filesystem Hierarchy Standard 1.104.1 Create partitions and lesystems

CLP Courses

3037/3, 3038/1

1.104.2 Maintain the integrity of lesystems 3037/3 1.104.3 Control mounting and unmounting lesystems 1.104.4 Managing disk quota 1.104.5 Use le permissions to control access to les 1.104.6 Manage le ownership 1.104.7 Create and change hard and symbolic links 1.104.8 Find system les and place les in the correct location 3036/6, 3037/3

3037/3 3036/6, 3037/2

3036/6, 3037/2 3036

3036/6

Topic 105: Kernel 1.105.1 Manage/query kernel and kernel modules at runtime 1.105.2 Recongure, build, and install a custom kernel and kernel modules 3037/5

not applicable

Topic 106: Boot, Installation, Shutdown and Runlevels 1.106.1 Boot the system 1.106.2 Change runlevels and shutdown or reboot system 3037/5, 3038/5 3036/8, 3037/5, 3037/6

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

A-3

SUSE Linux Fundamentals

(continued)

Table A-1

LPI Objective

CLP Courses

Topic 107: Printing 1.107.2 Manage printers and print queues 1.107.3 Print les 1.107.4 Install and congure local and remote printers 3037/8 3037/8 3037/8

Topic 108: Documentation 1.108.1 Use and manage local system documentation 1.108.2 Find Linux documentation on the Internet 1.108.5 Notify users on system-related issues 3036/3

3036/3

3036/2

Topic 109: Shells, Scripting, Programming and Compiling 1.109.1 Customize and use the shell environment 1.109.2 Customize or write simple scripts 3036/5, 3038/6

3038/6

Topic 110: X 1.110.1 Install and congure XFree86 1.110.2 Setup a display manager 1.110.4 Install and customize a window manager environment not applicable not applicable not applicable

A-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Novell CLP and LPI Requirements

(continued)

Table A-1

LPI Objective

CLP Courses

Topic 111: Administrative Tasks 1.111.1 Manage users and group accounts and related system les 1.111.2 Tune the user environment and system environment variables 1.111.3 Congure and use system log les to meet administrative and security needs 3036/5, 3037/2

3036/5, 3037/2

3037/6, 3038/8

1.111.4 Automate system administration 3036/8, 3037/6 tasks by scheduling jobs to run in the future 1.111.5 Maintain an effective data backup strategy 1.111.6 Maintain system time 3036/6, 3037/3, 3038/5

3037/8

Topic 112: Networking Fundamentals 1.112.1 Fundamentals of TCP/IP 1.112.3 TCP/IP conguration and troubleshooting 1.112.4 Congure Linux as a PPP client 3036/9, 3037/7 3036/9, 3037/7, 3038/1

not applicable

Topic 113: Networking Services 1.113.1 Congure and manage inetd, xinetd, and related services 1.113.2 Operate and perform basic conguration of sendmail 3037/9

not applicable

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

A-5

SUSE Linux Fundamentals

(continued)

Table A-1

LPI Objective 1.113.3 Operate and perform basic conguration of Apache 1.113.4 Properly manage the NFS, smb, and nmb daemons 1.113.5 Setup and congure basic DNS services 1.113.7 Setup secure shell (OpenSSH)

CLP Courses 3037/8, 3038/3

3037/9, 3038/3

3038/1

3037/10

Topic 114: Security 1.114.1 Perform security administration tasks 1.114.2 Setup host security 1.114.3 Setup user level security 3038/4

3038/4 3037/2, 3038/4

Topic 201: Linux Kernel 2.201.1 Kernel components 2.201.2 Compiling a kernel 2.201.3 Patching a kernel 2.201.4 Customizing a kernel not applicable not applicable not applicable not applicable

Topic 202: System Startup 2.202.1 Customizing system startup and boot process 2.202.2 System recovery 3037/5, 3037/6

3038/5

A-6

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Novell CLP and LPI Requirements

(continued)

Table A-1

LPI Objective Topic 203: Filesystem 2.203.1 Operate the Linux lesystem 2.203.2 Maintaining a Linux lesystem 2.203.3 Creating and conguring lesystem options

CLP Courses

3037/3 3037/3 3037/3

Topic 204: Hardware 2.204.1 Conguring RAID 2.204.2 Adding new hardware 2.204.3 Software and kernel conguration 2.204.4 Conguring PCMCIA devices 3038/1 3038/9 3038/1 not applicable

Topic 205: Networking 2.205.1 Basic network conguration 2.205.2 Advanced network conguration and troubleshooting 3036/9, 3037/7, 3038/1 3036/9, 3037/7, 3038/1

Topic 206: Mail and News 2.206.1 Conguring mailing lists 2.206.2 Using sendmail 2.206.3 Managing mail trafc 2.206.4 Serving news not applicable not applicable not applicable not applicable

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

A-7

SUSE Linux Fundamentals

(continued)

Table A-1

LPI Objective Topic 207: DNS 2.207.1 Basic BIND 8 conguration 2.207.2 Create and maintain DNS zones 2.207.3 Securing a DNS server

CLP Courses

not applicable 3038/1 3038/1

Topic 208: Web Services 2.208.1 Implementing a web server 2.208.2 Maintaining a web server 2.208.3 Implementing a proxy server 3037/9, 3038/3 3037/9, 3038/3 not applicable

Topic 209: File and Service Sharing 2.209.1 Conguring a samba server 2.209.2 Conguring an NFS server 3037/8, 3038/3 3037/8

Topic 210: Network Client Management 2.210.1 DHCP conguration 2.210.2 NIS conguration 2.210.3 LDAP conguration 2.210.4 PAM authentication not applicable 3037/8 3037/8, 3038/2 3037/2

Topic 211: System Maintenance 2.211.1 System logging 2.211.2 Packaging software 3037/6, 3038/8 not applicable

A-8

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Novell CLP and LPI Requirements

(continued)

Table A-1

LPI Objective 2.211.3 Backup operations

CLP Courses 3038/5

Topic 212: System Security 2.212.2 Conguring a router 2.212.3 Securing FTP servers 2.212.4 Secure Shell (OpenSSH) 2.212.5 TCP wrappers 2.212.6 Security tasks not applicable not applicable 3037/10 3037/9 3038/4

Topic 213: System Customization and Automation 2.213.1 Automating tasks using scripts 3037/6, 3038/6

Topic 214: Troubleshooting 2.214.2 Creating recovery disks 2.214.3 Identifying boot stages 2.214.4 Troubleshooting LILO 2.214.5 General troubleshooting 2.214.6 Troubleshooting system resources 2.214.7 Troubleshooting network issues 2.214.8 Troubleshooting environment congurations 3037/3, 3038/5 3037/5, 3038/5 not applicable 3038/5 3037/5 3037/7, 3038/1 3038/5

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

A-9

SUSE Linux Fundamentals

A-10

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Index

Index

A
address 9-18 administration Intro-1, Intro-3, 9-17, 9-19, 9-22, 9-27 administrator 5-13 Apache 1-8, 5-14, 6-29

B
background 1-1, 2-9, 2-30, 3-12, 8-2, 8-58-6, 8-15, 8-24 backup 5-70 binary 6-37, 6-55

5-13, 5-21, 6-36-5, 6-14, 6-31, 6-376-38, 6-416-42, 6-49, 6-546-55, 8-16, 8-25, 9-1, 9-39-4, 9-99-12, 9-17, 9-239-27, 9-29 configure Intro-6, 1-16, 1-18, 1-22, 1-26, 1-301-31, 1-35, 4-184-21, 4-25, 4-364-37, 5-13, 6-11, 6-46, 9-1, 9-39-4, 9-26 create Intro-5, 1-21, 2-14, 2-252-26, 3-16, 3-19, 4-64-7, 4-9, 4-14, 4-164-17, 4-354-36, 5-11, 5-14, 5-20, 5-31, 5-35, 5-41, 5-445-47, 5-59, 5-655-66, 5-68, 5-705-71, 5-82, 5-855-86, 6-12, 6-19, 6-30, 6-35, 6-51, 8-22, 9-9 cursor 2-13, 3-6, 3-103-11, 5-325-33, 5-35, 7-47-6, 7-8

C
cache 6-7 class 1-10, 1-16 cluster 1-10 commands 3-4, 5-61 compatibility 1-16 component 1-6, 1-8, 2-3, 2-11, 2-32, 5-7, 5-26, 9-2 compressed 5-32, 5-665-68, 5-735-76, 5-85, 5-915-92 compression 5-735-75, 5-92 configuration Intro-2, Intro-7Intro-8, 1-9, 1-15, 1-211-23, 1-26, 1-28, 1-30, 1-32, 1-35, 1-381-39, 1-41, 3-43-5, 3-19, 4-2, 4-184-19, 4-244-26, 4-30, 4-334-34, 4-364-37, 5-55-6, 5-105-11,

D
database 6-38, 6-55 deactivate 9-24 device 5-8, 5-68, 9-11 DHCP 1-28, 1-30, 9-5, 9-18, 9-26 diagnose 9-14 directory 2-172-20, 2-28, 3-7, 3-9, 3-123-14, 3-24, 4-6, 4-11, 4-164-17, 5-35-8, 5-105-17, 5-195-24, 5-265-30, 5-375-43, 5-47, 5-50, 5-52, 5-585-59, 5-61, 5-645-65, 5-685-73, 5-765-77, 5-79, 5-845-86, 5-905-91, 5-93, 6-7, 6-11, 6-17, 6-19, 6-226-23, 6-256-27, 6-29, 6-31, 6-336-37, 6-45, 6-50, 6-54, 7-13, 8-16,

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Index-1

SUSE Linux Fundamentals

8-218-22, 8-25, 9-23, 9-26 disk space 1-15 DNS 1-9, 1-30, 9-69-7, 9-13 domain name server 1-8 dynamic 9-11

H
hardware 1-4, 1-61-7, 1-16, 1-18, 1-211-22, 1-35, 1-39, 2-3, 2-20, 4-184-19, 4-25, 4-334-34, 4-364-37, 5-75-8, 5-12, 5-19, 5-26, 9-23 header 3-3, 9-15 high availability 1-10 HTML 5-76, 6-25

E
encrypted 5-10, 6-276-30 entry 5-26 ETC 6-24 external 5-57, 5-88, 8-10

I
installation 1-18, 1-41, 4-18 interval 8-21

F
file system Intro-8, 1-10, 1-16, 2-172-18, 2-272-28, 5-15-5, 5-14, 5-16, 5-195-21, 5-23, 5-255-26, 5-445-45, 5-48, 5-525-54, 5-57, 5-59, 5-65, 5-69, 5-84, 5-87, 5-91, 6-17, 6-37 format 3-7, 3-13, 8-9

K
keyword 7-57-6

L
libraries 5-12, 5-15 Linux 5-2 list 1-18, 5-74, 6-23 LOAD 8-38-4, 8-9, 8-118-12, 8-14, 9-4 logical 5-9, 6-28, 9-14

G
gateway 9-27 generate 6-30, 8-7 global 6-4, 6-41, 9-11, 9-25 graphical user interface 1-8, 2-2 group 4-7, 6-39 GUI 1-39, 2-2, 2-10, 2-202-21, 2-28, 3-15, 3-19, 4-16, 8-3, 8-14, 8-19

M
MAIL 5-28 management Intro-2, Intro-7Intro-8, 1-4, 1-6, 1-10, 1-18, 1-30, 2-10, 4-1, 4-8, 4-12, 4-15, 4-27, 5-64, 7-10, 8-1, 8-12 master 2-10, 5-6 media 5-12, 5-20 memory 1-4, 1-9, 1-18, 5-19, 5-75, 8-38-4, 8-9

Index-2

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

Index

monitor 2-3, 2-12, 2-24, 2-29, 3-8, 6-21, 8-3, 8-14, 8-24, 9-20 mount point 5-21

R
RAID 1-16 RAM 1-15 read 5-82 rename 5-40 resource 1-10, 1-13, 2-10, 3-21 management 1-10 root 5-17, 5-28, 5-35, 5-405-41, 5-43, 5-47, 5-59, 5-82, 6-28, 6-35, 6-43, 8-11, 8-23, 9-12, 9-28 router 9-21

N
navigation 2-172-20, 2-27, 3-14, 5-72 Navigator 2-17 network 9-17 NFS 1-9, 5-55, 8-18 node 3-9, 5-44, 9-189-19, 9-21 Notes 1-29, 1-34, 1-381-39, 3-12, 3-14, 3-19, 3-24, 5-34, 5-64, 5-76, 6-44, 6-55

S
SCSI 1-9, 5-85-9, 5-19, 5-68, 8-11 security 1-6, 1-17, 1-331-34, 2-10, 2-20, 3-20, 4-7, 4-164-17, 4-354-36 server Intro-1, Intro-5, Intro-9, 1-61-8, 1-15, 1-18, 1-20, 1-24, 1-301-32, 1-361-37, 1-401-41, 2-22-6, 2-10, 2-29, 2-32, 3-7, 3-9, 3-123-13, 3-24, 4-2, 4-7, 4-30, 5-10, 5-14, 5-34, 5-54, 6-4, 6-7, 6-14, 6-29, 6-46, 7-3, 8-17, 8-25, 9-59-8, 9-129-13, 9-20, 9-269-27, 9-299-30 Service Location Protocol 1-10 session 6-9, 6-50 set 9-19 setup 9-5 size 5-52, 6-39 SLP 1-91-10, 1-40 software Intro-8, 1-3, 1-61-7, 1-151-17, 1-19, 1-221-24, 1-37, 4-34-4, 4-274-32, 4-37, 6-376-41, 6-43, 6-55 space 1-15 start Intro-9, 1-39, 2-11, 2-13, 2-162-17, 2-20, 2-232-25, 2-272-28, 2-30,

O
operating system 1-5 options 5-70

P
parameters 1-9, 4-10 partition 5-5, 5-20, 8-18 password 1-38, 2-6, 5-35, 6-35 physical 1-5, 1-18, 5-29, 5-85, 9-14 ping 9-17 port 4-25, 5-8, 5-19, 9-21 printer 1-2, 3-19, 4-184-26, 4-364-37, 5-7 location 4-22 printing 4-26 processes 8-2 processor 1-9, 1-12, 5-19, 8-38-4, 8-14 property 2-26, 4-11, 4-26, 5-515-52, 5-58 protocol 1-10, 9-15, 9-189-19

Version 3

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Index-3

SUSE Linux Fundamentals

3-8, 3-14, 3-19, 3-21, 4-24-3, 4-5, 4-164-17, 4-25, 4-27, 4-37, 5-5, 5-10, 5-48, 5-51, 5-585-59, 5-66, 5-705-71, 5-90, 6-86-10, 6-19, 6-37, 6-46, 6-50, 7-3, 7-8, 7-10, 7-13, 8-2, 8-48-6, 8-8, 8-148-15, 9-12, 9-17, 9-24, 9-26 state 9-18 storage 5-65 subnet 9-6, 9-8, 9-12 SYS 5-19 system Intro-2, Intro-7Intro-8, 1-21-3, 1-51-6, 1-8, 1-10, 1-121-18, 1-201-24, 1-29, 1-31, 1-331-35, 1-371-38, 1-401-41, 2-22-4, 2-6, 2-92-11, 2-172-18, 2-272-30, 2-323-1, 3-33-5, 3-15, 3-24, 4-2, 4-54-7, 4-18, 4-35, 5-15-8, 5-105-16, 5-185-23, 5-255-26, 5-445-45, 5-48, 5-525-54, 5-57, 5-59, 5-65, 5-69, 5-84, 5-87, 5-91, 6-26-4, 6-126-13, 6-17, 6-23, 6-27, 6-29, 6-34, 6-376-38, 6-416-42, 6-45, 6-49, 6-51, 6-54, 7-1, 7-3, 7-8, 7-10, 7-137-14, 8-18-4, 8-7, 8-12, 8-14, 8-168-21, 8-248-26, 9-89-9, 9-23

U
UNIX 1-3 upgrade 6-41 user 4-11, 8-4, 8-8, 8-11 account 1-30, 1-32, 4-84-9, 4-114-12, 4-35, 6-306-31, 6-33, 6-54 interface 1-8, 2-2, 4-2 name 6-28 utilities 4-26, 5-66, 5-71, 5-90, 7-10, 7-13

V
value 8-9 version 6-39 view 2-272-28, 3-14, 7-11, 7-13, 7-15

W
web server 1-8, 5-14, 6-29 write 4-6

Z T
time 1-3, 1-61-7, 1-9, 1-12, 1-151-16, 1-22, 1-41, 2-122-13, 2-29, 3-6, 3-16, 3-21, 4-54-6, 5-27, 5-31, 5-39, 5-44, 5-48, 5-735-74, 5-85, 5-92, 6-3, 6-66-7, 6-14, 6-16, 6-32, 8-2, 8-4, 8-78-9, 8-11, 8-218-22, 8-24, 9-3, 9-159-16, 9-189-22 transmission 3-21 type 2-23, 2-28, 3-9, 5-25, 5-57, 6-13, 6-44, 9-4, 9-18 zone 1-22

Index-4

Copying all or part of this manual, or distributing such copies, is strictly prohibited. To report suspected copying, please call 1-800-PIRATES.

Version 3

You might also like