1. Trang chủ
  2. » Công Nghệ Thông Tin

teach yourself freebsd in 24 hours (2003)

456 745 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 456
Dung lượng 9,24 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

He has experience withvarious Unix operating systems including FreeBSD, Linux, and Solaris.. Among the most popular were email and Web services.Hobbyists who wanted to work with UNIX als

Trang 2

800 East 96th St., Indianapolis, Indiana, 46240 USA

Trang 3

Sams Teach Yourself FreeBSD

in 24 Hours

Copyright © 2003 by Sams Publishing

All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photo- copying, recording, or otherwise, without written permission from the pub- lisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation

of this book, the publisher and author assume no responsibility for errors or omissions Nor is any liability assumed for damages resulting from the use of the information contained herein.

International Standard Book Number: 0672324245 Library of Congress Catalog Card Number: 2002102902 Printed in the United States of America

First Printing: December 2002

04 03 02 4 3 2 1

Trademarks

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Sams Publishing cannot attest to the accuracy of this information Use of a term in this book should not be regarded

as affecting the validity of any trademark or service mark.

Warning and Disclaimer

Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied The information provided is on

an “as is” basis The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages aris- ing from the information contained in this book or from the use of the CD or programs accompanying it.

Trang 4

Contents at a Glance

Part I Introduction to FreeBSD 3

Hour 1 Planning for and Preparing to Install FreeBSD 5

Part II Basic FreeBSD Administration 73

6 Adding and Removing Third-Party Software 91

7 System Configuration and Startup Scripts 105

10 The FreeBSD Kernel and the Device Tree 165

13 Connecting FreeBSD to an Existing Network 215

Part IV FreeBSD as a Workstation 255

19 Window Managers and Desktop Environments 309

Trang 5

Part V FreeBSD as a Server 345

Trang 6

What This Book Is 1

What This Book Is Not .2

How to Use This Book .2

Part I Introduction to FreeBSD 3 HOUR 1 Planning for and Preparing to Install FreeBSD 5 What Is FreeBSD? .5

FreeBSD Is a True UNIX Operating System 6

FreeBSD Is Open Source .6

FreeBSD Is Free and Has a Very Liberal License Agreement 6

FreeBSD Is Stable and Powerful .6

What Is FreeBSD Being Used for? .7

Set Up a Powerful Web Server 7

Email Services .7

DNS and Routing Services 7

File and Printer Sharing .7

Database Services 7

Software Development/Learning Programming 8

Learning UNIX 8

Inexpensive UNIX Workstations .8

FreeBSD Compared to Other Operating Systems 8

FreeBSD Compared to Linux 8

Other BSD Operating Systems 10

FreeBSD Compared to Windows 2000 and XP .11

System Requirements .13

Deciding How and Where to Install FreeBSD .13

Backing Up Existing Systems .14

Floppy Disks 15

Zip Disks .15

Recordable and Rewritable CD-ROM .16

DVD-ROM 16

Tape Drives 16

Summary 17

Q&A 17

Workshop 18

Exercises 18

Trang 7

HOUR 2 Installing FreeBSD 19

Beginning the FreeBSD Installation .20

sysinstall 21

Navigating in sysinstall .21

Hard Disk Partitioning 22

FreeBSD’s Hard Disk Naming 22

Boot Manager .23

Creating BSD Partitions .23

Choosing the Distribution to Install .24

Choosing Installation Media .25

Post Installation .26

Shutting Down the System After Reboot .29

Summary 30

Q&A 30

Workshop 30

Quiz 31

Quiz Answers .31

HOUR 3 A Basic Tour of FreeBSD 33 The Basics of the FreeBSD Startup Process .34

The POST .34

The Bootstrap .34

The Boot Manager .34

The Kernel .35

init 37

Logging In to FreeBSD .37

Your Home Directory .39

The Rest of the Directory Structure .39

Working with Files and Directories 41

Creating and Deleting Directories .41

Rules for Directory Names 42

Listing Directory Contents .43

Changing Directories .45

The pwd Command .46

Creating Files .46

Moving Files 46

Copying Files .47

Deleting Files .48

Wildcard Basics .48

Logging Out of the System .49

Importance of Proper System Shutdown .50

Workshop 51

Trang 8

Quiz 51

Quiz Answers .52

HOUR 4 Basic UNIX Shell Use 53 The Role of the Shell 53

Different Shells Available .55

The Bourne Shell .55

The C Shell 55

The Korn Shell .56

The Bash Shell .56

The Tcsh Shell .56

Which Shell Should You Use? .56

Getting Help in the Shell .57

Man Page Format .57

Man Page Categories .58

Specifying Which Category to Use .59

Searching the Man Pages .59

Command Summaries .59

The GNU Info System .60

Searching for info Pages .61

Special Features of Bash .61

Command Line History .61

Command Line Completion .61

File Permissions 62

Displaying Permissions for a File or Directory .62

Process Management .64

Terminating a Process .66

Stopping a Process .67

Restarting a Process .68

Moving a Process into the Background .68

Summary 69

Q&A 69

Workshop 70

Quiz 70

Quiz Answers .71

Exercises 71

Part II Basic FreeBSD Administration 73 HOUR 5 Users and Groups 75 Multiuser Capabilities of FreeBSD .76

Adding Users to FreeBSD .77

Removing a User Account 83

Trang 9

Groups and Their Purpose .84

Creating Groups .84

Changing the Group Ownership 85

Setting the Permissions .86

Primary Versus Secondary Groups .88

Summary 88

Workshop 88

Quiz 88

Quiz Answers .89

HOUR 6 Adding and Removing Third-Party Software 91 FreeBSD’s Software Packaging Systems .92

The Differences Between Packages and Ports .92

Discovering What’s Available .93

Installing Software from Prebuilt Packages .94

Installing the Downloaded Package .96

Obtaining Information on Installed Packages .97

Installing Software from Ports 97

The FreeBSD Ports Tree .98

Making Sure That Your Ports Tree Is Up-to-Date .98

Installing a Port .100

Removing Installed Software .100

Updating Installed Software .101

Notes on Ports and Disk Space .101

Working with Linux Applications .102

Summary 102

Workshop 103

Quiz 103

Quiz Answers .104

HOUR 7 System Configuration and Startup Scripts 105 Understanding the FreeBSD Startup Process .106

Resource Configuration Scripts 109

Modifying System Settings .110

The /etc/defaults/rc.conf File .110

The /etc/rc.conf File .111

The /usr/local/etc and /usr/local/X11R6/etc Directories .113

The inetd Daemon and the inetd.conf Configuration File 114

The System Logger (syslogd) and the syslog.conf File .117

Summary 119

Q&A 119

Trang 10

Workshop 121

Quiz 121

Quiz Answers .122

Exercises 122

HOUR 8 Storage Systems and Backup Utilities 123 Understanding UNIX Filesystems 124

Partitions, Volumes, and Filesystems .126

The FreeBSD Filesystem .127

Mounting and Unmounting Various Media Formats 130

Formatting Disks .132

The mount Command 132

Mounting Non-UFS Filesystems .133

About NFS .134

The umount Command 134

The /etc/fstab File .135

The FreeBSD Automounter .136

System Backup Strategies and Utilities 138

Using tar .138

Using burncd .140

Recovery 141

Creating “Seed” Files .141

Summary 142

Q&A 143

Workshop 144

Quiz 144

Quiz Answers .145

Exercises 145

HOUR 9 The FreeBSD Printing System 147 How FreeBSD Handles Printing .148

Configuring the Printer .149

Configuring the Parallel Port .149

Configuring the Print Spool Directory .150

Configuring a Text Filter .151

Formatting Plain Text for Postscript Printers 152

Configuring a Ghostscript Filter .153

The /etc/printcap File .155

Starting lpd 156

Command Line Printing .156

Checking the Status of Jobs 157

Removing Jobs from the Queue .158

Trang 11

Controlling the Printers .159

Queue Status 160

Disabling the Queue .160

Enabling the Queue and Restarting the Printer .161

Restarting the Daemon .161

Cleaning the Queue .161

Changing the Priority of Print Jobs .161

Abbreviating Commands .162

Summary 162

Q&A 162

Workshop 162

Quiz 163

Answers 164

H OUR 10 The FreeBSD Kernel and Device Tree 165 The Kernel and Its Purpose .166

Why Build a Custom Kernel? .166

The Kernel Configuration File 167

Editing the Configuration File .167

The NOTES File 170

Building the New Kernel .170

Installing the New Kernel .171

Recovering from Botched Kernel Builds .172

”Kernel panic!” Message After Reboot .172

System Hangs After Reboot .172

Kernel Build Fails with “* Error code” Message .173

Certain System Utilities Stop Working .173

Summary 173

Workshop 174

Quiz 174

Quiz Answers .175

H OUR 11 Updating FreeBSD 177 The Two FreeBSD Source Trees .178

What Is a Source Tree? .178

The Difference Between STABLE and CURRENT .178

RELEASE Versions of FreeBSD .179

SNAPSHOT Versions of FreeBSD 180

Updating Your Source Tree .180

What Is cvsup? .181

Using CVSup .181

Editing the CVSup Configuration File 181

Running CVSup .184

Trang 12

Contents xi

The UPDATING File .184

The /etc/make.conf File .185

Updating Important Files 185

Rebuilding the System 187

Removing the Old Object Files .187

Building the World .187

Installing the New World .188

Building the New Kernel .189

Troubleshooting 190

Summary 191

Q&A 191

Workshop 192

Quiz 192

Quiz Answers .192

Exercises 193

Part III Networking 195 H OUR 12 Introduction to Networks 197 The OSI Networking Model .198

Basic Networking Components .201

Cables 201

Straight-through and Crossover Cables .201

Hubs 204

Switches 205

Bridges 206

Routers 206

The IP Address System and Subnets .207

Subnets and the Network Mask 209

Summary 211

Q&A 211

Workshop 212

Quiz 212

Quiz Answers .213

Exercises 213

H OUR 13 Connecting FreeBSD to an Existing Network 215 The Network Interface Device 216

Configuring Network Settings with sysinstall 219

Testing Network Connectivity with ping .221

Summary 222

Q&A 222

Trang 13

Workshop 224

Quiz 224

Quiz Answers .225

Exercises 225

H OUR 14 Dial-Up Network Connections 227 Selecting an Internet Service Provider .228

Modem Information 229

Configuring the Dial-up Internet Connection .230

Setting Up the DNS Servers 230

Configuring the Options File for Kernel PPP .231

Creating the Chat Script .232

pap-secrets and chap-secrets .233

Starting the Internet Connection .234

Dial-on-Demand 234

Persistent Connections .234

Automatically Running Commands on Connect and Disconnect .235

Troubleshooting the Connection .235

The Modem Never Dials .235

The Modem Dials But Never Establishes a Connection .236

The Modem Establishes a Connection, But You Can’t Access Any Web Sites, and So on After the Connection Has Been Made .236

Dial-on-demand Sometimes Dials the Modem Even When You Aren’t Trying to Use the Internet 237

The Internet Connection Never Drops Even Though You Have an Idle Value Set in the options File and You Are Not Using the Internet .237

Summary 237

Q&A 238

Workshop 238

Quiz 238

Quiz Answers .239

Exercises 239

H OUR 15 Network Security 241 Ensuring Password Integrity .242

Weak Passwords .242

Writing Down Passwords .243

What Makes a Good Password? 243

Be Aware of Suspicious Activity .244

Remote Login Issues .244

Telnet 244

rlogin 245

SSH 245

Trang 14

Contents xiii

Configuring a Basic Firewall 246

Creating Firewall Rules .246

Enabling the Firewall .248

Securing the Console .249

Security Holes in FreeBSD .250

Summary 250

Q&A 251

Workshop 251

Quiz 251

Quiz Answers .253

Exercises 253

Part IV FreeBSD as a Workstation 255 H OUR 16 Command-Line Applications 257 Working with Text .258

The ee Editor .258

Configuring ee .260

The vi Editor 262

Email Applications 264

The Lynx Web Browser .266

Summary 267

Q&A 267

Workshop 268

Quiz 268

Quiz Answers .269

Exercises 269

Exercise Answers .269

H OUR 17 Configuring the X Window System 271 More About X .273

Configuring X .274

Required Information .275

Using xf86config .276

Starting X 285

Summary 286

Q&A 286

Workshop 287

Quiz 287

Quiz Answers .288

Exercises 288

Trang 15

HOUR 18 The K Desktop Environment (KDE) 289

What Is a Desktop Environment? .290

Installing KDE .290

Making KDE Your Default Window Manager .290

Starting KDE .291

Navigating the KDE Desktop .292

Virtual Desktops .293

Window Controls .294

The Window Menu .295

Moving and Resizing Windows .296

Restoring Windows .296

The Desktop Menu .297

KDE Applets .298

The Address Book .298

Text Editors .300

File Management in KDE .301

Moving and Copying Files and Folders .302

Deleting Files or Folders .302

Changing File Attributes .302

Searching for Files .303

Customizing Your KDE Desktop 304

Changing the Desktop Background .304

Adding Desktop Icons .305

Customizing the Menu Bar .305

Customizing the Clock .306

Summary 306

Q&A 306

Workshop 307

Quiz 307

Quiz Answers .308

HOUR 19 Window Managers and Desktop Environments 309 The Difference Between Window Managers and Desktop Environments .310

Alternative (Non-KDE) Windowing Environments .311

WindowMaker 312

Blackbox 313

XFCE 313

IceWM 313

FVWM 95 314

Installing and Configuring Alternative Window Managers 314

Changing Your Default Window Manager .315

Summary 315

Q&A 315

Trang 16

Workshop 316

Quiz 316

Quiz Answers .317

Exercises 317

HOUR 20 Productivity in the X Window System 319 Office Software .319

Starting KOffice .320

KWord 321

KSpread 322

KPresenter 323

KIllustrator 324

StarOffice 324

Image Editing 325

Installing and Starting GIMP .326

Internet Applications .328

Konqueror Web Browser .328

KMail 329

Summary 331

Q&A 332

Workshop 333

Quiz 333

Quiz Answers .334

Exercises 334

HOUR 21 Multimedia in FreeBSD 335 Configuring Sound Support in FreeBSD 335

Sound Applications .336

mpg123 336

XMMS 336

CD Player .337

Mixers 337

CD Burning .338

Viewing MPEG Video Files .340

DivX Video Files .340

Playing DVDs .341

Summary 341

Q&A 342

Workshop 343

Quiz 343

Quiz Answers .344

Exercises 344

Trang 17

Part V FreeBSD as a Server 345

What Is Apache? .347

Requirements for Running Your Own Web Server .348

Installing Apache .350

Basic Apache Configuration: What You Need to Edit 350

Starting and Stopping the Apache Server .351

CGI 353

Configuring Apache for CGI .353

Troubleshooting CGI .355

Apache Modules .356

Basic Security and Access Control .357

Controlling Access by Hostnames or IP Address .357

Restricting Access by Username and Password 358

Summary 360

Q&A 360

Workshop 361

Quiz 362

Quiz Answers .362

Exercises 363

HOUR 23 Basic Email Services 365 SMTP and Sendmail .366

Basic Sendmail Configuration 368

Sendmail File Layout .369

Using the Sendmail Configuration Files .369

Controlling Sendmail .372

The Message Queue .373

Mail Relaying and Spam Control .375

Summary 377

Q&A 378

Workshop 378

Quiz 379

Quiz Answers .380

Exercises 380

HOUR 24 File Sharing 381 File Sharing Through FTP 382

Authenticated and Anonymous FTP .383

Enabling Anonymous FTP Access .384

Disabling Anonymous FTP Access .384

Trang 18

Controlling FTP Access .385

The /etc/ftpusers File .385

The /etc/shells File .386

The /var/run/nologin File .386

Basic NFS Configuration 386

Configuring an NFS Server .388

(d)Configuring an NFS Client .390

Samba and Windows File Sharing 393

Installing and Configuring Samba .394

The smbd and nmbd Daemons 395

Creating Samba Shares 396

Access Control .398

Accessing Shared Files on a Windows System (The smbfs Filesystem) 399

Summary 400

Q&A 400

Workshop 401

Quiz 401

Quiz Answers .402

Exercises 402

Part VI Appendixes 405 A Resources for FreeBSD Users 407 Web Sites .407

FreeBSD Specific Sites .407

Other Web Sites .408

Mailing Lists .409

General Lists 409

USENET Newsgroups .411

IRC Channels 413

Trang 19

About the Authors

M ICHAEL U RBANis a biology student at the University of Minnesota where he plans tomajor in Ecology, Evolution, and Behavior He is involved in research projects withAfrican lions and is also the Webmaster for the Lion Research Center He has worked innumerous IT jobs including Web design and technical analysis He has experience withvarious Unix operating systems including FreeBSD, Linux, and Solaris

B RIAN T IEMANNhas been a constant user of FreeBSD since his student days at Caltech,where he used it to build a movie fan Web site that has continued to grow and sustainmore and more load until the present day Born in Ukiah, California, He has remained inthe state all his life; he currently lives in San Jose, works in the networking appliancefield, and writes ceaseless commentary about Apple, Microsoft, and the technology field.Occasionally, but not often enough, he has time to enjoy motorcycling, travel, animation,and other such interests

Trang 20

About the Development Editor

D EE -A NN L E B LANCis an award-winning computer book author, and has been in the fieldsince 1994 She’s published 11 computer books and 60 articles, taught and developedcourses, and more—mostly involving the Linux operating system and its related pro-

grams Her latest book is Linux for Dummies, Fourth Edition from Wiley Publishing, Inc.

She also has a growing wealth of experience on the editorial front, turning part of hertime to technical and development editing This combination of working both sides of thedesk allows her to both write better books and become a better editor

You can follow Dee-Ann’s work and share your input through her mailing list athttp://www.dee-annleblanc.com/mailman/listinfo/generalor find out more in gen-eral at http://www.Dee-AnnLeBlanc.com/

Trang 22

This book would not have been possible without the efforts of several people I wouldlike to thank Kathryn Purdum at Sams Publishing for her work and also for accommodat-ing my unexpected trip to Egypt, Andrew Beaster for his work on the development, DanScherf for his work on the CD, and all of the other staff at Sams Publishing who worked

on this book In addition, I would like to thank Brian Tiemann for taking up the slack onsome of the chapters and on author review during my unexpected two weeks in Egypt

Of course, I also need to thank all the volunteers who have spent numerous unpaid hoursmaking FreeBSD into an operating system that is better than many commercial operatingsystems Without them, this book would not exist

—Michael Urban

Trang 23

We Want to Hear from You!

As the reader of this book, you are our most important critic and commentator We value

your opinion and want to know what we’re doing right, what we could do better, whatareas you’d like to see us publish in, and any other words of wisdom you’re willing topass our way

You can email or write me directly to let me know what you did or didn’t like about thisbook—as well as what we can do to make our books stronger

Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message.

When you write, please be sure to include this book’s title and author as well as yourname and phone or email address I will carefully review your comments and share themwith the author and editors who worked on the book

Email: opensource@samspublishing.com

Mail: Mark Taber

Associate PublisherSams Publishing

800 East 96th StreetIndianapolis, IN 46240 USA

Reader Services

For more information about this book or others from Sams Publishing, visit our Web site

atwww.samspublishing.com Type the ISBN (excluding hyphens) or the title of the book

in the Search box to find the book you’re looking for

Trang 24

Until recently, home computer users and small business users had little choice when itcame to what operating system they used to on their computers You pretty much had twochoices: You could either use Microsoft Windows or Apple’s Mac OS Of course, youwere limited even further by what hardware you had If you had an Apple Macintosh,you had to use Mac OS If you had an x86 based system, you had to use Windows.UNIX systems were well out of the price range of most small businesses or home hobby-ists On top of that, they required proprietary hardware from the UNIX vendor Thislocked you into a single vendor and a single choice of hardware So for the most part,home users and small businesses stuck with Windows If they needed to do networking,they usually went with Windows NT, or Novell Netware

In the mid to late 1990s, however, this Microsoft monopoly on x86 operating systemsbegan breaking A couple of UNIX-like operating systems being developed by hobbyistsworking together over the Internet began to get some notice The two most popular oneswere Linux and FreeBSD Over time, these operating systems evolved, and grew stableenough to be used in production environments on servers and workstations

The operating systems were being freely distributed on the Internet In addition, they ran

on cheap x86 hardware that had the additional advantage of not locking you into a singlevendor Businesses, both small and large, began to take notice and started using thesesystems for various tasks Among the most popular were email and Web services.Hobbyists who wanted to work with UNIX also adopted the new operating systems foruse on their home computers, and they wrote software for the new operating systems Among the software that was written was graphical user interfaces—some of which were

so advanced that they rivaled Windows for features and ease of use With the advent ofthese graphical interfaces, the new operating systems started to become usable for theaverage user instead of just the guru This book is geared toward that average user

What This Book Is

This book is designed to teach the average computer user how to work effectively withthe FreeBSD operating system in 24 lessons—each approximately one hour in length Bythe time you have finished this book, you will have a good basic understanding of how toperform most common tasks in FreeBSD, including such things as setting up a basic Web

or email server, basic FreeBSD administration, basic security, installing software, andbasic navigating and file management in FreeBSD You will also have a good under-standing of how to work with the graphical user environment in FreeBSD

Trang 25

What This Book Is Not

This book is not an introduction to computers Although it does not assume that you haveany previous UNIX experience, it does assume that you have a fairly good workingknowledge of Windows It does not assume that you are an expert Windows user, but itdoes assume that you have a working knowledge of basic concepts such as files and fold-ers and navigation in the Windows environment using the mouse

This book is also not designed to teach advanced concepts or cover all the included ics in depth As such, if you already have some UNIX experience with another UNIX

top-system such as Linux, you will probably do better looking at FreeBSD Unleashed, also

from Sams Publishing, because this book will likely be too basic for you, and will leaveyou unfulfilled

How to Use This Book

This book is designed as a tutorial on various topics of FreeBSD You might not be ested in all the topics covered You don’t necessarily have to go through the hours in theorder they are given in the book However, certain topics will require knowledge of othertopics that were covered previously For example, before you can set up a working Webserver, you must have a working network, and you also have to know how to install soft-ware so that you can get the Web server software installed At points in the hours whereknowledge is required from a previous hour, cross-references to the relevant hours will

inter-be made

The concept of learning an entirely new operating system might seem intimidating to you

at first, but the process can actually be fun, and you will probably find the rewards ofFreeBSD to be well worth the effort put into learning it Hopefully, this book will make

it a little easier to learn about this powerful operating system Now, let’s get started inHour 1 by learning about some of the basics of what FreeBSD is and why you mightwant to use it

Trang 26

1 Planning for and Preparing to Install FreeBSD

2 Installing FreeBSD

3 A Basic Tour of FreeBSD

4 Basic Shell Use

Introduction to FreeBSD

Trang 29

FreeBSD Is a True UNIX Operating System

This means FreeBSD is in the same family of operating systems as Solaris, AIX,

HP-UX, and Digital UNIX The original UNIX operating system can trace its roots back tothe 1960s The designers of UNIX created a design so flexible and powerful that even 30years later, UNIX (and thus FreeBSD as well) remains one of the most versatile, well-respected operating systems available

FreeBSD Is Open Source

This means that all the source code for the entire operating system is available to you Ifyou are not a programmer, this might not mean much to you However, even end usersbenefit from open source because thousands of programmers use FreeBSD The fact thatthe source is available to them means that bugs and possible security problems are likely

to be found and fixed quicker than in operating systems developed by commercial panies in which users do not get access to the source code

com-FreeBSD Is Free and Has a Very Liberal License Agreement

You can download FreeBSD free from the Internet You can burn your own FreeBSDCDs or purchase copies of FreeBSD from various sources for just a few dollars UnlikeWindows, and some commercial versions of UNIX, there are no per-user or per-serverlicense fees for FreeBSD You can install FreeBSD on as many systems as you want andallow as many users to access it as you want without paying a penny If you run a busi-ness, this has the potential to save you thousands of dollars in software licensing fees

FreeBSD Is Stable and Powerful

The old adage “You get what you pay for” doesn’t apply to FreeBSD A lot of peopleassume that because FreeBSD is free and is developed primarily by volunteer “hobby-ists,” it must be little more than a toy that cannot be taken seriously or relied upon fordoing serious work Nothing could be further from the truth Many large corporations arerelying on FreeBSD for many tasks Some of the companies and organizations currentlyusing FreeBSD include Sony, Yahoo!, Microsoft, the Apache project, and Hollywoodspecial effects studios Many people regard FreeBSD as one of the most stable operatingsystems available System crashes common in Windows become a thing of the past withFreeBSD

Trang 30

What Is FreeBSD Being Used for?

Because the source code for FreeBSD is freely available and FreeBSD comes with alarge number of programming tools, what you can do with FreeBSD is really only lim-ited by your imagination and skill as a programmer However, without having any pro-gramming skill, here are some of things that you can do with FreeBSD

Set Up a Powerful Web Server

The CD that comes with this book includes the Apache Web server, which is the mostpopular Web server software on the Internet FreeBSD and Apache is widely regarded asone of the best software combinations for building a powerful and stable Web server

Yahoo!, the Apache Project itself, and Sony Japan rely on FreeBSD to power their Websites If you do not want set up a public Web server, FreeBSD also makes a great plat-form for running a corporate intranet

Email Services

If you need an email server for your organization, FreeBSD can do the job quite well

The resource requirements of FreeBSD are very low, so it can often turn an old and dated system into a perfectly serviceable email server That old 486 you use as adoorstop might just have a use

out-DNS and Routing Services

You can make a perfectly serviceable router or DNS server using FreeBSD—even onewith sophisticated functions such as firewalling and Network Address Translation (NAT)

Once again, this can be a more attractive option than purchasing a dedicated router if youhave an older system sitting around that is not being used for anything FreeBSD also hasthe capability to allow you to share a single Internet connection with several systems,even if you only have one connection and one IP address

File and Printer Sharing

With the freely available SAMBA software, you can create a file or print server that iscompatible with Microsoft Windows workstations You can even create a FreeBSD serverthat emulates a Windows NT domain controller

Trang 31

Software Development/Learning Programming

If you want to learn programming, FreeBSD is a great platform to do it on For onething, FreeBSD comes with compilers for several programming languages Many morecan be downloaded free On some other operating systems, these compilers would costthousands of dollars

Learning UNIX

If you need to learn UNIX for a class or for your job, FreeBSD can help you do it And itcan help you do it at home on your own time FreeBSD is a real UNIX operating systemthat allows you to get hands-on experience

Inexpensive UNIX Workstations

Thousands of applications are available for FreeBSD—most of them at no cost Theseapplications range from Web browsers to office packages to email clients to scientificapplications In addition, you can work with remote X applications running on anyremote UNIX server

FreeBSD Compared to Other Operating Systems

You might be wondering how FreeBSD compares to other operating systems In this tion, we will look at how FreeBSD compares to several other operating systems, includ-ing other flavors of UNIX and Windows

sec-FreeBSD Compared to Linux

Most people today have at least heard of Linux, even if they do not have a very goodidea of what it is Linux is a clone, or “work alike,” of the UNIX operating system Itwas originally started as a hobby project by Linus Torvalds, but has since grown to bedeveloped by thousands of volunteers all over the world Linux is a project that wasstarted from scratch As such, it is not, and never has been, based on any actual UNIXcode When people talk about “UNIX-like operating systems,” they’re usually referring

to Linux

From an end-user point of view, and even for most administration tasks, FreeBSD andLinux are quite similar The main differences between the two are in the design philoso-phy Here are some of the major variances:

Trang 32

• There is only one distribution of FreeBSD There are more than 30 distributions ofLinux: Each of the Linux distributions has slightly different ways of doing things.

This can cause problems if you need to migrate to a different distribution of Linuxlater on

• FreeBSD is a complete operating system Linux is a kernel with a set of utilitiesincluded with it: Different Linux vendors have differing opinions on what should

be included with a Linux distribution Of course, if something you want isn’tincluded, you can always download it off the Internet

• FreeBSD is maintained by a core team As such, what ends up in a FreeBSDrelease is better controlled than what ends up in most Linux releases: This can help

to reduce the compatibility problems that sometimes show up with Linux

• FreeBSD can often be easier to upgrade than Linux: When you upgrade FreeBSD,you generally upgrade the entire operating system With Linux, you might down-load a kernel upgrade, only to find out that it breaks other parts of the system thatyou then need to upgrade separately (This has its downsides too, though; manyLinux distributions are packaged nicely so that upgrading them is easier and lessprone to breakage than FreeBSD.)

• FreeBSD is considered by many to be more stable than Linux As such, it might bemore suitable for production servers However, the trade-off is that FreeBSD isoften slower to support the latest cutting edge technology and hardware devicesthan Linux

• FreeBSD has less software available for it than Linux—especially when it comes

to commercial software However, this is often not an issue because FreeBSD canrun most Linux software extremely well

Another difference between FreeBSD and Linux is in licensing Linux is licensed under

the GPL, which stands for the GNU General Public License This license was developed

by the Free Software Foundation One of the goals of the GPL is to foster innovation byensuring that developers can build on existing code from other developers (Whether itsucceeds in this goal or actually inhibits innovation is a subject of religious debate.) TheGPL does this by requiring that source code be made available for the product and thatthe author not restrict distribution of the product Any GPL code used in a software prod-uct requires that the entire product automatically inherit the GPL license: thus, the authormust make source code available and cannot restrict others from redistributing the soft-ware or making further changes to it

1

Trang 33

FreeBSD, on the other hand, is licensed under the BSD software license developed bythe University of California at Berkeley This license is much more liberal than the GPL.Basically, the BSD license allows you to do whatever you want with the software,including re-using it in a commercial software product and not releasing the source code.Because of this, the BSD license is often favored by commercial software developers.Apple has used a great deal of FreeBSD code in Darwin, the foundation for Mac OS X;even Microsoft has used BSD licensed software, and occasionally contributed software toBSD This means that you re-use BSD licensed code in your own software and thenlicense the software under a completely different license The only requirement is thatthe BSD code maintain the BSD copyright information and an acknowledgment of theoriginal authors.

Ultimately, the major differences between FreeBSD and Linux come down to cal differences about software licenses and such Both operating systems are quite capa-ble, and both can serve the needs of most users quite well

philosophi-Other BSD Operating Systems

Although FreeBSD is by far the most popular of the BSD based operating systems for

PC hardware, there are several others

The most popular BSD-based operating system, and indeed the most popular UNIX-likeoperating system in the world, is Apple’s Mac OS X It’s possible to start a religious warover whether OS X is actually UNIX or not, but for our purposes (and under the terms ofits license), it is OS X has a fully functional BSD UNIX environment that is based onFreeBSD It will compile and run most BSD software without modification, and itincludes the majority of the BSD system utilities Of course, at this point in time, OS X

is only available for Macintosh hardware, although there is a long-standing rumor thatApple might port OS X to PC hardware—that is, recompile it so that it will run on theIntel/AMD architecture that most likely underlies your own computer

Another version of BSD that is available for PC hardware is NetBSD The main ence between FreeBSD and NetBSD is that FreeBSD focuses mostly on PC hardware,and thus is optimized to perform extremely well on it NetBSD, on the other hand, runs

differ-on just about every platform under the sun, including things that aren’t even computers

If you’re interested in reading an analysis of the GPL as well as how it affects and is affected by the realities of commercial software development, see “A Funny Thing Happened on the Way to the Market” by Matt Asay, at

http://www.linuxdevices.com/articles/AT4528760742.html

Trang 34

in the traditional sense of the word—such as certain gaming consoles FreeBSD has alarger user community than NetBSD; hence, it tends to be better documented and have alarger amount of ported software available.

OpenBSD is also available for PC hardware, as well as many other platforms, althoughnot as many platforms as NetBSD OpenBSD’s main focus is on security, and somewould argue (perhaps rightfully) that OpenBSD is the most secure general purpose oper-ating system available Like NetBSD, OpenBSD tends to be more difficult for beginners

to work with than FreeBSD because it is not as well documented and doesn’t have asmuch software pre-ported to it Also, be aware that as of this writing, OpenBSD does notsupport SMP processing This means that if you have a system with more than one CPU,you won’t be able to take advantage of the second CPU with OpenBSD (FreeBSD how-ever, does support multiple processors.)

FreeBSD Compared to Windows 2000 and XP

In the 80s and early 90s, Microsoft primarily focused on the desktop market Serverswere pretty much the domain of UNIX vendors such as SUN, IBM and HP, and non-UNIX vendors such as Novell However, with the introduction of Windows NT,Microsoft began to target the server market Microsoft continued to push into the servermarket with new products such as Windows 2000, Windows XP, and technologies such

as NET and ASP scripting In addition, various anti-UNIX campaigns on the part ofMicrosoft have made it clear that its intended target is UNIX Among other things,Microsoft claims that UNIX is outdated, arcane, and not cost-effective Is there any validbasis to these claims? Is UNIX really a technology in which its time has come and gone?

After all, UNIX is more than 30 years old, which is a long time when you consider thatthe computer has only been a major business tool since the mid 1960s Before UNIX iswritten off as an obsolete technology though, let’s consider some of its benefits, as well

as look at some of Microsoft’s points

Microsoft’s claim that UNIX is not cost-effective might be true if we are talking aboutcommercial UNIX vendors Traditionally, commercial UNIX has been proprietary soft-ware that required expensive hardware to run However, as PC hardware became morepowerful, it began to be possible to run very serviceable servers on commodity PC sys-tems, which traditionally has been the market that Microsoft has focused on A PC-basedserver could be had for much less money than a proprietary UNIX server

However, FreeBSD is focused on PC hardware So this eliminates the expensive ware argument for making UNIX not cost-effective In addition, FreeBSD doesn’t haveany licensing fees This eliminates a substantial cost that is associated with Windows

hard-You can install FreeBSD on as many servers as you would like without paying a dime

1

Trang 35

The number of simultaneous users who can be connected to the server is limited only bythe capacity of your hardware Once again, you don’t have to pay a dime With

Windows, on the other hand, you have to pay a licensing fee for each server you want torun Windows on, as well as a fee for each user who needs to be connected to any givenserver Basically, with the free UNIX systems such as FreeBSD, Microsoft’s argumentthat UNIX is not cost-effective doesn’t really work In fact, FreeBSD could potentiallysave tens of thousands of dollars because of Microsoft’s expensive licensing fees.What about the idea that UNIX is an outdated technology? This idea doesn’t really stand

up either For one, when UNIX was first invented, it was way ahead of its time But also,UNIX’s design philosophy allowed it to grow and meet future needs relatively easilybecause most of the functionality is handled by external programs that ship with theoperating system As far as the underlying technology of the operating system itself,UNIX had features in the 1970s that Microsoft didn’t get around to adding to Windowsuntil the mid 1990s

Other than the fact that FreeBSD can potentially save thousands of dollars in licensingfees, it also has the potential to save a great deal of money in hardware costs becauseFreeBSD’s resource requirements are relatively light compared to Windows Depending

on what you are doing with FreeBSD, even a 486 with 32MB of RAM might be cient On the other hand, Microsoft states that the minimum requirements for Windows

suffi-2000 server are a Pentium 133 and 64MB of RAM Realistically, for reasonably goodperformance, requirements for Windows 2000 are much higher than this

As far as FreeBSD (and UNIX in general) being more difficult to learn than Windows isconcerned, this is probably true A lot of procedures performed from a graphical userinterface in Windows need to be performed from the command line on FreeBSD—often

by editing a text-based configuration file However, the command-line interface doeshave several advantages over Windows graphical user interface

• Once you’ve learned the command line, it can often be much faster than navigatingthrough Windows graphical tools

• Not having a graphical interface running means that the resource requirements ofthe operating system are much lower It makes little sense to have a resource hun-gry graphical interface running on a headless server in a backroom somewhere that

no one ever sees anyway

• Not having the graphical interface also means that hardware requirements arelower For example, you can get by with an old and small monitor instead of hav-ing to have an expensive high resolution monitor

Trang 36

• You can administer FreeBSD from the command line remotely through any systemthat has a terminal emulator, even if it is not a UNIX system With Windows, youneed special software to do remote administration, and that software generally onlyruns on Windows.

The argument can also be made that FreeBSD is much more stable and secure thanWindows A properly designed graphical user interface can make system administrationmuch more straightforward than in a command-line–based system; but because of thearcane nature of the Windows’ system layout, its interface is hardly any more intuitivethan that of FreeBSD The really nasty part, too, is that the Windows’ graphical interface

leads people to believe that it’s easier—with the result that a great many Windows

servers in the world are configured improperly and insecurely, as well as administered bypeople who think it’s still better than if they’d used Linux or FreeBSD

System Requirements

The system requirements for FreeBSD depend on what you intend to do with the system

For a typical workstation setup that will run the X Window System (a graphical interfacesystem similar to Windows or Macintosh, also referred to as X or X11), the followingminimum system requirements are recommended:

• Pentium class processor

• 64MB of RAM

• At least 300MB of free hard disk space

• SVGA or better video card compatible with the X Window System (see Appendix

A, “Resources for FreeBSD Users”)

• Three-button mouse

It is possible to use the X Window System with a two-button mouse However, unlikeMicrosoft Windows, X relies a great deal on the third mouse button It is much easier towork in X with a three-button mouse

If you have no intention of running a graphical environment, you can often get by with alot less In fact, if all you want is to set up an email server, router, or low end Web server,you can get by with even a 486

Deciding How and Where to Install FreeBSD

There are two primary ways you can install FreeBSD on your system Most people new

to the operating system will probably want to opt for the dual boot method With a dual

1

Trang 37

boot system, you install FreeBSD alongside your existing Windows system A program

called a boot manager will be installed at the beginning of your hard disk Each time you

start your computer, you will be presented with a menu that allows you to choosewhether you want to work in Windows or in FreeBSD When you want to use Windows,you can simply select it from this menu, and the system will behave as if FreeBSD isn’teven installed In other words, your Windows system will work exactly the way it didbefore you installed FreeBSD

The second way that FreeBSD can be installed is as the only operating system on thecomputer If you only intend to work with FreeBSD on this system, you might want toopt for this method If you choose to use this method on a system that already hasWindows on it, you will delete your current system and start over with a new FreeBSDsystem Because of this, it is important to back up any data you have on your system andwant to keep More about doing backups will be discussed later in this hour

Backing Up Existing Systems

Before you can install FreeBSD, you will have to create a space for it on your hard disk,which will involve making some changes to the way your hard disk is currently set up.Although the program we will use to do this in the next hour can usually do this withoutcausing you to lose data, it is still possible that a mistake could be made Because of this,

it is very important that you back up any important data that you want to keep

Note that in general, you only need to back up your data You don’t need to back up grams or the Windows system itself because you will generally need to reinstall theseanyway Also, backing up all your programs and data would require a great deal of timeand a huge amount of space on your backup media

pro-Do be sure to back up any registration keys for shareware and commercial software that you might have installed If you reinstall these programs and then discover that you don’t have those keys handy, you’ll be reduced to limited functionality (or none at all).

There are several ways that you can back up data in Windows, and we aren’t going to gointo detail here Of course, the simplest way is to just copy your data files onto yourbackup media (more on backup media later) You can save space by using a programsuch as WinZip to compress the files before copying them Of course, several dedicatedbackup programs are also available for Windows

Trang 38

As far as the media you use to back up your system is concerned, several choices areavailable—all of which have their advantages and disadvantages We will next look at afew of the most popular methods.

Floppy Disks

If you only have a small amount of data to back up, floppy disks might work The mainadvantage of floppy disks is that they are a very cheap way to back up small amounts ofdata, and virtually every computer already has a floppy drive, so you already have thehardware available to do the backup

However, the disadvantages of using floppy disks for backups generally outweigh theadvantages For one thing, floppy disks are notoriously unreliable and prone to errors Inother words, you could back up your data only to find that when you try to restore it, thefloppy disk was bad and the data is corrupt Another problem with floppies is that theyhave a relatively low capacity So if you have more than a small amount of data to back

up, you could end up dealing with a lot of floppy disks Not only is it very slow andtime-consuming to back up and restore from a pile of floppies, but it also increases thechance that one of the disks will have errors Floppy disks are generally the worst choiceavailable for doing backups and should only be used if the amount of data to back up issmall, and no other backup system is available If you must use floppies, be sure to ver-ify the contents of each disk after copying files to it

Zip Disks

Iomega’s Zip disks are a type of high-capacity floppy disks, having a capacity of either100MB or 250MB The main advantage of Zip disks is that they can be accessed likenormal disks In other words, you can load a document from it, make changes to it, andsave it directly back on the Zip disk Because of this, Zip disks are quite popular atUniversity computer labs, for example Because they can hold a relatively large amount

of data, students can take the disks with them into and out of the computer lab, and theycan be used like a normal disk Zip disks are effective for backing up small amounts ofdata and are more reliable than floppy disks

Zip disks have two primary drawbacks The first is that the cost per megabyte is tively high For example, a 250MB Zip disk costs about 7.5 cents per megabyte as of thiswriting Compare this to a rewritable CD, which costs about 0.35 cents per megabyte,and you can see that Zip disks are more than 20 times more expensive per megabyte thanrewritable CDs (Rewritable CDs do have some disadvantages that Zip disks don’t have

rela-We will look at those in the next section.)

1

Trang 39

The second primary drawback of Zip disks is that they are relatively slow Although thisisn’t a huge issue for backing up and restoring data, it is an issue when attempting to use

a Zip disk as a normal disk and accessing large documents from it

Recordable and Rewritable CD-ROM

Recordable and rewritable CDs are perhaps the most popular backup media for smallbusinesses and organizations that do not have to back up extremely large amounts ofdata The cost of CD writers has come down greatly in recent years, making them afford-able to the average computer user Recordable CDs are very cheap and can hold a rela-tively large amount of data (up to 700MB) For the average home or small business user,recordable CDs are probably the best backup option available

Note that you can get recordable CDs (CD-Rs), which can only be written to one time,and rewritable CDs (CD-RWs), which can be erased and rewritten hundreds of times Forbackup purposes, it is better to go with the recordable CDs because they are more reli-able than the rewritable CDs

The primary drawback of recordable and rewritable CDs is that they cannot be written tolike a regular disk This means that you can’t, for example, open a document from arewritable CD, make changes, and then directly save it back on to the CD like you canwith a Zip disk Writing to a CD usually involves setting up a “burn” process with anumber of files to write and then executing the “burn,” which takes a fairly long time.What this means, really, is that CDs are not useful as an “on-demand” storage medium

DVD-ROM

Recordable DVD-ROM drives are likely to replace recordable CD-ROM drives in the atively near future Like CD writers, the cost of DVD writers has come down greatly inrecent years Although they still cost significantly more than a CD writer, they are rea-sonably affordable (and a very good investment because they can write CDs and playDVDs as well) The DVD-R or DVD-RW media costs several times more than CD-R orCD-RW media, which means that they are far less “disposable” than CDs DVDs canstore up to 4.7GB of data per disk, making them effective for backing up even large

rel-amounts of data However, for backing up extremely large rel-amounts of data, DVD drives

aren’t quite a match for high-capacity tape drives

Tape Drives

The oldest form of backup, it is still the most popular for backing up large amounts ofdata Of course, the media has gone from huge reel-to-reel drives that held less than100Mb of data, to Digital Audio Tape (DAT) cartridges smaller than a credit card that

Trang 40

can hold more than 20GB of data If you need to back up huge amounts of data, tape ves are still the best way to go However, the cheaper tape drives can be unreliable, andthe reliable ones are quite expensive (and often require a SCSI controller, which mostcomputers don’t have built-in anymore) The media isn’t cheap either Tape drives arebest left for those people who have to back up huge amounts of data.

dri-Summary

In this hour, we looked at what FreeBSD is and how it can be used You saw thatFreeBSD is a version of the UNIX operating system that is available free and can beinstalled on as many computers as you want without paying any licensing fees Welooked at some of the things that can be done with FreeBSD, including building a Webserver, email server, file server, or an inexpensive UNIX workstation We also comparedFreeBSD to other operating systems including Linux, other versions of BSD, andMicrosoft Windows Finally, we introduced the two ways that FreeBSD can be installedand looked at the importance of backing up your system We also examined several types

of media that can be used for backing up your system before installing FreeBSD

Q&A

Q Is FreeBSD a “true UNIX,” or is it just “UNIX-like” as some people say?

A FreeBSD is a licensed implementation of the BSD code developed at UC Berkeley.

Because that code is by definition “true UNIX,” so is FreeBSD So, in fact, is anyoperating system that uses such licensed Berkeley code

Q Is there a way to run Windows programs within FreeBSD?

A There are ongoing projects whose goal is to allow users to run Windows programs

in an “emulation mode” within FreeBSD, Linux, or other such operating system

These projects include WINE (an older emulator) and the Lindows project, whosemain goal is to integrate Linux and Windows These aren’t mature or stable solu-tions, though, and your best bet is to bank on having to boot into Windows if youcan’t give up gaming

Q What’s the best media to use to back up my Windows system before ing my disk for dual-booting with FreeBSD?

partition-A If you have a CD-R or CD-RW drive, this might be your best bet You don’t need

to duplicate your entire hard drive and restore it later; in fact, it’s often better to

“nuke and pave” Windows and reinstall your software from time to time anyway

Just worry about backing up your personal documents, registration keys, and allfiles that aren’t part of the operating system or any particular program

1

Ngày đăng: 26/10/2014, 21:29