Tải bản đầy đủ

OReilly learning UNIX for mac OS x panther dec 2003 ISBN 0596006179










TableofContents
Index
Reviews
ReaderReviews
Errata
Academic

LearningUnixforMacOSXPanther
ByBrianJepson,DaveTaylor

Publisher :O'Reilly
PubDate :December2003

ISBN :0-596-00617-9
Pages :184

Thiscompactbookprovidesauser-friendly
tourfortheuninitiatedoftheMacUnixbase.
YoucansafelyexploreTerminaland
familiarizeyourselfwiththecommandline,
learningasyougoaboutthehundredsof
UnixprogramsthatcomewithyourMac.
You'llbegintounderstandthepowerand


flexibilityofUnix.AndifUnixisn'tnewto
you,you'lldiscoverhowittranslatesintothis
latestMacincarnation.UpdatedtocoverMac
OSXPanther(MacOSX10.3),thisbookwill
keepyoucurrentwiththelatestfeaturesof
yourMac.











TableofContents
Index
Reviews
ReaderReviews
Errata
Academic

LearningUnixforMacOSXPanther
ByBrianJepson,DaveTaylor

Publisher :O'Reilly


PubDate :December2003
ISBN :0-596-00617-9
Pages :184


Copyright

Preface
Audience

WhoThisBookIsNotFor




ABriefHistory




InterfacestoUnix




UsingCodeExamples




TheEvolutionofThisBook

VersionsofUnix
ConventionsUsedinThisBook
CommentsandQuestions
AcknowledgmentsforDaveTaylor




AcknowledgmentsforBrianJepson


Chapter1.GettingIntoUnix
Section1.1.WhyUseUnix?

Section1.2.LaunchingTerminal




Section1.3.CustomizingYourShellEnvironment
Section1.4.FurtherCustomization


Chapter2.UsingtheTerminal
Section2.1.WorkingwiththeTerminal

Section2.2.SyntaxofaUnixCommandLine




Section2.3.TypesofCommands
Section2.4.TheUnresponsiveTerminal


Chapter3.UsingUnix
Section3.1.TheMacOSXFilesystem

Section3.2.ProtectingandSharingFiles




Section3.3.SuperuserPrivilegeswithsudo
Section3.4.ExploringExternalVolumes


Chapter4.FileManagement
Section4.1.FileandDirectoryNames

Section4.2.FileandDirectoryWildcards




Section4.3.CreatingandEditingFiles



Section4.5.ManagingFiles

Section4.4.ASimplerviAlternative:Pico


Chapter5.Printing
Section5.1.FormattingandPrintCommands

Section5.2.Non-PostScriptPrinters


Chapter6.RedirectingI/O
Section6.1.StandardInputandStandardOutput

Section6.2.PipesandFilters


Chapter7.Multitasking
Section7.1.RunningaCommandintheBackground

Section7.2.CheckingonaProcess



Section7.3.CancelingaProcess


Chapter8.AccessingtheInternet
Section8.1.RemoteLogins

Section8.2.TransferringFiles


Chapter9.OfWindowsandDownloads
Section9.1.X11

Section9.2.Fink





Section9.3.SomePicks


Chapter10.WheretoGofromHere
Section10.1.Documentation

Section10.2.ShellAliasesandFunctions






Section10.3.Programming
Section10.4.MorePossibilities:PerlandPython
Colophon
Index


[TeamLiB]
[SYMBOL][A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S]
[T][U][V][W][X][Y][Z]

[TeamLiB]


Preface
MacOSX(pronounced"MacOSTen"),thelatestincarnationof
theMacintoshoperatingsystem,isaradicaldeparturefrom
previousversions.Notonlyisthereawholenewlookandfeel
onthesurface,therearealsohugedifferencesunderthehood.
Alltheold,familiarMacintoshsystemsoftwarehasbeen
replacedwithanotheroperatingsystem,calledUnix.Unixisa
multiuser,multitaskingoperatingsystem.Beingmultiuser
meansMacOSXallowsmultipleuserstosharethesame
system,eachhavingtheabilitytocustomizetheirdesktop,
createfilesthatcanbekeptprivatefromotherusers,andmake
settingsthatwillautomaticallyberestoredwheneverthat
personusesthecomputer.BeingmultitaskingmeansMacOSX
caneasilyrunmanydifferentapplicationsatthesametime,
andthatifoneapplicationcrashesorhangs,theentiresystem
doesn'tneedtoberebooted.
ThefactthatMacOSXisUnixunderthehooddoesn'tmatterto
userswhosimplywanttouseitsslickgraphicalinterfacetorun
theirapplicationsormanagetheirfiles.Butitopensupworlds
ofpossibilitiesforuserswhowanttodigalittledeeper.The
Unixcommand-lineinterface,whichisaccessiblethroughaMac
applicationintheUtilitiesfoldercalledTerminal,providesan
enormousamountofpowerforintermediateandadvanced
users.What'smore,onceyou'velearnedtouseUnixinMacOS
X,you'llalsobeabletousethecommandlineinotherversions
ofUnixortheUnix-compatibleLinux.
ThisbookisdesignedtoteachthebasicsofUnixtoMacintosh
users.Wetellyouhowtousethecommandline(whichUnix
usersrefertoas"theshell")andthefilesystem,aswellas
someofthemostusefulcommands.Unixisacomplexand
powerfulsystem,sowescratchonlythesurface,butwealso
tellyouhowtodeepenyourUnixknowledgeonceyou'reready


formore.


Copyright
Copyright©2004,2003,2002O'Reilly&Associates,Inc.
PrintedintheUnitedStatesofAmerica.
PublishedbyO'Reilly&Associates,Inc.,1005Gravenstein
HighwayNorth,Sebastopol,CA95472.
O'Reilly&Associatesbooksmaybepurchasedforeducational,
business,orsalespromotionaluse.Onlineeditionsarealso
availableformosttitles(http://safari.oreilly.com).Formore
information,contactourcorporate/institutionalsales
department:(800)998-9938orcorporate@oreilly.com.
NutshellHandbook,theNutshellHandbooklogo,andthe
O'ReillylogoareregisteredtrademarksofO'Reilly&Associates,
Inc.LearningUnixforMacOSXPanther,theimageofan
Alaskanmalamute,andrelatedtradedressaretrademarksof
O'Reilly&Associates,Inc.
Apple,theApplelogo,AppleScript,AppleTalk,AppleWorks,
Cocoa,Finder,Mac,Macintosh,MPW,QuickDraw,QuickTime,
andSherlockaretrademarksofAppleComputer,Inc.,
registeredintheUnitedStatesandothercountries.Aqua,
Carbon,andQuartzaretrademarksofAppleComputer,Inc.
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Where
thosedesignationsappearinthisbook,andO'Reilly&
Associates,Inc.wasawareofatrademarkclaim,the
designationshavebeenprintedincapsorinitialcaps.
Whileeveryprecautionhasbeentakeninthepreparationofthis
book,thepublisherandauthorsassumenoresponsibilityfor
errorsoromissions,orfordamagesresultingfromtheuseof


theinformationcontainedherein.


Audience
Thisbookteachesbasicsystemutilitycommandstogetyou
startedwithUnix.Insteadofoverwhelmingyouwithlotsof
details,wewantyoutobecomfortableintheUnixenvironment
assoonaspossible.Sowecovereachcommand'smostuseful
featuresinsteadofdescribingallitsoptionsindetail.
Wealsoassumethatyourcomputerworksproperly;youhave
startedit,knowtheprocedureforturningthepoweroff,and
knowhowtoperformsystemmaintenance.


WhoThisBookIsNotFor
Ifyou'reseekingabookthattalksabouthowtodevelopCocoa
programsorotherwisebuildMacsoftwareapplications,thisisn't
yourbook(thoughit'squitehelpfulfordeveloperstohavea
goodgraspofMacOSXUnixessentials).Ifyou'reacomplete
beginnerandareoccasionallystymiedbywherethesecond
mousebuttonwent,thismightbeabetterbooktoputonthe
shelfuntilyou'remorecomfortablewithyourcomputing
environment.Finally,ifyouliveandbreatheUnixeverydayand
canmakeyourLinuxboxdobackflips,thisbookwillbetoo
basicforyou(though,sincewecovermanyoftheMacOSX
Unixnuances,you'llstillgleaninformationfromreadingit).We
don'tcovereitherUnixsystemadministrationorMacsystem
administrationfromthecommandline.


ABriefHistory
TheMacintoshstartedoutwithasingle-taskingoperating
systemthatallowedsimpleswitchingbetweenapplications
throughanapplicationcalledtheFinder.Morerecentversionsof
MacOShavesupportedmultipleapplicationsrunning
simultaneously,butitwasn'tuntilthelandmarkreleaseofMac
OSXthattruemultitaskingarrivedintheMacintoshworld.With
MacOSX,Macintoshapplicationsruninseparatememory
areas;theMacisatruemultiusersystemthatalsofinally
includesproperfile-levelsecurity.
Toaccomplishtheseimprovements,MacOSXmadethejump
fromaproprietaryunderlyingoperatingenvironmenttoUnix.
MacOSXisbuiltontopofDarwin,aversionofUnixbasedon
BSD4.4Lite,FreeBSD,NetBSD,andtheMachmicrokernel.
Unixitselfwasinventedmorethan30yearsagoforscientific
andprofessionaluserswhowantedaverypowerfulandflexible
OS.Ithasevolvedsincethenthrougharemarkablycircuitous
path,withstopsatBellTelephoneLabs,UCBerkeley,research
centersinAustraliaandEurope,andtheU.S.Departmentof
DefenseAdvancedResearchProjectsAgency(forfunding).
BecauseUnixwasdesignedforexperts,itcanbeabit
overwhelmingatfirst.Butafteryougetthebasics(fromthis
book!),you'llstarttoappreciatesomeofthereasonstouse
Unix:
Itcomeswithahugenumberofpowerfulapplication
programs.YoucangetmanyothersforfreeontheInternet.
(TheFinkproject,availablefromSourceForge
(http://fink.sourceforge.net/),bringsmanyopensource
packagestoMacOSX.)Youcanthusdomuchmoreata
muchlowercost.Anotherplacetoexploreisthecool
DarwinPortsproject,whereadedicatedteamofsoftware


developersarecreatingDarwinversionsofmanypopular
Unixapps
(http://www.opendarwin.org/projects/darwinports).
Notonlyaretheapplicationsoftenfree,butsoaresome
Unix(andUnix-compatible)operatingsystems.Linuxand
FreeBSDaregoodexamples.Likethefreeapplications,
mostfreeUnixversionsareofexcellentquality.They're
maintainedbyvolunteerprogrammersandcorporations
whowantapowerfulOSandarefrustratedbytheslow,
bug-riddenOSdevelopmentatsomebigsoftware
companies.MacOSX'sDarwincoreisafreeUnixOS(getit
athttp://developer.apple.com/darwin/),butitdoesnot
haveMacOSX'seasy-to-useinterface.Manypeopleuse
MacOSXdailywithouteverknowingaboutallthepower
lurkingunderthehood.
Unixrunsonalmostanykindofcomputer,fromtiny
embeddedsystemstogiantsupercomputers.Afteryouread
thisbook,you'llnotonlyknowallaboutDarwin,butyou'll
alsobereadytousemanyotherkindsofUnix-based
computerswithoutlearninganewOSforeachone.
Ingeneral,Unix(especiallywithoutawindowingsystem)is
lessresourceintensivethanothermajoroperatingsystems.
Forinstance,Linuxwillrunhappilyonanoldsystemwith
anIntel80386microprocessorandletmultipleusersshare
thesamecomputer.(Don'tbothertryingtousethelatest
versionsofMicrosoftWindowsonasystemthat'smorethan
afewyearsold!)Ifyouneedawindowingsystem,Unixlets
youchoosefrommodernfeature-richinterfacesaswellas
fromsimpleonesthatneedmuchlesssystempower.
Anyonewithlimitedresourceseducationalinstitutions,
organizationsindevelopingcountries,andsooncanuse
Unixtodomorewithless.


MuchoftheInternet'sdevelopmentwasdoneonUnix
systems.ManyInternetwebsitesandserviceprovidersuse
Unixbecauseit'ssoflexibleandinexpensive.Withpowerful
hardware,Unixreallyshines.


VersionsofUnix
ThereareseveralversionsofUnix.Somepastandpresent
commercialversionsincludeSolaris,AIX,andHP/UX.Freely
availableversionsincludeLinux,NetBSD,OpenBSD,and
FreeBSD.Darwin,thefreeUnixunderneathMacOSX,wasbuilt
bygraftinganadvancedversioncalledMachontoBSD,witha
lightsprinklingofApplemagicforthewindowingsystem.
Althoughgraphicaluserinterfaces(GUIs)andadvanced
featuresdifferamongUnixsystems,youshouldbeabletouse
muchofwhatyoulearnfromthisintroductoryhandbookonany
system.Don'tworrytoomuchaboutwhat'sfromwhatversion
ofUnix.JustasEnglishborrowswordsfromFrench,German,
Japanese,Italian,andevenHebrew,MacOSXUnixborrows
commandsfrommanydifferentversionsofUnix,andyoucan
usethemallwithoutpayingattentiontotheirorigins.
Fromtimetotime,wedoexplainfeaturesofUnixonother
systems.Knowingthedifferencescanhelpyouifyoueverwant
touseanothertypeofUnixsystem.Whenwewrite"Unix"in
thisbook,wemean"Unixanditsversions,"unlesswe
specificallymentionaparticularversion.


InterfacestoUnix
Unixcanbeusedasitwasoriginallydesigned:ontypewriterliketerminals,fromapromptonacommandline.Mostversions
ofUnixalsoworkwithwindowsystems(orGUIs).Theseallow
eachusertohaveasinglescreenwithmultiple
windowsincluding"terminal"windowsthatactliketheoriginal
Unixinterface.
MacOSXincludesasimpleterminalapplicationforaccessing
thecommand-linelevelofthesystem.Thatapplication,
reasonablyenough,iscalledTerminalandcanbefoundinthe
Applications Utilitiesfolder.TheTerminalapplicationwillbe
examinedmorecloselyinChapter1andChapter2.
AlthoughyoucancertainlyuseyourMacquiteefficiently
withouttypingtextatashellprompt,we'llspendallourtimein
thisbookonthattraditionalcommand-lineinterfacetoUnix.
Why?
EveryUnixsystemhasacommand-lineinterface.Ifyou
knowhowtousethecommandline,you'llalwaysbeableto
usethesystem.
IfyoubecomeamoreadvancedUnixuser,you'llfindthat
thecommandlineisactuallymuchmoreflexiblethana
windowinginterface.Unixprogramsaredesignedtobe
usedtogetherfromthecommandlineas"buildingblocks"in
analmostinfinitenumberofcombinations,todoaninfinite
numberoftasks.Nowindowingsystemwe'veseen(yet!)
hasthistremendouspower.
YoucanlaunchandcloseGUIprogramsfromthecommand
line.


Onceyoulearntousethecommandline,youcanusethose
sametechniquestowritescripts.Theselittle(orbig!)
programsautomatejobsyou'dhavetodomanuallyand
repetitivelywithawindowsystem(unlessyouunderstand
howtoprogramawindowsystem,whichisusuallyamuch
harderjob).SeeSection10.3inChapter10forabrief
introductiontoscripting.
Ingeneral,text-basedinterfacesaremucheasierthanGUIs
forsight-impairedusers.
Wearen'tsayingthatthecommand-lineinterfaceisrightfor
everysituation.Forinstance,usingtheWebwithitsgraphics
andlinksisusuallyeasierwithaGUIwebbrowserwithinMac
OSX.Butthecommandlineisthefundamentalwaytouse
Unix.UnderstandingitwillletyouworkonanyUnixsystem,
withorwithoutwindows.AgreatresourceforgeneralMacOSX
information(theGUIyou'reprobablyusedto)canbefoundin
MacOSX:TheMissingManualbyDavidPogue(Pogue
Press/O'Reilly).


ConventionsUsedinThisBook
Thefollowingtypographicalconventionsareusedinthisbook:

Plaintext
Indicatesmenutitles,menuoptions,menubuttons,and
keyboardaccelerators(suchasAltandCtrl).

Italic
Indicatesnewterms,exampleURLs,emailaddresses,
filenames,fileextensions,pathnames,directories,andUnix
utilities.

Constantwidth
Indicatescommands,options,switches,variables,
attributes,keys,functions,types,classes,namespaces,
methods,modules,properties,parameters,values,objects,
events,eventhandlers,XMLtags,HTMLtags,macros,the
contentsoffiles,ortheoutputfromcommands.

Constantwidthbold
Showscommandsorothertextthatshouldbetyped
literallybytheuser.


Constantwidthitalic
Showstextthatshouldbereplacedwithuser-supplied
values.

Thisiconsignifiesatip,suggestion,orgeneralnote.

Thisiconindicatesawarningorcaution.


UsingCodeExamples
Thisbookisheretohelpyougetyourjobdone.Ingeneral,you
mayusethecodeinthisbookinyourprogramsand
documentation.Youdonotneedtocontactusforpermission
unlessyou'rereproducingasignificantportionofthecode.For
example,writingaprogramthatusesseveralchunksofcode
fromthisbookdoesnotrequirepermission.Sellingor
distributingaCD-ROMofexamplesfromO'Reillybooksdoes
requirepermission.Answeringaquestionbycitingthisbook
andquotingexamplecodedoesnotrequirepermission.
Incorporatingasignificantamountofexamplecodefromthis
bookintoyourproduct'sdocumentationdoesrequire
permission.
Weappreciate,butdonotrequire,attribution.Anattribution
usuallyincludesthetitle,author,publisher,andISBN.For
example:"LearningUnixforMacOSXPanther,ThirdEdition,
byDaveTaylorandBrianJepson.Copyright2004O'Reilly&
Associates,Inc.,0-596-00617-9."
Ifyoufeelyouruseofcodeexamplesfallsoutsidefairuseor
thepermissiongivenabove,feelfreetocontactusat
permissions@oreilly.com.


CommentsandQuestions
Pleaseaddresscommentsandquestionsconcerningthisbookto
thepublisher:
O'Reilly&Associates,Inc.
1005GravensteinHighwayNorth
Sebastopol,CA95472
(800)998-9938(intheUnitedStatesorCanada)
(707)829-0515(internationalorlocal)
(707)829-0104(fax)
Wehaveawebpageforthisbook,wherewelisterrata,
examples,andanyadditionalinformation.Youcanaccessthis
pageat:
http://www.oreilly.com/catalog/lunixpanther
Tocommentorasktechnicalquestionsaboutthisbook,send
emailto:
bookquestions@oreilly.com
Formoreinformationaboutourbooks,conferences,Resource
Centers,andtheO'ReillyNetwork,seeourwebsiteat:
http://www.oreilly.com


TheEvolutionofThisBook
ThisbookisbasedonthepopularO'ReillytitleLearningthe
UnixOperatingSystem,byJerryPeek,GraceTodino,andJohn
Strang(currentlyinitsfifthedition).Therearemany
differencesinthisbooktomeettheneedsofMacOSXusers,
butthefundamentallayoutandexplanationsarethesame.


AcknowledgmentsforDaveTaylor
I'dliketoacknowledgethegreatworkofNatTorkington,our
editoratO'Reilly,andthevaluableinformationandreviewof
themanuscriptbyAppleComputer,Inc.Iwouldalsoliketo
expressmygratitudetoChuckToporekforhisvaluable
commentsonthedraftmanuscript.ThanksalsotoChristian
Crumlishforhisback-roomassistance,andtoTimO'Reillyfor
theopportunitytohelprevisethepopularLearningtheUnix
OperatingSystembookfortheexcitingnewMacOSXworld.
Oh,andabigthumbsuptoLinda,Ashley,Gareth,and"Peanut"
forlettingmetype,type,andtypesomemore,ultimately
gettingthisbookoutthedoorinaremarkablyspeedymanner.


AcknowledgmentsforBrianJepson
I'dliketothankNathanTorkington,myeditor,forhelpingme
shape,launch,andcompletethisproject.ThanksalsotoChuck
Toporek,whogaveuslotsofguidanceonwheretotakethis
nextedition.SpecialthankstoJoan,Seiji,andYeuhifortheir
patienceasIslippedawayintovariouscornersofthehouseto
workonthisbook.


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×