tar.texi 334 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @c ======================================================================
  11. @c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
  12. @c as decided by @set symbols. The PUBLISH rendition does not show
  13. @c notes or marks asking for revision. Most users will prefer having more
  14. @c information, even if this information is not fully revised for adequacy,
  15. @c so DISTRIB is the default for tar distributions. The PROOF rendition
  16. @c show all marks to the point of ugliness, but is nevertheless useful to
  17. @c those working on the manual itself.
  18. @c ======================================================================
  19. @ifclear PUBLISH
  20. @ifclear DISTRIB
  21. @ifclear PROOF
  22. @set DISTRIB
  23. @end ifclear
  24. @end ifclear
  25. @end ifclear
  26. @ifset PUBLISH
  27. @set RENDITION The book, version
  28. @end ifset
  29. @ifset DISTRIB
  30. @set RENDITION FTP release, version
  31. @end ifset
  32. @ifset PROOF
  33. @set RENDITION Proof reading version
  34. @end ifset
  35. @c ---------------------------------------------------------------------
  36. @c The @FIXME's, @UNREVISED and @c comments are part Fran@,{c}ois's work
  37. @c plan. These annotations are somewhat precious to him; he asks that I
  38. @c do not alter them inconsiderately. Much work is needed for GNU tar
  39. @c internals (the sources, the programs themselves). Revising the
  40. @c adequacy of the manual while revising the sources, and cleaning them
  41. @c both at the same time, seems to him like a good way to proceed.
  42. @c ---------------------------------------------------------------------
  43. @c Output marks for nodes needing revision, but not in PUBLISH rendition.
  44. @macro UNREVISED
  45. @ifclear PUBLISH
  46. @quotation
  47. @emph{(This message will disappear, once this node revised.)}
  48. @end quotation
  49. @end ifclear
  50. @end macro
  51. @c Output various FIXME information only in PROOF rendition.
  52. @macro FIXME{string}
  53. @allow-recursion
  54. @quote-arg
  55. @ifset PROOF
  56. @strong{<FIXME>} \string\ @strong{</>}
  57. @end ifset
  58. @end macro
  59. @macro FIXME-ref{string}
  60. @quote-arg
  61. @ifset PROOF
  62. @strong{<REF>} \string\ @strong{</>}
  63. @end ifset
  64. @end macro
  65. @macro FIXME-pxref{string}
  66. @quote-arg
  67. @ifset PROOF
  68. @strong{<PXREF>} \string\ @strong{</>}
  69. @end ifset
  70. @end macro
  71. @macro FIXME-xref{string}
  72. @quote-arg
  73. @ifset PROOF
  74. @strong{<XREF>} \string\ @strong{</>}
  75. @end ifset
  76. @end macro
  77. @c @macro option{entry}
  78. @c @quote-arg
  79. @c @opindex{--\entry\}
  80. @c @value{\entry\}
  81. @c @end macro
  82. @macro GNUTAR
  83. @acronym{GNU} @command{tar}
  84. @end macro
  85. @set op-absolute-names @kbd{--absolute-names} (@kbd{-P})
  86. @set ref-absolute-names @ref{absolute}
  87. @set xref-absolute-names @xref{absolute}
  88. @set pxref-absolute-names @pxref{absolute}
  89. @set op-after-date @kbd{--after-date=@var{date}} (@kbd{--newer=@var{date}}, @kbd{-N @var{date}})
  90. @set ref-after-date @ref{after}
  91. @set xref-after-date @xref{after}
  92. @set pxref-after-date @pxref{after}
  93. @set op-append @kbd{--append} (@kbd{-r})
  94. @set ref-append @ref{add}
  95. @set xref-append @xref{add}
  96. @set pxref-append @pxref{add}
  97. @set op-atime-preserve @kbd{--atime-preserve}
  98. @set ref-atime-preserve @ref{Attributes}
  99. @set xref-atime-preserve @xref{Attributes}
  100. @set pxref-atime-preserve @pxref{Attributes}
  101. @set op-backup @kbd{--backup}
  102. @set ref-backup @ref{Backup options}
  103. @set xref-backup @xref{Backup options}
  104. @set pxref-backup @pxref{Backup options}
  105. @set op-block-number @kbd{--block-number} (@kbd{-R})
  106. @set ref-block-number @ref{verbose}
  107. @set xref-block-number @xref{verbose}
  108. @set pxref-block-number @pxref{verbose}
  109. @set op-blocking-factor @kbd{--blocking-factor=@var{512-size}} (@kbd{-b @var{512-size}})
  110. @set ref-blocking-factor @ref{Blocking Factor}
  111. @set xref-blocking-factor @xref{Blocking Factor}
  112. @set pxref-blocking-factor @pxref{Blocking Factor}
  113. @set op-bzip2 @kbd{--bzip2} (@kbd{-j})
  114. @set ref-bzip2 @ref{gzip}
  115. @set xref-bzip2 @xref{gzip}
  116. @set pxref-bzip2 @pxref{gzip}
  117. @set op-check-links @kbd{--check-links} (@kbd{-l})
  118. @set ref-check-links @ref{--check-links}
  119. @set xref-check-links @xref{--check-links}
  120. @set pxref-check-links @pxref{--check-links}
  121. @set op-checkpoint @kbd{--checkpoint}
  122. @set ref-checkpoint @ref{verbose}
  123. @set xref-checkpoint @xref{verbose}
  124. @set pxref-checkpoint @pxref{verbose}
  125. @set op-check-links @kbd{--check-links}
  126. @set op-compare @kbd{--compare} (@kbd{--diff}, @kbd{-d})
  127. @set ref-compare @ref{compare}
  128. @set xref-compare @xref{compare}
  129. @set pxref-compare @pxref{compare}
  130. @set op-compress @kbd{--compress} (@kbd{--uncompress}, @kbd{-Z})
  131. @set ref-compress @ref{gzip}
  132. @set xref-compress @xref{gzip}
  133. @set pxref-compress @pxref{gzip}
  134. @set op-concatenate @kbd{--concatenate} (@kbd{--catenate}, @kbd{-A})
  135. @set ref-concatenate @ref{concatenate}
  136. @set xref-concatenate @xref{concatenate}
  137. @set pxref-concatenate @pxref{concatenate}
  138. @set op-create @kbd{--create} (@kbd{-c})
  139. @set ref-create @ref{create}
  140. @set xref-create @xref{create}
  141. @set pxref-create @pxref{create}
  142. @set op-delete @kbd{--delete}
  143. @set ref-delete @ref{delete}
  144. @set xref-delete @xref{delete}
  145. @set pxref-delete @pxref{delete}
  146. @set op-dereference @kbd{--dereference} (@kbd{-h})
  147. @set ref-dereference @ref{dereference}
  148. @set xref-dereference @xref{dereference}
  149. @set pxref-dereference @pxref{dereference}
  150. @set op-directory @kbd{--directory=@var{directory}} (@kbd{-C @var{directory}})
  151. @set ref-directory @ref{directory}
  152. @set xref-directory @xref{directory}
  153. @set pxref-directory @pxref{directory}
  154. @set op-exclude @kbd{--exclude=@var{pattern}}
  155. @set ref-exclude @ref{exclude}
  156. @set xref-exclude @xref{exclude}
  157. @set pxref-exclude @pxref{exclude}
  158. @set op-exclude-from @kbd{--exclude-from=@var{file-of-patterns}} (@kbd{-X @var{file-of-patterns}})
  159. @set ref-exclude-from @ref{exclude}
  160. @set xref-exclude-from @xref{exclude}
  161. @set pxref-exclude-from @pxref{exclude}
  162. @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
  163. @set ref-extract @ref{extract}
  164. @set xref-extract @xref{extract}
  165. @set pxref-extract @pxref{extract}
  166. @set op-file @kbd{--file=@var{archive-name}} (@kbd{-f @var{archive-name}})
  167. @set ref-file @ref{file}
  168. @set xref-file @xref{file}
  169. @set pxref-file @pxref{file}
  170. @set op-files-from @kbd{--files-from=@var{file-of-names}} (@kbd{-T @var{file-of-names}})
  171. @set ref-files-from @ref{files}
  172. @set xref-files-from @xref{files}
  173. @set pxref-files-from @pxref{files}
  174. @set op-force-local @kbd{--force-local}
  175. @set ref-force-local @ref{file}
  176. @set xref-force-local @xref{file}
  177. @set pxref-force-local @pxref{file}
  178. @set op-group @kbd{--group=@var{group}}
  179. @set ref-group @ref{Option Summary}
  180. @set xref-group @xref{Option Summary}
  181. @set pxref-group @pxref{Option Summary}
  182. @set op-gzip @kbd{--gzip} (@kbd{--gunzip}, @kbd{--ungzip}, @kbd{-z})
  183. @set ref-gzip @ref{gzip}
  184. @set xref-gzip @xref{gzip}
  185. @set pxref-gzip @pxref{gzip}
  186. @set op-help @kbd{--help}
  187. @set ref-help @ref{help}
  188. @set xref-help @xref{help}
  189. @set pxref-help @pxref{help}
  190. @set op-ignore-failed-read @kbd{--ignore-failed-read}
  191. @set ref-ignore-failed-read @ref{create options}
  192. @set xref-ignore-failed-read @xref{create options}
  193. @set pxref-ignore-failed-read @pxref{create options}
  194. @set op-ignore-zeros @kbd{--ignore-zeros} (@kbd{-i})
  195. @set ref-ignore-zeros @ref{Reading}
  196. @set xref-ignore-zeros @xref{Reading}
  197. @set pxref-ignore-zeros @pxref{Reading}
  198. @set op-incremental @kbd{--incremental} (@kbd{-G})
  199. @set ref-incremental @ref{Inc Dumps}
  200. @set xref-incremental @xref{Inc Dumps}
  201. @set pxref-incremental @pxref{Inc Dumps}
  202. @set op-info-script @kbd{--info-script=@var{script-name}} (@kbd{--new-volume-script=@var{script-name}}, @kbd{-F @var{script-name}})
  203. @set ref-info-script @ref{Multi-Volume Archives}
  204. @set xref-info-script @xref{Multi-Volume Archives}
  205. @set pxref-info-script @pxref{Multi-Volume Archives}
  206. @set op-interactive @kbd{--interactive} (@kbd{-w})
  207. @set ref-interactive @ref{interactive}
  208. @set xref-interactive @xref{interactive}
  209. @set pxref-interactive @pxref{interactive}
  210. @set op-keep-old-files @kbd{--keep-old-files} (@kbd{-k})
  211. @set ref-keep-old-files @ref{Writing}
  212. @set xref-keep-old-files @xref{Writing}
  213. @set pxref-keep-old-files @pxref{Writing}
  214. @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
  215. @set ref-label @ref{label}
  216. @set xref-label @xref{label}
  217. @set pxref-label @pxref{label}
  218. @set op-list @kbd{--list} (@kbd{-t})
  219. @set ref-list @ref{list}
  220. @set xref-list @xref{list}
  221. @set pxref-list @pxref{list}
  222. @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
  223. @set ref-listed-incremental @ref{Inc Dumps}
  224. @set xref-listed-incremental @xref{Inc Dumps}
  225. @set pxref-listed-incremental @pxref{Inc Dumps}
  226. @set op-mode @kbd{--mode=@var{permissions}}
  227. @set ref-mode @ref{Option Summary}
  228. @set xref-mode @xref{Option Summary}
  229. @set pxref-mode @pxref{Option Summary}
  230. @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
  231. @set ref-multi-volume @ref{Multi-Volume Archives}
  232. @set xref-multi-volume @xref{Multi-Volume Archives}
  233. @set pxref-multi-volume @pxref{Multi-Volume Archives}
  234. @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
  235. @set ref-newer-mtime @ref{after}
  236. @set xref-newer-mtime @xref{after}
  237. @set pxref-newer-mtime @pxref{after}
  238. @set op-no-recursion @kbd{--no-recursion}
  239. @set ref-no-recursion @ref{recurse}
  240. @set xref-no-recursion @xref{recurse}
  241. @set pxref-no-recursion @pxref{recurse}
  242. @set op-no-same-owner @kbd{--no-same-owner} (@kbd{-o})
  243. @set ref-no-same-owner @ref{Attributes}
  244. @set xref-no-same-owner @xref{Attributes}
  245. @set pxref-no-same-owner @pxref{Attributes}
  246. @set op-no-same-permissions @kbd{--no-same-permissions}
  247. @set ref-no-same-permissions @ref{Attributes}
  248. @set xref-no-same-permissions @xref{Attributes}
  249. @set pxref-no-same-permissions @pxref{Attributes}
  250. @set op-null @kbd{--null}
  251. @set ref-null @ref{files}
  252. @set xref-null @xref{files}
  253. @set pxref-null @pxref{files}
  254. @set op-numeric-owner @kbd{--numeric-owner}
  255. @set ref-numeric-owner @ref{Attributes}
  256. @set xref-numeric-owner @xref{Attributes}
  257. @set pxref-numeric-owner @pxref{Attributes}
  258. @set op-occurrence @kbd{--occurrence}
  259. @set ref-occurrence @ref{--occurrence}
  260. @set xref-occurrence @xref{--occurrence}
  261. @set pxref-occurrence @pxref{--occurrence}
  262. @set op-old-archive @kbd{--old-archive} (@kbd{-o})
  263. @set ref-old-archive @ref{old}
  264. @set xref-old-archive @xref{old}
  265. @set pxref-old-archive @pxref{old}
  266. @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
  267. @set ref-one-file-system @ref{one}
  268. @set xref-one-file-system @xref{one}
  269. @set pxref-one-file-system @pxref{one}
  270. @set op-overwrite @kbd{--overwrite}
  271. @set ref-overwrite @ref{Overwrite Old Files}
  272. @set xref-overwrite @xref{Overwrite Old Files}
  273. @set pxref-overwrite @pxref{Overwrite Old Files}
  274. @set op-owner @kbd{--owner=@var{user}}
  275. @set ref-owner @ref{Option Summary}
  276. @set xref-owner @xref{Option Summary}
  277. @set pxref-owner @pxref{Option Summary}
  278. @set op-format @kbd{--format}
  279. @set ref-format @ref{format}
  280. @set xref-format @xref{format}
  281. @set pxref-format @pxref{format}
  282. @set op-format-v7 @kbd{--format=v7}
  283. @set op-format-gnu @kbd{--format=gnu}
  284. @set op-format-oldgnu @kbd{--format=oldgnu}
  285. @set op-format-posix @kbd{--format=posix}
  286. @set op-format-ustar @kbd{--format=ustar}
  287. @set op-posix @kbd{--posix}
  288. @set ref-posix @ref{posix}
  289. @set xref-posix @xref{posix}
  290. @set pxref-posix @pxref{posix}
  291. @set op-preserve @kbd{--preserve}
  292. @set ref-preserve @ref{Attributes}
  293. @set xref-preserve @xref{Attributes}
  294. @set pxref-preserve @pxref{Attributes}
  295. @set op-record-size @kbd{--record-size=@var{size}}
  296. @set ref-record-size @ref{Blocking}
  297. @set xref-record-size @xref{Blocking}
  298. @set pxref-record-size @pxref{Blocking}
  299. @set op-recursive-unlink @kbd{--recursive-unlink}
  300. @set ref-recursive-unlink @ref{Writing}
  301. @set xref-recursive-unlink @xref{Writing}
  302. @set pxref-recursive-unlink @pxref{Writing}
  303. @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
  304. @set ref-read-full-records @ref{Blocking}
  305. @set xref-read-full-records @xref{Blocking}
  306. @set pxref-read-full-records @pxref{Blocking}
  307. @c FIXME: or should it be Reading, or Blocking Factor
  308. @set op-remove-files @kbd{--remove-files}
  309. @set ref-remove-files @ref{Writing}
  310. @set xref-remove-files @xref{Writing}
  311. @set pxref-remove-files @pxref{Writing}
  312. @set op-rsh-command @kbd{rsh-command=@var{command}}
  313. @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
  314. @set ref-same-order @ref{Scarce}
  315. @set xref-same-order @xref{Scarce}
  316. @set pxref-same-order @pxref{Scarce}
  317. @c FIXME: or should it be Reading, or Attributes?
  318. @set op-same-owner @kbd{--same-owner}
  319. @set ref-same-owner @ref{Attributes}
  320. @set xref-same-owner @xref{Attributes}
  321. @set pxref-same-owner @pxref{Attributes}
  322. @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
  323. @set ref-same-permissions @ref{Attributes}
  324. @set xref-same-permissions @xref{Attributes}
  325. @set pxref-same-permissions @pxref{Attributes}
  326. @c FIXME: or should it be Writing?
  327. @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
  328. @set ref-show-omitted-dirs @ref{verbose}
  329. @set xref-show-omitted-dirs @xref{verbose}
  330. @set pxref-show-omitted-dirs @pxref{verbose}
  331. @set op-sparse @kbd{--sparse} (@kbd{-S})
  332. @set ref-sparse @ref{sparse}
  333. @set xref-sparse @xref{sparse}
  334. @set pxref-sparse @pxref{sparse}
  335. @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
  336. @set ref-starting-file @ref{Scarce}
  337. @set xref-starting-file @xref{Scarce}
  338. @set pxref-starting-file @pxref{Scarce}
  339. @set op-strip-path @kbd{--strip-path}
  340. @set ref-strip-path @ref{--strip-path}
  341. @set xref-strip-path @xref{--strip-path}
  342. @set pxref-strip-path @pxref{--strip-path}
  343. @set op-suffix @kbd{--suffix=@var{suffix}}
  344. @set ref-suffix @ref{Backup options}
  345. @set xref-suffix @xref{Backup options}
  346. @set pxref-suffix @pxref{Backup options}
  347. @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
  348. @set ref-tape-length @ref{Using Multiple Tapes}
  349. @set xref-tape-length @xref{Using Multiple Tapes}
  350. @set pxref-tape-length @pxref{Using Multiple Tapes}
  351. @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
  352. @set ref-to-stdout @ref{Writing}
  353. @set xref-to-stdout @xref{Writing}
  354. @set pxref-to-stdout @pxref{Writing}
  355. @set op-totals @kbd{--totals}
  356. @set ref-totals @ref{verbose}
  357. @set xref-totals @xref{verbose}
  358. @set pxref-totals @pxref{verbose}
  359. @set op-touch @kbd{--touch} (@kbd{-m})
  360. @set ref-touch @ref{Writing}
  361. @set xref-touch @xref{Writing}
  362. @set pxref-touch @pxref{Writing}
  363. @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
  364. @set ref-unlink-first @ref{Writing}
  365. @set xref-unlink-first @xref{Writing}
  366. @set pxref-unlink-first @pxref{Writing}
  367. @set op-update @kbd{--update} (@kbd{-u})
  368. @set ref-update @ref{update}
  369. @set xref-update @xref{update}
  370. @set pxref-update @pxref{update}
  371. @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
  372. @set ref-use-compress-prog @ref{gzip}
  373. @set xref-use-compress-prog @xref{gzip}
  374. @set pxref-use-compress-prog @pxref{gzip}
  375. @set op-verbose @kbd{--verbose} (@kbd{-v})
  376. @set ref-verbose @ref{verbose}
  377. @set xref-verbose @xref{verbose}
  378. @set pxref-verbose @pxref{verbose}
  379. @set op-verify @kbd{--verify} (@kbd{-W})
  380. @set ref-verify @ref{verify}
  381. @set xref-verify @xref{verify}
  382. @set pxref-verify @pxref{verify}
  383. @set op-version @kbd{--version}
  384. @set ref-version @ref{help}
  385. @set xref-version @xref{help}
  386. @set pxref-version @pxref{help}
  387. @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
  388. @set ref-volno-file @ref{Using Multiple Tapes}
  389. @set xref-volno-file @xref{Using Multiple Tapes}
  390. @set pxref-volno-file @pxref{Using Multiple Tapes}
  391. @c Put everything in one index (arbitrarily chosen to be the concept index).
  392. @syncodeindex fn cp
  393. @syncodeindex ky cp
  394. @syncodeindex pg cp
  395. @syncodeindex vr cp
  396. @defindex op
  397. @syncodeindex op cp
  398. @copying
  399. This manual is for @acronym{GNU} @command{tar} (version
  400. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  401. from archives.
  402. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  403. 2003 Free Software Foundation, Inc.
  404. @quotation
  405. Permission is granted to copy, distribute and/or modify this document
  406. under the terms of the GNU Free Documentation License, Version 1.1 or
  407. any later version published by the Free Software Foundation; with the
  408. Invariant Sections being "GNU General Public License", with the
  409. Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
  410. as in (a) below. A copy of the license is included in the section
  411. entitled "GNU Free Documentation License".
  412. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  413. this GNU Manual. Buying copies from GNU Press supports the FSF in
  414. developing GNU and promoting software freedom.''
  415. @end quotation
  416. @end copying
  417. @dircategory Archiving
  418. @direntry
  419. * Tar: (tar). Making tape (or disk) archives.
  420. @end direntry
  421. @dircategory Individual utilities
  422. @direntry
  423. * tar: (tar)tar invocation. Invoking @GNUTAR{}
  424. @end direntry
  425. @shorttitlepage @acronym{GNU} @command{tar}
  426. @titlepage
  427. @title @acronym{GNU} tar: an archiver tool
  428. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  429. @author Melissa Weisshaus, Jay Fenlason,
  430. @author Thomas Bushnell, n/BSG, Amy Gorin
  431. @c he said to remove it: Fran@,{c}ois Pinard
  432. @c i'm thinking about how the author page *should* look. -mew 2may96
  433. @page
  434. @vskip 0pt plus 1filll
  435. @insertcopying
  436. @end titlepage
  437. @ifnottex
  438. @node Top
  439. @top @acronym{GNU} tar: an archiver tool
  440. @insertcopying
  441. @cindex file archival
  442. @cindex archiving files
  443. The first part of this master menu lists the major nodes in this Info
  444. document. The rest of the menu lists all the lower level nodes.
  445. @end ifnottex
  446. @c The master menu, created with texinfo-master-menu, goes here.
  447. @c (However, getdate.texi's menu is interpolated by hand.)
  448. @menu
  449. * Introduction::
  450. * Tutorial::
  451. * tar invocation::
  452. * operations::
  453. * Backups::
  454. * Choosing::
  455. * Date input formats::
  456. * Formats::
  457. * Media::
  458. * Free Software Needs Free Documentation::
  459. * Copying This Manual::
  460. * Index::
  461. @detailmenu
  462. --- The Detailed Node Listing ---
  463. Introduction
  464. * Book Contents:: What this Book Contains
  465. * Definitions:: Some Definitions
  466. * What tar Does:: What @command{tar} Does
  467. * Naming tar Archives:: How @command{tar} Archives are Named
  468. * posix compliance::
  469. * Current status:: Current development status of @GNUTAR{}
  470. * Authors:: @GNUTAR{} Authors
  471. * Reports:: Reporting bugs or suggestions
  472. Tutorial Introduction to @command{tar}
  473. * assumptions::
  474. * stylistic conventions::
  475. * basic tar options:: Basic @command{tar} Operations and Options
  476. * frequent operations::
  477. * Two Frequent Options::
  478. * create:: How to Create Archives
  479. * list:: How to List Archives
  480. * extract:: How to Extract Members from an Archive
  481. * going further::
  482. Two Frequently Used Options
  483. * file tutorial::
  484. * verbose tutorial::
  485. * help tutorial::
  486. How to Create Archives
  487. * prepare for examples::
  488. * Creating the archive::
  489. * create verbose::
  490. * short create::
  491. * create dir::
  492. How to List Archives
  493. * list dir::
  494. How to Extract Members from an Archive
  495. * extracting archives::
  496. * extracting files::
  497. * extract dir::
  498. * failing commands::
  499. Invoking @GNUTAR{}
  500. * Synopsis::
  501. * using tar options::
  502. * Styles::
  503. * All Options::
  504. * help::
  505. * verbose::
  506. * interactive::
  507. The Three Option Styles
  508. * Mnemonic Options:: Mnemonic Option Style
  509. * Short Options:: Short Option Style
  510. * Old Options:: Old Option Style
  511. * Mixing:: Mixing Option Styles
  512. All @command{tar} Options
  513. * Operation Summary::
  514. * Option Summary::
  515. * Short Option Summary::
  516. @GNUTAR{} Operations
  517. * Basic tar::
  518. * Advanced tar::
  519. * create options::
  520. * extract options::
  521. * backup::
  522. * Applications::
  523. * looking ahead::
  524. Advanced @GNUTAR{} Operations
  525. * Operations::
  526. * append::
  527. * update::
  528. * concatenate::
  529. * delete::
  530. * compare::
  531. How to Add Files to Existing Archives: @code{--append}
  532. * appending files:: Appending Files to an Archive
  533. * multiple::
  534. Updating an Archive
  535. * how to update::
  536. Options Used by @code{--create}
  537. * Ignore Failed Read::
  538. Options Used by @code{--extract}
  539. * Reading:: Options to Help Read Archives
  540. * Writing:: Changing How @command{tar} Writes Files
  541. * Scarce:: Coping with Scarce Resources
  542. Options to Help Read Archives
  543. * read full records::
  544. * Ignore Zeros::
  545. Changing How @command{tar} Writes Files
  546. * Dealing with Old Files::
  547. * Overwrite Old Files::
  548. * Keep Old Files::
  549. * Unlink First::
  550. * Recursive Unlink::
  551. * Modification Times::
  552. * Setting Access Permissions::
  553. * Writing to Standard Output::
  554. * remove files::
  555. Coping with Scarce Resources
  556. * Starting File::
  557. * Same Order::
  558. Performing Backups and Restoring Files
  559. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  560. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  561. * incremental and listed-incremental:: The Incremental Options
  562. * Backup Levels:: Levels of Backups
  563. * Backup Parameters:: Setting Parameters for Backups and Restoration
  564. * Scripted Backups:: Using the Backup Scripts
  565. * Scripted Restoration:: Using the Restore Script
  566. Setting Parameters for Backups and Restoration
  567. * backup-specs example:: An Example Text of @file{Backup-specs}
  568. * Script Syntax:: Syntax for @file{Backup-specs}
  569. Choosing Files and Names for @command{tar}
  570. * file:: Choosing the Archive's Name
  571. * Selecting Archive Members::
  572. * files:: Reading Names from a File
  573. * exclude:: Excluding Some Files
  574. * Wildcards::
  575. * after:: Operating Only on New Files
  576. * recurse:: Descending into Directories
  577. * one:: Crossing Filesystem Boundaries
  578. Reading Names from a File
  579. * nul::
  580. Excluding Some Files
  581. * controlling pattern-patching with exclude::
  582. * problems with exclude::
  583. Crossing Filesystem Boundaries
  584. * directory:: Changing Directory
  585. * absolute:: Absolute File Names
  586. Date input formats
  587. * General date syntax:: Common rules.
  588. * Calendar date items:: 19 Dec 1994.
  589. * Time of day items:: 9:20pm.
  590. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  591. * Day of week items:: Monday and others.
  592. * Relative items in date strings:: next tuesday, 2 years ago.
  593. * Pure numbers in date strings:: 19931219, 1440.
  594. * Authors of getdate:: Bellovin, Eggert, Salz, Berets, et al.
  595. Controlling the Archive Format
  596. * Portability:: Making @command{tar} Archives More Portable
  597. * Compression:: Using Less Space through Compression
  598. * Attributes:: Handling File Attributes
  599. * Standard:: The Standard Format
  600. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  601. * cpio:: Comparison of @command{tar} and @command{cpio}
  602. Making @command{tar} Archives More Portable
  603. * Portable Names:: Portable Names
  604. * dereference:: Symbolic Links
  605. * old:: Old V7 Archives
  606. * posix:: @sc{posix} archives
  607. * Checksumming:: Checksumming Problems
  608. * Large or Negative Values:: Large files, negative time stamps, etc.
  609. Using Less Space through Compression
  610. * gzip:: Creating and Reading Compressed Archives
  611. * sparse:: Archiving Sparse Files
  612. Tapes and Other Archive Media
  613. * Device:: Device selection and switching
  614. * Remote Tape Server::
  615. * Common Problems and Solutions::
  616. * Blocking:: Blocking
  617. * Many:: Many archives on one tape
  618. * Using Multiple Tapes:: Using Multiple Tapes
  619. * label:: Including a Label in the Archive
  620. * verify::
  621. * Write Protection::
  622. Blocking
  623. * Format Variations:: Format Variations
  624. * Blocking Factor:: The Blocking Factor of an Archive
  625. Many Archives on One Tape
  626. * Tape Positioning:: Tape Positions and Tape Marks
  627. * mt:: The @command{mt} Utility
  628. Using Multiple Tapes
  629. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  630. * Tape Files:: Tape Files
  631. Copying This Manual
  632. * GNU Free Documentation License:: License for copying this manual
  633. @end detailmenu
  634. @end menu
  635. @node Introduction
  636. @chapter Introduction
  637. @GNUTAR{} creates
  638. and manipulates (@dfn{archives}) which are actually collections of
  639. many other files; the program provides users with an organized and
  640. systematic method for controlling a large amount of data.
  641. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  642. archives need not (and these days, typically do not) reside on tapes.
  643. @menu
  644. * Book Contents:: What this Book Contains
  645. * Definitions:: Some Definitions
  646. * What tar Does:: What @command{tar} Does
  647. * Naming tar Archives:: How @command{tar} Archives are Named
  648. * posix compliance::
  649. * Current status:: Current development status of @GNUTAR{}
  650. * Authors:: @GNUTAR{} Authors
  651. * Reports:: Reporting bugs or suggestions
  652. @end menu
  653. @node Book Contents
  654. @section What this Book Contains
  655. The first part of this chapter introduces you to various terms that will
  656. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  657. and its documentation, and where you should send bug reports
  658. or comments.
  659. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  660. gentle introduction for people who are new to using @command{tar}. It is
  661. meant to be self contained, not requiring any reading from subsequent
  662. chapters to make sense. It moves from topic to topic in a logical,
  663. progressive order, building on information already explained.
  664. Although the tutorial is paced and structured to allow beginners to
  665. learn how to use @command{tar}, it is not intended solely for beginners.
  666. The tutorial explains how to use the three most frequently used
  667. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  668. two frequently used options (@samp{file} and @samp{verbose}). The other
  669. chapters do not refer to the tutorial frequently; however, if a section
  670. discusses something which is a complex variant of a basic concept, there
  671. may be a cross reference to that basic concept. (The entire book,
  672. including the tutorial, assumes that the reader understands some basic
  673. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  674. The third chapter presents the remaining five operations, and
  675. information about using @command{tar} options and option syntax.
  676. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  677. than the reality. should think about whether this makes sense to say
  678. here, or not.} The other chapters are meant to be used as a
  679. reference. Each chapter presents everything that needs to be said
  680. about a specific topic.
  681. One of the chapters (@pxref{Date input formats}) exists in its
  682. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  683. In addition, one section of this manual (@pxref{Standard}) contains a
  684. big quote which is taken directly from @command{tar} sources.
  685. In general, we give both the long and short (abbreviated) option names
  686. at least once in each section where the relevant option is covered, so
  687. that novice readers will become familiar with both styles. (A few
  688. options have no short versions, and the relevant sections will
  689. indicate this.)
  690. @node Definitions
  691. @section Some Definitions
  692. @cindex archive
  693. @cindex tar archive
  694. The @command{tar} program is used to create and manipulate @command{tar}
  695. archives. An @dfn{archive} is a single file which contains the contents
  696. of many files, while still identifying the names of the files, their
  697. owner(s), and so forth. (In addition, archives record access
  698. permissions, user and group, size in bytes, and last modification time.
  699. Some archives also record the file names in each archived directory, as
  700. well as other file and directory information.) You can use @command{tar}
  701. to @dfn{create} a new archive in a specified directory.
  702. @cindex member
  703. @cindex archive member
  704. @cindex file name
  705. @cindex member name
  706. The files inside an archive are called @dfn{members}. Within this
  707. manual, we use the term @dfn{file} to refer only to files accessible in
  708. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  709. @dfn{member} to refer only to the members of an archive. Similarly, a
  710. @dfn{file name} is the name of a file, as it resides in the filesystem,
  711. and a @dfn{member name} is the name of an archive member within the
  712. archive.
  713. @cindex extraction
  714. @cindex unpacking
  715. The term @dfn{extraction} refers to the process of copying an archive
  716. member (or multiple members) into a file in the filesystem. Extracting
  717. all the members of an archive is often called @dfn{extracting the
  718. archive}. The term @dfn{unpack} can also be used to refer to the
  719. extraction of many or all the members of an archive. Extracting an
  720. archive does not destroy the archive's structure, just as creating an
  721. archive does not destroy the copies of the files that exist outside of
  722. the archive. You may also @dfn{list} the members in a given archive
  723. (this is often thought of as ``printing'' them to the standard output,
  724. or the command line), or @dfn{append} members to a pre-existing archive.
  725. All of these operations can be performed using @command{tar}.
  726. @node What tar Does
  727. @section What @command{tar} Does
  728. @cindex tar
  729. The @command{tar} program provides the ability to create @command{tar}
  730. archives, as well as various other kinds of manipulation. For example,
  731. you can use @command{tar} on previously created archives to extract files,
  732. to store additional files, or to update or list files which were already
  733. stored.
  734. Initially, @command{tar} archives were used to store files conveniently on
  735. magnetic tape. The name @command{tar} comes from this use; it stands for
  736. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  737. direct its output to available devices, files, or other programs (using
  738. pipes). @command{tar} may even access remote devices or files (as archives).
  739. @FIXME{the following table entries need a bit of work..}
  740. You can use @command{tar} archives in many ways. We want to stress a few
  741. of them: storage, backup, and transportation.
  742. @table @asis
  743. @item Storage
  744. Often, @command{tar} archives are used to store related files for
  745. convenient file transfer over a network. For example, the
  746. @acronym{GNU} Project distributes its software bundled into
  747. @command{tar} archives, so that all the files relating to a particular
  748. program (or set of related programs) can be transferred as a single
  749. unit.
  750. A magnetic tape can store several files in sequence. However, the tape
  751. has no names for these files; it only knows their relative position on
  752. the tape. One way to store several files on one tape and retain their
  753. names is by creating a @command{tar} archive. Even when the basic transfer
  754. mechanism can keep track of names, as FTP can, the nuisance of handling
  755. multiple files, directories, and multiple links makes @command{tar}
  756. archives useful.
  757. Archive files are also used for long-term storage. You can think of
  758. this as transportation from the present into the future. (It is a
  759. science-fiction idiom that you can move through time as well as in
  760. space; the idea here is that @command{tar} can be used to move archives in
  761. all dimensions, even time!)
  762. @item Backup
  763. Because the archive created by @command{tar} is capable of preserving
  764. file information and directory structure, @command{tar} is commonly
  765. used for performing full and incremental backups of disks. A backup
  766. puts a collection of files (possibly pertaining to many users and
  767. projects) together on a disk or a tape. This guards against
  768. accidental destruction of the information in those files.
  769. @GNUTAR{} has special features that allow it to be
  770. used to make incremental and full dumps of all the files in a
  771. filesystem.
  772. @item Transportation
  773. You can create an archive on one system, transfer it to another system,
  774. and extract the contents there. This allows you to transport a group of
  775. files from one system to another.
  776. @end table
  777. @node Naming tar Archives
  778. @section How @command{tar} Archives are Named
  779. Conventionally, @command{tar} archives are given names ending with
  780. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  781. but this manual follows that convention in order to accustom readers to
  782. it and to make examples more clear.
  783. @cindex tar file
  784. @cindex entry
  785. @cindex tar entry
  786. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  787. archive members as ``files'' or ``entries''. For people familiar with
  788. the operation of @command{tar}, this causes no difficulty. However, in
  789. this manual, we consistently refer to ``archives'' and ``archive
  790. members'' to make learning to use @command{tar} easier for novice users.
  791. @node posix compliance
  792. @section @sc{posix} Compliance
  793. @noindent
  794. @FIXME{must ask franc,ois about this. dan hagerty thinks this might
  795. be an issue, but we're not really sure at this time. dan just tried a
  796. test case of mixing up options' orders while the variable was set, and
  797. there was no problem...}
  798. @FIXME{I did not notice any problems either. Besides, the only piece
  799. of code that really uses POSIXLY_CORRECT is the one that forces
  800. creation of POSIX archives. I guess this paragraph should be removed.
  801. --gray}
  802. We make some of our recommendations throughout this book for one
  803. reason in addition to what we think of as ``good sense''. The main
  804. additional reason for a recommendation is to be compliant with the
  805. @sc{posix} standards. If you set the shell environment variable
  806. @env{POSIXLY_CORRECT}, @GNUTAR{} will force you to
  807. adhere to these standards. Therefore, if this variable is set and you
  808. violate one of the @sc{posix} standards in the way you phrase a
  809. command, for example, @GNUTAR{} will not allow the
  810. command and will signal an error message. You would then have to
  811. reorder the options or rephrase the command to comply with the
  812. @sc{posix} standards.
  813. Notice also, that if this environment variable is set, @GNUTAR{}
  814. will create @acronym{POSIX} archives. Currently this means that
  815. no @acronym{GNU} extensions will be allowed (@pxref{posix}).
  816. @node Current status
  817. @section Current development status of @GNUTAR{}
  818. @GNUTAR{} is currently in the process of active development, whose
  819. primary aims are:
  820. @itemize @bullet
  821. @item Improve compatibility between @GNUTAR{} and other @command{tar}
  822. implementations.
  823. @item Switch to using @acronym{POSIX} archives.
  824. @item Revise sparse file handling.
  825. @item Revise multiple volume processing.
  826. @end itemize
  827. The following issues need mentioning:
  828. @table @asis
  829. @item Use of short option @option{-o}.
  830. Earlier versions of @GNUTAR{} understood @option{-o} command line
  831. option as a synonym for @option{--old-archive}.
  832. @GNUTAR{} starting from version 1.13.90 understands this option as
  833. a synonym for @option{--no-same-owner}. This is compatible with
  834. UNIX98 @command{tar} implementations.
  835. However, to facilitate transition, @option{-o} option retains its
  836. old semantics when it is used with one of archive-creation commands.
  837. Users are encouraged to use @value{op-format-oldgnu} instead.
  838. Future versions of @GNUTAR{} will understand @option{-o} only as a
  839. synonym for @option{--no-same-owner}.
  840. @item Use of short option @option{-l}
  841. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  842. synonym for @samp{--one-file-system}. Such usage is deprecated.
  843. For compatibility with other implementations future versions of
  844. @GNUTAR{} will understand this option as a synonym for
  845. @option{--check-links}.
  846. @item Use of options @option{--portability} and @option{--old-archive}
  847. These options are deprecated. Please use @option{--format=v7} instead.
  848. @item Use of option @option{--posix}
  849. This option is deprecated. Please use @option{--format=posix} instead.
  850. @end table
  851. @node Authors
  852. @section @GNUTAR{} Authors
  853. @GNUTAR{} was originally written by John Gilmore,
  854. and modified by many people. The @acronym{GNU} enhancements were
  855. written by Jay Fenlason, then Joy Kendall, and the whole package has
  856. been further maintained by Thomas Bushnell, n/BSG, and finally
  857. Fran@,{c}ois Pinard, with the help of numerous and kind users.
  858. We wish to stress that @command{tar} is a collective work, and owes much to
  859. all those people who reported problems, offered solutions and other
  860. insights, or shared their thoughts and suggestions. An impressive, yet
  861. partial list of those contributors can be found in the @file{THANKS}
  862. file from the @GNUTAR{} distribution.
  863. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  864. sure i want to spell out the history in this detail, at least not for
  865. the printed book. i'm just not sure it needs to be said this way.
  866. i'll think about it.}
  867. @FIXME{History is more important, and surely more interesting, than
  868. actual names. Quoting names without history would be meaningless. FP}
  869. Jay Fenlason put together a draft of a @GNUTAR{}
  870. manual, borrowing notes from the original man page from John Gilmore.
  871. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  872. Gorin worked on a tutorial and manual for @GNUTAR{}.
  873. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  874. taking information from all these sources and merging them. Melissa
  875. Weisshaus finally edited and redesigned the book to create version
  876. 1.12. @FIXME{update version number as necessary; i'm being
  877. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  878. maybe melissa? maybe julie sussman?] needs to properly index the
  879. thing.}
  880. For version 1.12, Daniel Hagerty contributed a great deal of technical
  881. consulting. In particular, he is the primary author of @ref{Backups}.
  882. In July, 2003 @GNUTAR{} was put on CVS at @url{savannah.gnu.org}, and
  883. an active development and maintenance work has started
  884. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  885. Poznyakoff and Jeff Bailey.
  886. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  887. @node Reports
  888. @section Reporting bugs or suggestions
  889. @cindex bug reports
  890. @cindex reporting bugs
  891. If you find problems or have suggestions about this program or manual,
  892. please report them to @file{bug-tar@@gnu.org}.
  893. @node Tutorial
  894. @chapter Tutorial Introduction to @command{tar}
  895. This chapter guides you through some basic examples of three @command{tar}
  896. operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
  897. you already know how to use some other version of @command{tar}, then you
  898. may not need to read this chapter. This chapter omits most complicated
  899. details about how @command{tar} works.
  900. @menu
  901. * assumptions::
  902. * stylistic conventions::
  903. * basic tar options:: Basic @command{tar} Operations and Options
  904. * frequent operations::
  905. * Two Frequent Options::
  906. * create:: How to Create Archives
  907. * list:: How to List Archives
  908. * extract:: How to Extract Members from an Archive
  909. * going further::
  910. @end menu
  911. @node assumptions
  912. @section Assumptions this Tutorial Makes
  913. This chapter is paced to allow beginners to learn about @command{tar}
  914. slowly. At the same time, we will try to cover all the basic aspects of
  915. these three operations. In order to accomplish both of these tasks, we
  916. have made certain assumptions about your knowledge before reading this
  917. manual, and the hardware you will be using:
  918. @itemize @bullet
  919. @item
  920. Before you start to work through this tutorial, you should understand
  921. what the terms ``archive'' and ``archive member'' mean
  922. (@pxref{Definitions}). In addition, you should understand something
  923. about how Unix-type operating systems work, and you should know how to
  924. use some basic utilities. For example, you should know how to create,
  925. list, copy, rename, edit, and delete files and directories; how to
  926. change between directories; and how to figure out where you are in the
  927. filesystem. You should have some basic understanding of directory
  928. structure and how files are named according to which directory they are
  929. in. You should understand concepts such as standard output and standard
  930. input, what various definitions of the term ``argument'' mean, and the
  931. differences between relative and absolute path names. @FIXME{and what
  932. else?}
  933. @item
  934. This manual assumes that you are working from your own home directory
  935. (unless we state otherwise). In this tutorial, you will create a
  936. directory to practice @command{tar} commands in. When we show path names,
  937. we will assume that those paths are relative to your home directory.
  938. For example, my home directory path is @file{/home/fsf/melissa}. All of
  939. my examples are in a subdirectory of the directory named by that path
  940. name; the subdirectory is called @file{practice}.
  941. @item
  942. In general, we show examples of archives which exist on (or can be
  943. written to, or worked with from) a directory on a hard disk. In most
  944. cases, you could write those archives to, or work with them on any other
  945. device, such as a tape drive. However, some of the later examples in
  946. the tutorial and next chapter will not work on tape drives.
  947. Additionally, working with tapes is much more complicated than working
  948. with hard disks. For these reasons, the tutorial does not cover working
  949. with tape drives. @xref{Media}, for complete information on using
  950. @command{tar} archives with tape drives.
  951. @FIXME{this is a cop out. need to add some simple tape drive info.}
  952. @end itemize
  953. @node stylistic conventions
  954. @section Stylistic Conventions
  955. In the examples, @samp{$} represents a typical shell prompt. It
  956. precedes lines you should type; to make this more clear, those lines are
  957. shown in @kbd{this font}, as opposed to lines which represent the
  958. computer's response; those lines are shown in @code{this font}, or
  959. sometimes @samp{like this}. When we have lines which are too long to be
  960. displayed in any other way, we will show them like this:
  961. @smallexample
  962. This is an example of a line which would otherwise not fit in this space.
  963. @end smallexample
  964. @FIXME{how often do we use smallexample?}
  965. @node basic tar options
  966. @section Basic @command{tar} Operations and Options
  967. @command{tar} can take a wide variety of arguments which specify and define
  968. the actions it will have on the particular set of files or the archive.
  969. The main types of arguments to @command{tar} fall into one of two classes:
  970. operations, and options.
  971. Some arguments fall into a class called @dfn{operations}; exactly one of
  972. these is both allowed and required for any instance of using @command{tar};
  973. you may @emph{not} specify more than one. People sometimes speak of
  974. @dfn{operating modes}. You are in a particular operating mode when you
  975. have specified the operation which specifies it; there are eight
  976. operations in total, and thus there are eight operating modes.
  977. The other arguments fall into the class known as @dfn{options}. You are
  978. not required to specify any options, and you are allowed to specify more
  979. than one at a time (depending on the way you are using @command{tar} at
  980. that time). Some options are used so frequently, and are so useful for
  981. helping you type commands more carefully that they are effectively
  982. ``required''. We will discuss them in this chapter.
  983. You can write most of the @command{tar} operations and options in any
  984. of three forms: long (mnemonic) form, short form, and old style. Some
  985. of the operations and options have no short or ``old'' forms; however,
  986. the operations and options which we will cover in this tutorial have
  987. corresponding abbreviations. @FIXME{make sure this is still the case,
  988. at the end}We will indicate those abbreviations appropriately to get
  989. you used to seeing them. (Note that the ``old style'' option forms
  990. exist in @GNUTAR{} for compatibility with Unix
  991. @command{tar}. We present a full discussion of this way of writing
  992. options and operations appears in @ref{Old Options}, and we discuss
  993. the other two styles of writing options in @ref{Mnemonic Options} and
  994. @ref{Short Options}.)
  995. In the examples and in the text of this tutorial, we usually use the
  996. long forms of operations and options; but the ``short'' forms produce
  997. the same result and can make typing long @command{tar} commands easier.
  998. For example, instead of typing
  999. @smallexample
  1000. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  1001. @end smallexample
  1002. @noindent
  1003. you can type
  1004. @smallexample
  1005. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  1006. @end smallexample
  1007. @noindent
  1008. or even
  1009. @smallexample
  1010. @kbd{tar -cvf afiles.tar apple angst aspic}
  1011. @end smallexample
  1012. @noindent
  1013. For more information on option syntax, see @ref{Advanced tar}. In
  1014. discussions in the text, when we name an option by its long form, we
  1015. also give the corresponding short option in parentheses.
  1016. The term, ``option'', can be confusing at times, since ``operations''
  1017. are often lumped in with the actual, @emph{optional} ``options'' in certain
  1018. general class statements. For example, we just talked about ``short and
  1019. long forms of options and operations''. However, experienced @command{tar}
  1020. users often refer to these by shorthand terms such as, ``short and long
  1021. options''. This term assumes that the ``operations'' are included, also.
  1022. Context will help you determine which definition of ``options'' to use.
  1023. Similarly, the term ``command'' can be confusing, as it is often used in
  1024. two different ways. People sometimes refer to @command{tar} ``commands''.
  1025. A @command{tar} @dfn{command} is the entire command line of user input
  1026. which tells @command{tar} what to do --- including the operation, options,
  1027. and any arguments (file names, pipes, other commands, etc). However,
  1028. you will also sometimes hear the term ``the @command{tar} command''. When
  1029. the word ``command'' is used specifically like this, a person is usually
  1030. referring to the @command{tar} @emph{operation}, not the whole line.
  1031. Again, use context to figure out which of the meanings the speaker
  1032. intends.
  1033. @node frequent operations
  1034. @section The Three Most Frequently Used Operations
  1035. Here are the three most frequently used operations (both short and long
  1036. forms), as well as a brief description of their meanings. The rest of
  1037. this chapter will cover how to use these operations in detail. We will
  1038. present the rest of the operations in the next chapter.
  1039. @table @kbd
  1040. @item --create
  1041. @itemx -c
  1042. Create a new @command{tar} archive.
  1043. @item --list
  1044. @itemx -t
  1045. List the contents of an archive.
  1046. @item --extract
  1047. @itemx -x
  1048. Extract one or more members from an archive.
  1049. @end table
  1050. @node Two Frequent Options
  1051. @section Two Frequently Used Options
  1052. To understand how to run @command{tar} in the three operating modes listed
  1053. previously, you also need to understand how to use two of the options to
  1054. @command{tar}: @samp{--file} (which takes an archive file as an argument)
  1055. and @samp{--verbose}. (You are usually not @emph{required} to specify
  1056. either of these options when you run @command{tar}, but they can be very
  1057. useful in making things more clear and helping you avoid errors.)
  1058. @menu
  1059. * file tutorial::
  1060. * verbose tutorial::
  1061. * help tutorial::
  1062. @end menu
  1063. @node file tutorial
  1064. @unnumberedsubsec The @samp{--file} Option
  1065. @table @kbd
  1066. @item --file=@var{archive-name}
  1067. @itemx -f @var{archive-name}
  1068. Specify the name of an archive file.
  1069. @end table
  1070. You can specify an argument for the @value{op-file} option whenever you
  1071. use @command{tar}; this option determines the name of the archive file
  1072. that @command{tar} will work on.
  1073. If you don't specify this argument, then @command{tar} will use a
  1074. default, usually some physical tape drive attached to your machine.
  1075. If there is no tape drive attached, or the default is not meaningful,
  1076. then @command{tar} will print an error message. The error message might
  1077. look roughly like one of the following:
  1078. @smallexample
  1079. tar: can't open /dev/rmt8 : No such device or address
  1080. tar: can't open /dev/rsmt0 : I/O error
  1081. @end smallexample
  1082. @noindent
  1083. To avoid confusion, we recommend that you always specify an archive file
  1084. name by using @value{op-file} when writing your @command{tar} commands.
  1085. For more information on using the @value{op-file} option, see
  1086. @ref{file}.
  1087. @node verbose tutorial
  1088. @unnumberedsubsec The @samp{--verbose} Option
  1089. @table @kbd
  1090. @item --verbose
  1091. @itemx -v
  1092. Show the files being worked on as @command{tar} is running.
  1093. @end table
  1094. @value{op-verbose} shows details about the results of running
  1095. @command{tar}. This can be especially useful when the results might not be
  1096. obvious. For example, if you want to see the progress of @command{tar} as
  1097. it writes files into the archive, you can use the @samp{--verbose}
  1098. option. In the beginning, you may find it useful to use
  1099. @samp{--verbose} at all times; when you are more accustomed to
  1100. @command{tar}, you will likely want to use it at certain times but not at
  1101. others. We will use @samp{--verbose} at times to help make something
  1102. clear, and we will give many examples both using and not using
  1103. @samp{--verbose} to show the differences.
  1104. Sometimes, a single instance of @samp{--verbose} on the command line
  1105. will show a full, @samp{ls} style listing of an archive or files,
  1106. @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
  1107. giving sizes, owners, and similar information. Other times,
  1108. @samp{--verbose} will only show files or members that the particular
  1109. operation is operating on at the time. In the latter case, you can
  1110. use @samp{--verbose} twice in a command to get a listing such as that
  1111. in the former case. For example, instead of saying
  1112. @smallexample
  1113. @kbd{tar -cvf afiles.tar apple angst aspic}
  1114. @end smallexample
  1115. @noindent
  1116. above, you might say
  1117. @smallexample
  1118. @kbd{tar -cvvf afiles.tar apple angst aspic}
  1119. @end smallexample
  1120. @noindent
  1121. This works equally well using short or long forms of options. Using
  1122. long forms, you would simply write out the mnemonic form of the option
  1123. twice, like this:
  1124. @smallexample
  1125. $ @kbd{tar --create --verbose --verbose @dots{}}
  1126. @end smallexample
  1127. @noindent
  1128. Note that you must double the hyphens properly each time.
  1129. Later in the tutorial, we will give examples using @w{@samp{--verbose
  1130. --verbose}}.
  1131. @node help tutorial
  1132. @unnumberedsubsec Getting Help: Using the @code{--help} Option
  1133. @table @kbd
  1134. @item --help
  1135. The @samp{--help} option to @command{tar} prints out a very brief list of
  1136. all operations and option available for the current version of
  1137. @command{tar} available on your system.
  1138. @end table
  1139. @node create
  1140. @section How to Create Archives
  1141. @UNREVISED
  1142. One of the basic operations of @command{tar} is @value{op-create}, which
  1143. you use to create a @command{tar} archive. We will explain
  1144. @samp{--create} first because, in order to learn about the other
  1145. operations, you will find it useful to have an archive available to
  1146. practice on.
  1147. To make this easier, in this section you will first create a directory
  1148. containing three files. Then, we will show you how to create an
  1149. @emph{archive} (inside the new directory). Both the directory, and
  1150. the archive are specifically for you to practice on. The rest of this
  1151. chapter and the next chapter will show many examples using this
  1152. directory and the files you will create: some of those files may be
  1153. other directories and other archives.
  1154. The three files you will archive in this example are called
  1155. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  1156. @file{collection.tar}.
  1157. This section will proceed slowly, detailing how to use @samp{--create}
  1158. in @code{verbose} mode, and showing examples using both short and long
  1159. forms. In the rest of the tutorial, and in the examples in the next
  1160. chapter, we will proceed at a slightly quicker pace. This section
  1161. moves more slowly to allow beginning users to understand how
  1162. @command{tar} works.
  1163. @menu
  1164. * prepare for examples::
  1165. * Creating the archive::
  1166. * create verbose::
  1167. * short create::
  1168. * create dir::
  1169. @end menu
  1170. @node prepare for examples
  1171. @subsection Preparing a Practice Directory for Examples
  1172. To follow along with this and future examples, create a new directory
  1173. called @file{practice} containing files called @file{blues}, @file{folk}
  1174. and @file{jazz}. The files can contain any information you like:
  1175. ideally, they should contain information which relates to their names,
  1176. and be of different lengths. Our examples assume that @file{practice}
  1177. is a subdirectory of your home directory.
  1178. Now @command{cd} to the directory named @file{practice}; @file{practice}
  1179. is now your @dfn{working directory}. (@emph{Please note}: Although
  1180. the full path name of this directory is
  1181. @file{/@var{homedir}/practice}, in our examples we will refer to
  1182. this directory as @file{practice}; the @var{homedir} is presumed.
  1183. In general, you should check that the files to be archived exist where
  1184. you think they do (in the working directory) by running @command{ls}.
  1185. Because you just created the directory and the files and have changed to
  1186. that directory, you probably don't need to do that this time.
  1187. It is very important to make sure there isn't already a file in the
  1188. working directory with the archive name you intend to use (in this case,
  1189. @samp{collection.tar}), or that you don't care about its contents.
  1190. Whenever you use @samp{create}, @command{tar} will erase the current
  1191. contents of the file named by @value{op-file} if it exists. @command{tar}
  1192. will not tell you if you are about to overwrite an archive unless you
  1193. specify an option which does this. @FIXME{xref to the node for
  1194. --backup!}To add files to an existing archive, you need to use a
  1195. different option, such as @value{op-append}; see @ref{append} for
  1196. information on how to do this.
  1197. @node Creating the archive
  1198. @subsection Creating the Archive
  1199. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  1200. archive named @file{collection.tar}, use the following command:
  1201. @smallexample
  1202. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  1203. @end smallexample
  1204. The order of the arguments is not very important, @emph{when using long
  1205. option forms}. You could also say:
  1206. @smallexample
  1207. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1208. @end smallexample
  1209. @noindent
  1210. However, you can see that this order is harder to understand; this is
  1211. why we will list the arguments in the order that makes the commands
  1212. easiest to understand (and we encourage you to do the same when you use
  1213. @command{tar}, to avoid errors).
  1214. Note that the part of the command which says,
  1215. @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
  1216. If you substituted any other string of characters for
  1217. @kbd{collection.tar}, then that string would become the name of the
  1218. archive file you create.
  1219. The order of the options becomes more important when you begin to use
  1220. short forms. With short forms, if you type commands in the wrong order
  1221. (even if you type them correctly in all other ways), you may end up with
  1222. results you don't expect. For this reason, it is a good idea to get
  1223. into the habit of typing options in the order that makes inherent sense.
  1224. @xref{short create}, for more information on this.
  1225. In this example, you type the command as shown above: @samp{--create}
  1226. is the operation which creates the new archive
  1227. (@file{collection.tar}), and @samp{--file} is the option which lets
  1228. you give it the name you chose. The files, @file{blues}, @file{folk},
  1229. and @file{jazz}, are now members of the archive, @file{collection.tar}
  1230. (they are @dfn{file name arguments} to the @samp{--create} operation).
  1231. @FIXME{xref here to the discussion of file name args?}Now that they are
  1232. in the archive, they are called @emph{archive members}, not files.
  1233. @FIXME{xref to definitions?}
  1234. When you create an archive, you @emph{must} specify which files you
  1235. want placed in the archive. If you do not specify any archive
  1236. members, @GNUTAR{} will complain.
  1237. If you now list the contents of the working directory (@kbd{ls}), you will
  1238. find the archive file listed as well as the files you saw previously:
  1239. @smallexample
  1240. blues folk jazz collection.tar
  1241. @end smallexample
  1242. @noindent
  1243. Creating the archive @samp{collection.tar} did not destroy the copies of
  1244. the files in the directory.
  1245. Keep in mind that if you don't indicate an operation, @command{tar} will not
  1246. run and will prompt you for one. If you don't name any files, @command{tar}
  1247. will complain. You must have write access to the working directory,
  1248. or else you will not be able to create an archive in that directory.
  1249. @emph{Caution}: Do not attempt to use @value{op-create} to add files to
  1250. an existing archive; it will delete the archive and write a new one.
  1251. Use @value{op-append} instead. @xref{append}.
  1252. @node create verbose
  1253. @subsection Running @samp{--create} with @samp{--verbose}
  1254. If you include the @value{op-verbose} option on the command line,
  1255. @command{tar} will list the files it is acting on as it is working. In
  1256. verbose mode, the @code{create} example above would appear as:
  1257. @smallexample
  1258. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  1259. blues
  1260. folk
  1261. jazz
  1262. @end smallexample
  1263. This example is just like the example we showed which did not use
  1264. @samp{--verbose}, except that @command{tar} generated the remaining lines
  1265. @iftex
  1266. (note the different font styles).
  1267. @end iftex
  1268. @ifinfo
  1269. .
  1270. @end ifinfo
  1271. In the rest of the examples in this chapter, we will frequently use
  1272. @code{verbose} mode so we can show actions or @command{tar} responses that
  1273. you would otherwise not see, and which are important for you to
  1274. understand.
  1275. @node short create
  1276. @subsection Short Forms with @samp{create}
  1277. As we said before, the @value{op-create} operation is one of the most
  1278. basic uses of @command{tar}, and you will use it countless times.
  1279. Eventually, you will probably want to use abbreviated (or ``short'')
  1280. forms of options. A full discussion of the three different forms that
  1281. options can take appears in @ref{Styles}; for now, here is what the
  1282. previous example (including the @value{op-verbose} option) looks like
  1283. using short option forms:
  1284. @smallexample
  1285. $ @kbd{tar -cvf collection.tar blues folk jazz}
  1286. blues
  1287. folk
  1288. jazz
  1289. @end smallexample
  1290. @noindent
  1291. As you can see, the system responds the same no matter whether you use
  1292. long or short option forms.
  1293. @FIXME{i don't like how this is worded:} One difference between using
  1294. short and long option forms is that, although the exact placement of
  1295. arguments following options is no more specific when using short forms,
  1296. it is easier to become confused and make a mistake when using short
  1297. forms. For example, suppose you attempted the above example in the
  1298. following way:
  1299. @smallexample
  1300. $ @kbd{tar -cfv collection.tar blues folk jazz}
  1301. @end smallexample
  1302. @noindent
  1303. In this case, @command{tar} will make an archive file called @file{v},
  1304. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  1305. the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
  1306. is thus taken to be the chosen archive file name. @command{tar} will try
  1307. to add a file called @file{collection.tar} to the @file{v} archive file;
  1308. if the file @file{collection.tar} did not already exist, @command{tar} will
  1309. report an error indicating that this file does not exist. If the file
  1310. @file{collection.tar} does already exist (e.g., from a previous command
  1311. you may have run), then @command{tar} will add this file to the archive.
  1312. Because the @samp{-v} option did not get registered, @command{tar} will not
  1313. run under @samp{verbose} mode, and will not report its progress.
  1314. The end result is that you may be quite confused about what happened,
  1315. and possibly overwrite a file. To illustrate this further, we will show
  1316. you how an example we showed previously would look using short forms.
  1317. This example,
  1318. @smallexample
  1319. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1320. @end smallexample
  1321. @noindent
  1322. is confusing as it is. When shown using short forms, however, it
  1323. becomes much more so:
  1324. @smallexample
  1325. $ @kbd{tar blues -c folk -f collection.tar jazz}
  1326. @end smallexample
  1327. @noindent
  1328. It would be very easy to put the wrong string of characters
  1329. immediately following the @samp{-f}, but doing that could sacrifice
  1330. valuable data.
  1331. For this reason, we recommend that you pay very careful attention to
  1332. the order of options and placement of file and archive names,
  1333. especially when using short option forms. Not having the option name
  1334. written out mnemonically can affect how well you remember which option
  1335. does what, and therefore where different names have to be placed.
  1336. (Placing options in an unusual order can also cause @command{tar} to
  1337. report an error if you have set the shell environment variable
  1338. @env{POSIXLY_CORRECT}; @pxref{posix compliance} for more information
  1339. on this.)
  1340. @node create dir
  1341. @subsection Archiving Directories
  1342. @cindex Archiving Directories
  1343. @cindex Directories, Archiving
  1344. You can archive a directory by specifying its directory name as a
  1345. file name argument to @command{tar}. The files in the directory will be
  1346. archived relative to the working directory, and the directory will be
  1347. re-created along with its contents when the archive is extracted.
  1348. To archive a directory, first move to its superior directory. If you
  1349. have followed the previous instructions in this tutorial, you should
  1350. type:
  1351. @smallexample
  1352. $ @kbd{cd ..}
  1353. $
  1354. @end smallexample
  1355. @noindent
  1356. This will put you into the directory which contains @file{practice},
  1357. i.e. your home directory. Once in the superior directory, you can
  1358. specify the subdirectory, @file{practice}, as a file name argument. To
  1359. store @file{practice} in the new archive file @file{music.tar}, type:
  1360. @smallexample
  1361. $ @kbd{tar --create --verbose --file=music.tar practice}
  1362. @end smallexample
  1363. @noindent
  1364. @command{tar} should output:
  1365. @smallexample
  1366. practice/
  1367. practice/blues
  1368. practice/folk
  1369. practice/jazz
  1370. practice/collection.tar
  1371. @end smallexample
  1372. Note that the archive thus created is not in the subdirectory
  1373. @file{practice}, but rather in the current working directory---the
  1374. directory from which @command{tar} was invoked. Before trying to archive a
  1375. directory from its superior directory, you should make sure you have
  1376. write access to the superior directory itself, not only the directory
  1377. you are trying archive with @command{tar}. For example, you will probably
  1378. not be able to store your home directory in an archive by invoking
  1379. @command{tar} from the root directory; @value{xref-absolute-names}. (Note
  1380. also that @file{collection.tar}, the original archive file, has itself
  1381. been archived. @command{tar} will accept any file as a file to be
  1382. archived, regardless of its content. When @file{music.tar} is
  1383. extracted, the archive file @file{collection.tar} will be re-written
  1384. into the file system).
  1385. If you give @command{tar} a command such as
  1386. @smallexample
  1387. $ @kbd{tar --create --file=foo.tar .}
  1388. @end smallexample
  1389. @noindent
  1390. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1391. dumped}. This happens because @command{tar} creates the archive
  1392. @file{foo.tar} in the current directory before putting any files into
  1393. it. Then, when @command{tar} attempts to add all the files in the
  1394. directory @file{.} to the archive, it notices that the file
  1395. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1396. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1397. will continue in this case, and create the archive
  1398. normally, except for the exclusion of that one file. (@emph{Please
  1399. note:} Other versions of @command{tar} are not so clever; they will
  1400. enter an infinite loop when this happens, so you should not depend on
  1401. this behavior unless you are certain you are running @GNUTAR{}.)
  1402. @FIXME{bob doesn't like this sentence, since he does
  1403. it all the time, and we've been doing it in the editing passes for
  1404. this manual: In general, make sure that the archive is not inside a
  1405. directory being dumped.}
  1406. @node list
  1407. @section How to List Archives
  1408. Frequently, you will find yourself wanting to determine exactly what a
  1409. particular archive contains. You can use the @value{op-list} operation
  1410. to get the member names as they currently appear in the archive, as well
  1411. as various attributes of the files at the time they were archived. For
  1412. example, you can examine the archive @file{collection.tar} that you
  1413. created in the last section with the command,
  1414. @smallexample
  1415. $ @kbd{tar --list --file=collection.tar}
  1416. @end smallexample
  1417. @noindent
  1418. The output of @command{tar} would then be:
  1419. @smallexample
  1420. blues
  1421. folk
  1422. jazz
  1423. @end smallexample
  1424. @FIXME{we hope this will change. if it doesn't, need to show the
  1425. creation of bfiles somewhere above!!! : }
  1426. @noindent
  1427. The archive @file{bfiles.tar} would list as follows:
  1428. @smallexample
  1429. ./birds
  1430. baboon
  1431. ./box
  1432. @end smallexample
  1433. @noindent
  1434. Be sure to use a @value{op-file} option just as with @value{op-create}
  1435. to specify the name of the archive.
  1436. If you use the @value{op-verbose} option with @samp{--list}, then
  1437. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1438. showing owner, file size, and so forth.
  1439. If you had used @value{op-verbose} mode, the example above would look
  1440. like:
  1441. @smallexample
  1442. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1443. -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
  1444. @end smallexample
  1445. @cindex File name arguments, using @code{--list} with
  1446. @cindex @code{--list} with file name arguments
  1447. You can specify one or more individual member names as arguments when
  1448. using @samp{list}. In this case, @command{tar} will only list the
  1449. names of members you identify. For example, @w{@kbd{tar --list
  1450. --file=afiles.tar apple}} would only print @file{apple}.
  1451. @FIXME{we hope the relevant aspects of this will change:}Because
  1452. @command{tar} preserves paths, file names must be specified as they appear
  1453. in the archive (ie., relative to the directory from which the archive
  1454. was created). Therefore, it is essential when specifying member names
  1455. to @command{tar} that you give the exact member names. For example,
  1456. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1457. something like @samp{tar: birds: Not found in archive}, because there is
  1458. no member named @file{birds}, only one named @file{./birds}. While the
  1459. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1460. names are compared using a simplistic name comparison, in which an exact
  1461. match is necessary. @xref{absolute}.
  1462. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1463. with @file{folk}, because @file{folk} is in the archive file
  1464. @file{collection.tar}. If you are not sure of the exact file name, try
  1465. listing all the files in the archive and searching for the one you
  1466. expect to find; remember that if you use @samp{--list} with no file
  1467. names as arguments, @command{tar} will print the names of all the members
  1468. stored in the specified archive.
  1469. @menu
  1470. * list dir::
  1471. @end menu
  1472. @node list dir
  1473. @unnumberedsubsec Listing the Contents of a Stored Directory
  1474. @UNREVISED
  1475. @FIXME{i changed the order of these nodes around and haven't had a
  1476. chance to play around with this node's example, yet. i have to play
  1477. with it and see what it actually does for my own satisfaction, even if
  1478. what it says *is* correct..}
  1479. To get information about the contents of an archived directory,
  1480. use the directory name as a file name argument in conjunction with
  1481. @value{op-list}. To find out file attributes, include the
  1482. @value{op-verbose} option.
  1483. For example, to find out about files in the directory @file{practice}, in
  1484. the archive file @file{music.tar}, type:
  1485. @smallexample
  1486. $ @kbd{tar --list --verbose --file=music.tar practice}
  1487. @end smallexample
  1488. @command{tar} responds:
  1489. @smallexample
  1490. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1491. -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
  1492. -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
  1493. -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
  1494. -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1495. @end smallexample
  1496. When you use a directory name as a file name argument, @command{tar} acts on
  1497. all the files (including sub-directories) in that directory.
  1498. @node extract
  1499. @section How to Extract Members from an Archive
  1500. @UNREVISED
  1501. @cindex Extraction
  1502. @cindex Retrieving files from an archive
  1503. @cindex Resurrecting files from an archive
  1504. Creating an archive is only half the job---there is no point in storing
  1505. files in an archive if you can't retrieve them. The act of retrieving
  1506. members from an archive so they can be used and manipulated as
  1507. unarchived files again is called @dfn{extraction}. To extract files
  1508. from an archive, use the @value{op-extract} operation. As with
  1509. @value{op-create}, specify the name of the archive with @value{op-file}.
  1510. Extracting an archive does not modify the archive in any way; you can
  1511. extract it multiple times if you want or need to.
  1512. Using @samp{--extract}, you can extract an entire archive, or specific
  1513. files. The files can be directories containing other files, or not. As
  1514. with @value{op-create} and @value{op-list}, you may use the short or the
  1515. long form of the operation without affecting the performance.
  1516. @menu
  1517. * extracting archives::
  1518. * extracting files::
  1519. * extract dir::
  1520. * extracting untrusted archives::
  1521. * failing commands::
  1522. @end menu
  1523. @node extracting archives
  1524. @subsection Extracting an Entire Archive
  1525. To extract an entire archive, specify the archive file name only, with
  1526. no individual file names as arguments. For example,
  1527. @smallexample
  1528. $ @kbd{tar -xvf collection.tar}
  1529. @end smallexample
  1530. @noindent
  1531. produces this:
  1532. @smallexample
  1533. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  1534. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  1535. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  1536. @end smallexample
  1537. @node extracting files
  1538. @subsection Extracting Specific Files
  1539. To extract specific archive members, give their exact member names as
  1540. arguments, as printed by @value{op-list}. If you had mistakenly deleted
  1541. one of the files you had placed in the archive @file{collection.tar}
  1542. earlier (say, @file{blues}), you can extract it from the archive without
  1543. changing the archive's structure. It will be identical to the original
  1544. file @file{blues} that you deleted. @FIXME{check this; will the times,
  1545. permissions, owner, etc be the same, also?}
  1546. First, make sure you are in the @file{practice} directory, and list the
  1547. files in the directory. Now, delete the file, @samp{blues}, and list
  1548. the files in the directory again.
  1549. You can now extract the member @file{blues} from the archive file
  1550. @file{collection.tar} like this:
  1551. @smallexample
  1552. $ @kbd{tar --extract --file=collection.tar blues}
  1553. @end smallexample
  1554. @noindent
  1555. If you list the files in the directory again, you will see that the file
  1556. @file{blues} has been restored, with its original permissions, creation
  1557. times, and owner.@FIXME{This is only accidentally true, but not in
  1558. general. In most cases, one has to be root for restoring the owner, and
  1559. use a special option for restoring permissions. Here, it just happens
  1560. that the restoring user is also the owner of the archived members, and
  1561. that the current @code{umask} is compatible with original permissions.}
  1562. (These parameters will be identical to those which
  1563. the file had when you originally placed it in the archive; any changes
  1564. you may have made before deleting the file from the file system,
  1565. however, will @emph{not} have been made to the archive member.) The
  1566. archive file, @samp{collection.tar}, is the same as it was before you
  1567. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1568. @value{op-list}.
  1569. @FIXME{we hope this will change:}Remember that as with other operations,
  1570. specifying the exact member name is important. @w{@kbd{tar --extract
  1571. --file=bfiles.tar birds}} will fail, because there is no member named
  1572. @file{birds}. To extract the member named @file{./birds}, you must
  1573. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1574. exact member names of the members of an archive, use @value{op-list}
  1575. (@pxref{list}).
  1576. You can extract a file to standard output by combining the above options
  1577. with the @option{--to-stdout} option (@pxref{Writing to Standard
  1578. Output}).
  1579. If you give the @value{op-verbose} option, then @value{op-extract} will
  1580. print the names of the archive members as it extracts them.
  1581. @node extract dir
  1582. @subsection Extracting Files that are Directories
  1583. Extracting directories which are members of an archive is similar to
  1584. extracting other files. The main difference to be aware of is that if
  1585. the extracted directory has the same name as any directory already in
  1586. the working directory, then files in the extracted directory will be
  1587. placed into the directory of the same name. Likewise, if there are
  1588. files in the pre-existing directory with the same names as the members
  1589. which you extract, the files from the extracted archive will replace
  1590. the files already in the working directory (and possible
  1591. subdirectories). This will happen regardless of whether or not the
  1592. files in the working directory were more recent than those extracted.
  1593. However, if a file was stored with a directory name as part of its file
  1594. name, and that directory does not exist under the working directory when
  1595. the file is extracted, @command{tar} will create the directory.
  1596. We can demonstrate how to use @samp{--extract} to extract a directory
  1597. file with an example. Change to the @file{practice} directory if you
  1598. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1599. go back to the parent directory and extract the archive
  1600. @file{music.tar}. You may either extract the entire archive, or you may
  1601. extract only the files you just deleted. To extract the entire archive,
  1602. don't give any file names as arguments after the archive name
  1603. @file{music.tar}. To extract only the files you deleted, use the
  1604. following command:
  1605. @smallexample
  1606. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1607. @end smallexample
  1608. @FIXME{need to show tar's response; used verbose above. also, here's a
  1609. good place to demonstrate the -v -v thing. have to write that up
  1610. (should be trivial, but i'm too tired!).}
  1611. @noindent
  1612. Because you created the directory with @file{practice} as part of the
  1613. file names of each of the files by archiving the @file{practice}
  1614. directory as @file{practice}, you must give @file{practice} as part
  1615. of the file names when you extract those files from the archive.
  1616. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1617. will be.}
  1618. @node extracting untrusted archives
  1619. @subsection Extracting Archives from Untrusted Sources
  1620. Extracting files from archives can overwrite files that already exist.
  1621. If you receive an archive from an untrusted source, you should make a
  1622. new directory and extract into that directory, so that you don't have
  1623. to worry about the extraction overwriting one of your existing files.
  1624. For example, if @file{untrusted.tar} came from somewhere else on the
  1625. Internet, and you don't necessarily trust its contents, you can
  1626. extract it as follows:
  1627. @smallexample
  1628. $ @kbd{mkdir newdir}
  1629. $ @kbd{cd newdir}
  1630. $ @kbd{tar -xvf ../untrusted.tar}
  1631. @end smallexample
  1632. @node failing commands
  1633. @subsection Commands That Will Fail
  1634. Here are some sample commands you might try which will not work, and why
  1635. they won't work.
  1636. If you try to use this command,
  1637. @smallexample
  1638. $ @kbd{tar -xvf music.tar folk jazz}
  1639. @end smallexample
  1640. @noindent
  1641. you will get the following response:
  1642. @smallexample
  1643. tar: folk: Not found in archive
  1644. tar: jazz: Not found in archive
  1645. $
  1646. @end smallexample
  1647. @noindent
  1648. This is because these files were not originally @emph{in} the parent
  1649. directory @file{..}, where the archive is located; they were in the
  1650. @file{practice} directory, and their file names reflect this:
  1651. @smallexample
  1652. $ @kbd{tar -tvf music.tar}
  1653. practice/folk
  1654. practice/jazz
  1655. practice/rock
  1656. @end smallexample
  1657. @FIXME{make sure the above works when going through the examples in
  1658. order...}
  1659. @noindent
  1660. Likewise, if you try to use this command,
  1661. @smallexample
  1662. $ @kbd{tar -tvf music.tar folk jazz}
  1663. @end smallexample
  1664. @noindent
  1665. you would get a similar response. Members with those names are not in the
  1666. archive. You must use the correct member names in order to extract the
  1667. files from the archive.
  1668. If you have forgotten the correct names of the files in the archive,
  1669. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1670. @FIXME{more examples, here? hag thinks it's a good idea.}
  1671. @node going further
  1672. @section Going Further Ahead in this Manual
  1673. @FIXME{need to write up a node here about the things that are going to
  1674. be in the rest of the manual.}
  1675. @node tar invocation
  1676. @chapter Invoking @GNUTAR{}
  1677. @UNREVISED
  1678. This chapter is about how one invokes the @GNUTAR{}
  1679. command, from the command synopsis (@pxref{Synopsis}). There are
  1680. numerous options, and many styles for writing them. One mandatory
  1681. option specifies the operation @command{tar} should perform
  1682. (@pxref{Operation Summary}), other options are meant to detail how
  1683. this operation should be performed (@pxref{Option Summary}).
  1684. Non-option arguments are not always interpreted the same way,
  1685. depending on what the operation is.
  1686. You will find in this chapter everything about option styles and rules for
  1687. writing them (@pxref{Styles}). On the other hand, operations and options
  1688. are fully described elsewhere, in other chapters. Here, you will find
  1689. only synthetic descriptions for operations and options, together with
  1690. pointers to other parts of the @command{tar} manual.
  1691. Some options are so special they are fully described right in this
  1692. chapter. They have the effect of inhibiting the normal operation of
  1693. @command{tar} or else, they globally alter the amount of feedback the user
  1694. receives about what is going on. These are the @value{op-help} and
  1695. @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
  1696. and @value{op-interactive} options (@pxref{interactive}).
  1697. @menu
  1698. * Synopsis::
  1699. * using tar options::
  1700. * Styles::
  1701. * All Options::
  1702. * help::
  1703. * verbose::
  1704. * interactive::
  1705. @end menu
  1706. @node Synopsis
  1707. @section General Synopsis of @command{tar}
  1708. The @GNUTAR{} program is invoked as either one of:
  1709. @smallexample
  1710. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1711. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1712. @end smallexample
  1713. The second form is for when old options are being used.
  1714. You can use @command{tar} to store files in an archive, to extract them from
  1715. an archive, and to do other types of archive manipulation. The primary
  1716. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1717. which action to take. The other arguments to @command{tar} are either
  1718. @dfn{options}, which change the way @command{tar} performs an operation,
  1719. or file names or archive members, which specify the files or members
  1720. @command{tar} is to act on.
  1721. You can actually type in arguments in any order, even if in this manual
  1722. the options always precede the other arguments, to make examples easier
  1723. to understand. Further, the option stating the main operation mode
  1724. (the @command{tar} main command) is usually given first.
  1725. Each @var{name} in the synopsis above is interpreted as an archive member
  1726. name when the main command is one of @value{op-compare}, @value{op-delete},
  1727. @value{op-extract}, @value{op-list} or @value{op-update}. When naming
  1728. archive members, you must give the exact name of the member in the
  1729. archive, as it is printed by @value{op-list}. For @value{op-append}
  1730. and @value{op-create}, these @var{name} arguments specify the names
  1731. of either files or directory hierarchies to place in the archive.
  1732. These files or hierarchies should already exist in the file system,
  1733. prior to the execution of the @command{tar} command.
  1734. @command{tar} interprets relative file names as being relative to the
  1735. working directory. @command{tar} will make all file names relative
  1736. (by removing leading slashes when archiving or restoring files),
  1737. unless you specify otherwise (using the @value{op-absolute-names}
  1738. option). @value{xref-absolute-names}, for more information about
  1739. @value{op-absolute-names}.
  1740. If you give the name of a directory as either a file name or a member
  1741. name, then @command{tar} acts recursively on all the files and directories
  1742. beneath that directory. For example, the name @file{/} identifies all
  1743. the files in the filesystem to @command{tar}.
  1744. The distinction between file names and archive member names is especially
  1745. important when shell globbing is used, and sometimes a source of confusion
  1746. for newcomers. @xref{Wildcards}, for more information about globbing.
  1747. The problem is that shells may only glob using existing files in the
  1748. file system. Only @command{tar} itself may glob on archive members, so when
  1749. needed, you must ensure that wildcard characters reach @command{tar} without
  1750. being interpreted by the shell first. Using a backslash before @samp{*}
  1751. or @samp{?}, or putting the whole argument between quotes, is usually
  1752. sufficient for this.
  1753. Even if @var{name}s are often specified on the command line, they
  1754. can also be read from a text file in the file system, using the
  1755. @value{op-files-from} option.
  1756. If you don't use any file name arguments, @value{op-append},
  1757. @value{op-delete} and @value{op-concatenate} will do nothing, while
  1758. @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
  1759. execution. The other operations of @command{tar} (@value{op-list},
  1760. @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
  1761. on the entire contents of the archive.
  1762. @cindex exit status
  1763. @cindex return status
  1764. Besides successful exits, @GNUTAR{} may fail for
  1765. many reasons. Some reasons correspond to bad usage, that is, when the
  1766. @command{tar} command is improperly written. Errors may be
  1767. encountered later, while encountering an error processing the archive
  1768. or the files. Some errors are recoverable, in which case the failure
  1769. is delayed until @command{tar} has completed all its work. Some
  1770. errors are such that it would not meaningful, or at least risky, to
  1771. continue processing: @command{tar} then aborts processing immediately.
  1772. All abnormal exits, whether immediate or delayed, should always be
  1773. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1774. the error.
  1775. @GNUTAR{} returns only a few exit statuses. I'm really
  1776. aiming simplicity in that area, for now. If you are not using the
  1777. @value{op-compare} option, zero means that everything went well, besides
  1778. maybe innocuous warnings. Nonzero means that something went wrong.
  1779. Right now, as of today, ``nonzero'' is almost always 2, except for
  1780. remote operations, where it may be 128.
  1781. @node using tar options
  1782. @section Using @command{tar} Options
  1783. @GNUTAR{} has a total of eight operating modes which
  1784. allow you to perform a variety of tasks. You are required to choose
  1785. one operating mode each time you employ the @command{tar} program by
  1786. specifying one, and only one operation as an argument to the
  1787. @command{tar} command (two lists of four operations each may be found
  1788. at @ref{frequent operations} and @ref{Operations}). Depending on
  1789. circumstances, you may also wish to customize how the chosen operating
  1790. mode behaves. For example, you may wish to change the way the output
  1791. looks, or the format of the files that you wish to archive may require
  1792. you to do something special in order to make the archive look right.
  1793. You can customize and control @command{tar}'s performance by running
  1794. @command{tar} with one or more options (such as @value{op-verbose}, which
  1795. we used in the tutorial). As we said in the tutorial, @dfn{options} are
  1796. arguments to @command{tar} which are (as their name suggests) optional.
  1797. Depending on the operating mode, you may specify one or more options.
  1798. Different options will have different effects, but in general they all
  1799. change details of the operation, such as archive format, archive name,
  1800. or level of user interaction. Some options make sense with all
  1801. operating modes, while others are meaningful only with particular modes.
  1802. You will likely use some options frequently, while you will only use
  1803. others infrequently, or not at all. (A full list of options is
  1804. available in @pxref{All Options}.)
  1805. The @env{TAR_OPTIONS} environment variable specifies default options to
  1806. be placed in front of any explicit options. For example, if
  1807. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1808. if the two options @option{-v} and @option{--unlink-first} had been
  1809. specified before any explicit options. Option specifications are
  1810. separated by whitespace. A backslash escapes the next character, so it
  1811. can be used to specify an option containing whitespace or a backslash.
  1812. Note that @command{tar} options are case sensitive. For example, the
  1813. options @samp{-T} and @samp{-t} are different; the first requires an
  1814. argument for stating the name of a file providing a list of @var{name}s,
  1815. while the second does not require an argument and is another way to
  1816. write @value{op-list}.
  1817. In addition to the eight operations, there are many options to
  1818. @command{tar}, and three different styles for writing both: long (mnemonic)
  1819. form, short form, and old style. These styles are discussed below.
  1820. Both the options and the operations can be written in any of these three
  1821. styles.
  1822. @FIXME{menu at end of this node. need to think of an actual outline
  1823. for this chapter; probably do that after stuff from chap. 4 is
  1824. incorporated.}
  1825. @node Styles
  1826. @section The Three Option Styles
  1827. There are three styles for writing operations and options to the command
  1828. line invoking @command{tar}. The different styles were developed at
  1829. different times during the history of @command{tar}. These styles will be
  1830. presented below, from the most recent to the oldest.
  1831. Some options must take an argument. (For example, @value{op-file} takes
  1832. the name of an archive file as an argument. If you do not supply an
  1833. archive file name, @command{tar} will use a default, but this can be
  1834. confusing; thus, we recommend that you always supply a specific archive
  1835. file name.) Where you @emph{place} the arguments generally depends on
  1836. which style of options you choose. We will detail specific information
  1837. relevant to each option style in the sections on the different option
  1838. styles, below. The differences are subtle, yet can often be very
  1839. important; incorrect option placement can cause you to overwrite a
  1840. number of important files. We urge you to note these differences, and
  1841. only use the option style(s) which makes the most sense to you until you
  1842. feel comfortable with the others.
  1843. @FIXME{hag to write a brief paragraph on the option(s) which can
  1844. optionally take an argument}
  1845. @menu
  1846. * Mnemonic Options:: Mnemonic Option Style
  1847. * Short Options:: Short Option Style
  1848. * Old Options:: Old Option Style
  1849. * Mixing:: Mixing Option Styles
  1850. @end menu
  1851. @node Mnemonic Options
  1852. @subsection Mnemonic Option Style
  1853. @FIXME{have to decide whether or not to replace other occurrences of
  1854. "mnemonic" with "long", or *ugh* vice versa.}
  1855. Each option has at least one long (or mnemonic) name starting with two
  1856. dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
  1857. their corresponding short or old names. It sometimes happens that a
  1858. single mnemonic option has many different different names which are
  1859. synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
  1860. long option names can be given unique abbreviations. For example,
  1861. @samp{--cre} can be used in place of @samp{--create} because there is no
  1862. other mnemonic option which begins with @samp{cre}. (One way to find
  1863. this out is by trying it and seeing what happens; if a particular
  1864. abbreviation could represent more than one option, @command{tar} will tell
  1865. you that that abbreviation is ambiguous and you'll know that that
  1866. abbreviation won't work. You may also choose to run @samp{tar --help}
  1867. to see a list of options. Be aware that if you run @command{tar} with a
  1868. unique abbreviation for the long name of an option you didn't want to
  1869. use, you are stuck; @command{tar} will perform the command as ordered.)
  1870. Mnemonic options are meant to be obvious and easy to remember, and their
  1871. meanings are generally easier to discern than those of their
  1872. corresponding short options (see below). For example:
  1873. @smallexample
  1874. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1875. @end smallexample
  1876. @noindent
  1877. gives a fairly good set of hints about what the command does, even
  1878. for those not fully acquainted with @command{tar}.
  1879. Mnemonic options which require arguments take those arguments
  1880. immediately following the option name; they are introduced by an equal
  1881. sign. For example, the @samp{--file} option (which tells the name
  1882. of the @command{tar} archive) is given a file such as @file{archive.tar}
  1883. as argument by using the notation @samp{--file=archive.tar} for the
  1884. mnemonic option.
  1885. @node Short Options
  1886. @subsection Short Option Style
  1887. Most options also have a short option name. Short options start with
  1888. a single dash, and are followed by a single character, e.g.@: @samp{-t}
  1889. (which is equivalent to @samp{--list}). The forms are absolutely
  1890. identical in function; they are interchangeable.
  1891. The short option names are faster to type than long option names.
  1892. Short options which require arguments take their arguments immediately
  1893. following the option, usually separated by white space. It is also
  1894. possible to stick the argument right after the short option name, using
  1895. no intervening space. For example, you might write @w{@samp{-f
  1896. archive.tar}} or @samp{-farchive.tar} instead of using
  1897. @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
  1898. @w{@samp{-f @var{archive-name}}} denote the option which indicates a
  1899. specific archive, here named @file{archive.tar}.
  1900. Short options' letters may be clumped together, but you are not
  1901. required to do this (as compared to old options; see below). When
  1902. short options are clumped as a set, use one (single) dash for them
  1903. all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
  1904. such a set is allowed to have an argument@footnote{Clustering many
  1905. options, the last of which has an argument, is a rather opaque way to
  1906. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1907. even be made helpful enough for considering such usages as invalid.}.
  1908. When the options are separated, the argument for each option which requires
  1909. an argument directly follows that option, as is usual for Unix programs.
  1910. For example:
  1911. @smallexample
  1912. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1913. @end smallexample
  1914. If you reorder short options' locations, be sure to move any arguments
  1915. that belong to them. If you do not move the arguments properly, you may
  1916. end up overwriting files.
  1917. @node Old Options
  1918. @subsection Old Option Style
  1919. @UNREVISED
  1920. Like short options, old options are single letters. However, old options
  1921. must be written together as a single clumped set, without spaces separating
  1922. them or dashes preceding them@footnote{Beware that if you precede options
  1923. with a dash, you are announcing the short option style instead of the
  1924. old option style; short options are decoded differently.}. This set
  1925. of letters must be the first to appear on the command line, after the
  1926. @command{tar} program name and some white space; old options cannot appear
  1927. anywhere else. The letter of an old option is exactly the same letter as
  1928. the corresponding short option. For example, the old option @samp{t} is
  1929. the same as the short option @samp{-t}, and consequently, the same as the
  1930. mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
  1931. cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
  1932. @FIXME{bob suggests having an uglier example. :-) }
  1933. When options that need arguments are given together with the command,
  1934. all the associated arguments follow, in the same order as the options.
  1935. Thus, the example given previously could also be written in the old
  1936. style as follows:
  1937. @smallexample
  1938. $ @kbd{tar cvbf 20 /dev/rmt0}
  1939. @end smallexample
  1940. @noindent
  1941. Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
  1942. the argument of @samp{-f}.
  1943. On the other hand, this old style syntax makes it difficult to match
  1944. option letters with their corresponding arguments, and is often
  1945. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1946. @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
  1947. argument for @samp{-f}, and @samp{-v} does not have a corresponding
  1948. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1949. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1950. pertain to.
  1951. If you want to reorder the letters in the old option argument, be
  1952. sure to reorder any corresponding argument appropriately.
  1953. This old way of writing @command{tar} options can surprise even experienced
  1954. users. For example, the two commands:
  1955. @smallexample
  1956. @kbd{tar cfz archive.tar.gz file}
  1957. @kbd{tar -cfz archive.tar.gz file}
  1958. @end smallexample
  1959. @noindent
  1960. are quite different. The first example uses @file{archive.tar.gz} as
  1961. the value for option @samp{f} and recognizes the option @samp{z}. The
  1962. second example, however, uses @file{z} as the value for option
  1963. @samp{f}---probably not what was intended.
  1964. Old options are kept for compatibility with old versions of @command{tar}.
  1965. This second example could be corrected in many ways, among which the
  1966. following are equivalent:
  1967. @smallexample
  1968. @kbd{tar -czf archive.tar.gz file}
  1969. @kbd{tar -cf archive.tar.gz -z file}
  1970. @kbd{tar cf archive.tar.gz -z file}
  1971. @end smallexample
  1972. @FIXME{still could explain this better; it's redundant:}
  1973. @cindex option syntax, traditional
  1974. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1975. non-@acronym{GNU}, support old options. @GNUTAR{}
  1976. supports them not only for historical reasons, but also because many
  1977. people are used to them. For compatibility with Unix @command{tar},
  1978. the first argument is always treated as containing command and option
  1979. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1980. equivalent to @w{@samp{tar -c}:} both of them specify the
  1981. @value{op-create} command to create an archive.
  1982. @node Mixing
  1983. @subsection Mixing Option Styles
  1984. All three styles may be intermixed in a single @command{tar} command,
  1985. so long as the rules for each style are fully
  1986. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1987. a bug prevented intermixing old style options with mnemonic options in
  1988. some cases.}. Old style options and either of the modern styles of
  1989. options may be mixed within a single @command{tar} command. However,
  1990. old style options must be introduced as the first arguments only,
  1991. following the rule for old options (old options must appear directly
  1992. after the @command{tar} command and some white space). Modern options
  1993. may be given only after all arguments to the old options have been
  1994. collected. If this rule is not respected, a modern option might be
  1995. falsely interpreted as the value of the argument to one of the old
  1996. style options.
  1997. For example, all the following commands are wholly equivalent, and
  1998. illustrate the many combinations and orderings of option styles.
  1999. @smallexample
  2000. @kbd{tar --create --file=archive.tar}
  2001. @kbd{tar --create -f archive.tar}
  2002. @kbd{tar --create -farchive.tar}
  2003. @kbd{tar --file=archive.tar --create}
  2004. @kbd{tar --file=archive.tar -c}
  2005. @kbd{tar -c --file=archive.tar}
  2006. @kbd{tar -c -f archive.tar}
  2007. @kbd{tar -c -farchive.tar}
  2008. @kbd{tar -cf archive.tar}
  2009. @kbd{tar -cfarchive.tar}
  2010. @kbd{tar -f archive.tar --create}
  2011. @kbd{tar -f archive.tar -c}
  2012. @kbd{tar -farchive.tar --create}
  2013. @kbd{tar -farchive.tar -c}
  2014. @kbd{tar c --file=archive.tar}
  2015. @kbd{tar c -f archive.tar}
  2016. @kbd{tar c -farchive.tar}
  2017. @kbd{tar cf archive.tar}
  2018. @kbd{tar f archive.tar --create}
  2019. @kbd{tar f archive.tar -c}
  2020. @kbd{tar fc archive.tar}
  2021. @end smallexample
  2022. On the other hand, the following commands are @emph{not} equivalent to
  2023. the previous set:
  2024. @smallexample
  2025. @kbd{tar -f -c archive.tar}
  2026. @kbd{tar -fc archive.tar}
  2027. @kbd{tar -fcarchive.tar}
  2028. @kbd{tar -farchive.tarc}
  2029. @kbd{tar cfarchive.tar}
  2030. @end smallexample
  2031. @noindent
  2032. These last examples mean something completely different from what the
  2033. user intended (judging based on the example in the previous set which
  2034. uses long options, whose intent is therefore very clear). The first
  2035. four specify that the @command{tar} archive would be a file named
  2036. @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  2037. respectively. The first two examples also specify a single non-option,
  2038. @var{name} argument having the value @samp{archive.tar}. The last
  2039. example contains only old style option letters (repeating option
  2040. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  2041. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  2042. the first sentence of this paragraph..}
  2043. @node All Options
  2044. @section All @command{tar} Options
  2045. The coming manual sections contain an alphabetical listing of all
  2046. @command{tar} operations and options, with brief descriptions and cross
  2047. references to more in-depth explanations in the body of the manual.
  2048. They also contain an alphabetically arranged table of the short option
  2049. forms with their corresponding long option. You can use this table as
  2050. a reference for deciphering @command{tar} commands in scripts.
  2051. @menu
  2052. * Operation Summary::
  2053. * Option Summary::
  2054. * Short Option Summary::
  2055. @end menu
  2056. @node Operation Summary
  2057. @subsection Operations
  2058. @table @kbd
  2059. @item --append
  2060. @itemx -r
  2061. Appends files to the end of the archive. @xref{append}.
  2062. @item --catenate
  2063. @itemx -A
  2064. Same as @samp{--concatenate}. @xref{concatenate}.
  2065. @item --compare
  2066. @itemx -d
  2067. Compares archive members with their counterparts in the file
  2068. system, and reports differences in file size, mode, owner,
  2069. modification date and contents. @xref{compare}.
  2070. @item --concatenate
  2071. @itemx -A
  2072. Appends other @command{tar} archives to the end of the archive.
  2073. @xref{concatenate}.
  2074. @item --create
  2075. @itemx -c
  2076. Creates a new @command{tar} archive. @xref{create}.
  2077. @item --delete
  2078. Deletes members from the archive. Don't try this on a archive on a
  2079. tape! @xref{delete}.
  2080. @item --diff
  2081. @itemx -d
  2082. Same @samp{--compare}. @xref{compare}.
  2083. @item --extract
  2084. @itemx -x
  2085. Extracts members from the archive into the file system. @xref{extract}.
  2086. @item --get
  2087. @itemx -x
  2088. Same as @samp{--extract}. @xref{extract}.
  2089. @item --list
  2090. @itemx -t
  2091. Lists the members in an archive. @xref{list}.
  2092. @item --update
  2093. @itemx -u
  2094. @FIXME{It was: A combination of the @samp{--compare} and
  2095. @samp{--append} operations. This is not true and rather misleading,
  2096. as @value{op-compare} does a lot more than @value{op-update} for
  2097. ensuring files are identical.} Adds files to the end of the archive,
  2098. but only if they are newer than their counterparts already in the
  2099. archive, or if they do not already exist in the archive.
  2100. @xref{update}.
  2101. @end table
  2102. @node Option Summary
  2103. @subsection @command{tar} Options
  2104. @table @kbd
  2105. @item --absolute-names
  2106. @itemx -P
  2107. Normally when creating an archive, @command{tar} strips an initial
  2108. @samp{/} from member names. This option disables that behavior.
  2109. @FIXME-xref{}
  2110. @item --after-date
  2111. (See @samp{--newer}.) @FIXME-pxref{}
  2112. @item --anchored
  2113. An exclude pattern must match an initial subsequence of the name's components.
  2114. @FIXME-xref{}
  2115. @item --atime-preserve
  2116. Tells @command{tar} to preserve the access time field in a file's inode when
  2117. reading it. Due to limitations in the @code{utimes} system call, the
  2118. modification time field is also preserved, which may cause problems if
  2119. the file is simultaneously being modified by another program.
  2120. This option is incompatible with incremental backups, because
  2121. preserving the access time involves updating the last-changed time.
  2122. Also, this option does not work on files that you do not own,
  2123. unless you're root.
  2124. @FIXME-xref{}
  2125. @item --backup=@var{backup-type}
  2126. Rather than deleting files from the file system, @command{tar} will
  2127. back them up using simple or numbered backups, depending upon
  2128. @var{backup-type}. @FIXME-xref{}
  2129. @item --block-number
  2130. @itemx -R
  2131. With this option present, @command{tar} prints error messages for read errors
  2132. with the block number in the archive file. @FIXME-xref{}
  2133. @item --blocking-factor=@var{blocking}
  2134. @itemx -b @var{blocking}
  2135. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  2136. record. @FIXME-xref{}
  2137. @item --bzip2
  2138. @itemx -j
  2139. This option tells @command{tar} to read or write archives through
  2140. @code{bzip2}. @FIXME-xref{}
  2141. @item --checkpoint
  2142. This option directs @command{tar} to print periodic checkpoint messages as it
  2143. reads through the archive. Its intended for when you want a visual
  2144. indication that @command{tar} is still running, but don't want to see
  2145. @samp{--verbose} output. @FIXME-xref{}
  2146. @item --check-links
  2147. @itemx -l
  2148. If this option was given, @command{tar} will check the number of links
  2149. dumped for each processed file. If this number does not match the
  2150. total number of hard links for the file, a warning message will be
  2151. output.
  2152. Future versions will take @option{-l} as a short version of
  2153. @option{--check-links}. However, current release still retains the old
  2154. semantics for @option{-l}.
  2155. @xref{Current status}, for more information.
  2156. @item --compress
  2157. @itemx --uncompress
  2158. @itemx -Z
  2159. @command{tar} will use the @command{compress} program when reading or
  2160. writing the archive. This allows you to directly act on archives
  2161. while saving space. @FIXME-xref{}
  2162. @item --confirmation
  2163. (See @samp{--interactive}.) @FIXME-pxref{}
  2164. @item --dereference
  2165. @itemx -h
  2166. When creating a @command{tar} archive, @command{tar} will archive the
  2167. file that a symbolic link points to, rather than archiving the
  2168. symlink. @FIXME-xref{}
  2169. @item --directory=@var{dir}
  2170. @itemx -C @var{dir}
  2171. When this option is specified, @command{tar} will change its current directory
  2172. to @var{dir} before performing any operations. When this option is used
  2173. during archive creation, it is order sensitive. @FIXME-xref{}
  2174. @item --exclude=@var{pattern}
  2175. When performing operations, @command{tar} will skip files that match
  2176. @var{pattern}. @FIXME-xref{}
  2177. @item --exclude-from=@var{file}
  2178. @itemx -X @var{file}
  2179. Similar to @samp{--exclude}, except @command{tar} will use the list of
  2180. patterns in the file @var{file}. @FIXME-xref{}
  2181. @item --file=@var{archive}
  2182. @itemx -f @var{archive}
  2183. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  2184. performs operations on, rather than @command{tar}'s compilation dependent
  2185. default. @FIXME-xref{}
  2186. @item --files-from=@var{file}
  2187. @itemx -T @var{file}
  2188. @command{tar} will use the contents of @var{file} as a list of archive members
  2189. or files to operate on, in addition to those specified on the
  2190. command-line. @FIXME-xref{}
  2191. @item --force-local
  2192. Forces @command{tar} to interpret the filename given to @samp{--file}
  2193. as a local file, even if it looks like a remote tape drive name.
  2194. @FIXME-xref{}
  2195. @item --format=@var{format}
  2196. Selects output archive format. @var{Format} may be one of the
  2197. following:
  2198. @table @samp
  2199. @item v7
  2200. Creates an archive that is compatible with Unix V7 @command{tar}.
  2201. @item oldgnu
  2202. Creates an archive that is compatible with GNU @command{tar} version
  2203. 1.12 or earlier.
  2204. @item ustar
  2205. Creates a POSIX.1-1988 compatible archive.
  2206. @item posix
  2207. Creates a POSIX.1-2001 archive.
  2208. @item gnu
  2209. Creates archive in GNU format.
  2210. @end table
  2211. @item --group=@var{group}
  2212. Files added to the @command{tar} archive will have a group id of @var{group},
  2213. rather than the group from the source file. @var{group} is first decoded
  2214. as a group symbolic name, but if this interpretation fails, it has to be
  2215. a decimal numeric group ID. @FIXME-xref{}
  2216. Also see the comments for the @value{op-owner} option.
  2217. @item --gzip
  2218. @itemx --gunzip
  2219. @itemx --ungzip
  2220. @itemx -z
  2221. This option tells @command{tar} to read or write archives through
  2222. @command{gzip}, allowing @command{tar} to directly operate on several
  2223. kinds of compressed archives transparently. @FIXME-xref{}
  2224. @item --help
  2225. @command{tar} will print out a short message summarizing the operations and
  2226. options to @command{tar} and exit. @FIXME-xref{}
  2227. @item --ignore-case
  2228. Ignore case when excluding files.
  2229. @FIXME-xref{}
  2230. @item --ignore-failed-read
  2231. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2232. @xref{Reading}.
  2233. @item --ignore-zeros
  2234. @itemx -i
  2235. With this option, @command{tar} will ignore zeroed blocks in the
  2236. archive, which normally signals EOF. @xref{Reading}.
  2237. @item --incremental
  2238. @itemx -G
  2239. Used to inform @command{tar} that it is working with an old
  2240. @acronym{GNU}-format incremental backup archive. It is intended
  2241. primarily for backwards compatibility only. @FIXME-xref{}
  2242. @item --index-file=@var{file}
  2243. Send verbose output to @var{file} instead of to standard output.
  2244. @item --info-script=@var{script-file}
  2245. @itemx --new-volume-script=@var{script-file}
  2246. @itemx -F @var{script-file}
  2247. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2248. at the end of each tape. If @var{script-file} exits with nonzero status,
  2249. @command{tar} fails immediately. @FIXME-xref{}
  2250. @item --interactive
  2251. @itemx --confirmation
  2252. @itemx -w
  2253. Specifies that @command{tar} should ask the user for confirmation before
  2254. performing potentially destructive options, such as overwriting files.
  2255. @FIXME-xref{}
  2256. @item --keep-old-files
  2257. @itemx -k
  2258. Do not overwrite existing files when extracting files from an archive.
  2259. @xref{Writing}.
  2260. @item --label=@var{name}
  2261. @itemx -V @var{name}
  2262. When creating an archive, instructs @command{tar} to write @var{name}
  2263. as a name record in the archive. When extracting or listing archives,
  2264. @command{tar} will only operate on archives that have a label matching
  2265. the pattern specified in @var{name}. @FIXME-xref{}
  2266. @item --listed-incremental=@var{snapshot-file}
  2267. @itemx -g @var{snapshot-file}
  2268. During a @samp{--create} operation, specifies that the archive that
  2269. @command{tar} creates is a new @acronym{GNU}-format incremental
  2270. backup, using @var{snapshot-file} to determine which files to backup.
  2271. With other operations, informs @command{tar} that the archive is in
  2272. incremental format. @FIXME-xref{}
  2273. @item --mode=@var{permissions}
  2274. When adding files to an archive, @command{tar} will use
  2275. @var{permissions} for the archive members, rather than the permissions
  2276. from the files. The program @command{chmod} and this @command{tar}
  2277. option share the same syntax for what @var{permissions} might be.
  2278. @xref{File permissions, Permissions, File permissions, fileutils,
  2279. @acronym{GNU} file utilities}. This reference also has useful
  2280. information for those not being overly familiar with the Unix
  2281. permission system.
  2282. Of course, @var{permissions} might be plainly specified as an octal number.
  2283. However, by using generic symbolic modifications to mode bits, this allows
  2284. more flexibility. For example, the value @samp{a+rw} adds read and write
  2285. permissions for everybody, while retaining executable bits on directories
  2286. or on any other file already marked as executable.
  2287. @item --multi-volume
  2288. @itemx -M
  2289. Informs @command{tar} that it should create or otherwise operate on a
  2290. multi-volume @command{tar} archive. @FIXME-xref{}
  2291. @item --new-volume-script
  2292. (see --info-script)
  2293. @item --newer=@var{date}
  2294. @itemx --after-date=@var{date}
  2295. @itemx -N
  2296. When creating an archive, @command{tar} will only add files that have changed
  2297. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2298. is taken to be the name of a file whose last-modified time specifies
  2299. the date. @FIXME-xref{}
  2300. @item --newer-mtime=@var{date}
  2301. Like @samp{--newer}, but add only files whose
  2302. contents have changed (as opposed to just @samp{--newer}, which will
  2303. also back up files for which any status information has changed).
  2304. @item --no-anchored
  2305. An exclude pattern can match any subsequence of the name's components.
  2306. @FIXME-xref{}
  2307. @item --no-ignore-case
  2308. Use case-sensitive matching when excluding files.
  2309. @FIXME-xref{}
  2310. @item --no-recursion
  2311. With this option, @command{tar} will not recurse into directories.
  2312. @FIXME-xref{}
  2313. @item --no-same-owner
  2314. @itemx -o
  2315. When extracting an archive, do not attempt to preserve the owner
  2316. specified in the @command{tar} archive. This the default behavior
  2317. for ordinary users; this option has an effect only for the superuser.
  2318. @item --no-same-permissions
  2319. When extracting an archive, subtract the user's umask from files from
  2320. the permissions specified in the archive. This is the default behavior
  2321. for ordinary users; this option has an effect only for the superuser.
  2322. @item --no-wildcards
  2323. Do not use wildcards when excluding files.
  2324. @FIXME-xref{}
  2325. @item --no-wildcards-match-slash
  2326. Wildcards do not match @samp{/} when excluding files.
  2327. @FIXME-xref{}
  2328. @item --null
  2329. When @command{tar} is using the @samp{--files-from} option, this option
  2330. instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
  2331. @command{tar} can correctly work with file names that contain newlines.
  2332. @FIXME-xref{}
  2333. @item --numeric-owner
  2334. This option will notify @command{tar} that it should use numeric user
  2335. and group IDs when creating a @command{tar} file, rather than names.
  2336. @FIXME-xref{}
  2337. @item -o
  2338. When extracting files, this option is a synonym for
  2339. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2340. restoring ownership of files being extracted.
  2341. When creating an archive, @option{-o} is a synonym for
  2342. @option{--old-archive}. This behavior is for compatibility
  2343. with previous versions of @GNUTAR{}, and will be
  2344. removed in the future releases.
  2345. @xref{Current status}, for more information.
  2346. @item --occurrence[=@var{number}]
  2347. This option can be used in conjunction with one of the subcommands
  2348. @option{--delete}, @option{--diff}, @option{--extract} or
  2349. @option{--list} when a list of files is given either on the command
  2350. line or via @option{-T} option.
  2351. This option instructs @command{tar} to process only the @var{number}th
  2352. occurrence of each named file. @var{Number} defaults to 1, so
  2353. @smallexample
  2354. tar -x -f archive.tar --occurrence filename
  2355. @end smallexample
  2356. @noindent
  2357. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2358. and will terminate without scanning to the end of the archive.
  2359. @item --old-archive
  2360. Synonym for @option{--format=v7}.
  2361. @item --one-file-system
  2362. @itemx -l
  2363. Used when creating an archive. Prevents @command{tar} from recursing into
  2364. directories that are on different file systems from the current
  2365. directory.
  2366. Earlier versions of @GNUTAR{} understood @option{-l} as a
  2367. synonym for @option{--one-file-system}. Although such usage is still
  2368. allowed in the present version, it is @emph{strongly discouraged}.
  2369. The future versions of @GNUTAR{} will use @option{-l} as
  2370. a synonym for @option{--check-links}.
  2371. @xref{Current status}, for more information.
  2372. @item --overwrite
  2373. Overwrite existing files and directory metadata when extracting files
  2374. from an archive. @xref{Overwrite Old Files}.
  2375. @item --overwrite-dir
  2376. Overwrite the metadata of existing directories when extracting files
  2377. from an archive. @xref{Overwrite Old Files}.
  2378. @item --owner=@var{user}
  2379. Specifies that @command{tar} should use @var{user} as the owner of members
  2380. when creating archives, instead of the user associated with the source
  2381. file. @var{user} is first decoded as a user symbolic name, but if
  2382. this interpretation fails, it has to be a decimal numeric user ID.
  2383. @FIXME-xref{}
  2384. There is no value indicating a missing number, and @samp{0} usually means
  2385. @code{root}. Some people like to force @samp{0} as the value to offer in
  2386. their distributions for the owner of files, because the @code{root} user is
  2387. anonymous anyway, so that might as well be the owner of anonymous archives.
  2388. This option does not affect extraction from archives.
  2389. @item --portability
  2390. @itemx --old-archive
  2391. Synonym for @option{--format=v7}.
  2392. @item --posix
  2393. Same as @option{--format=posix}.
  2394. @item --preserve
  2395. Synonymous with specifying both @samp{--preserve-permissions} and
  2396. @samp{--same-order}. @FIXME-xref{}
  2397. @item --preserve-order
  2398. (See @samp{--same-order}; @pxref{Reading}.)
  2399. @item --preserve-permissions
  2400. @itemx --same-permissions
  2401. @itemx -p
  2402. When @command{tar} is extracting an archive, it normally subtracts the
  2403. users' umask from the permissions specified in the archive and uses
  2404. that number as the permissions to create the destination file.
  2405. Specifying this option instructs @command{tar} that it should use the
  2406. permissions directly from the archive. @xref{Writing}.
  2407. @item --read-full-records
  2408. @itemx -B
  2409. Specifies that @command{tar} should reblock its input, for reading
  2410. from pipes on systems with buggy implementations. @xref{Reading}.
  2411. @item --record-size=@var{size}
  2412. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2413. archive. @FIXME-xref{}
  2414. @item --recursion
  2415. With this option, @command{tar} recurses into directories.
  2416. @FIXME-xref{}
  2417. @item --recursive-unlink
  2418. Remove existing
  2419. directory hierarchies before extracting directories of the same name
  2420. from the archive. @xref{Writing}.
  2421. @item --remove-files
  2422. Directs @command{tar} to remove the source file from the file system after
  2423. appending it to an archive. @FIXME-xref{}
  2424. @item --rsh-command=@var{cmd}
  2425. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2426. devices. @FIXME-xref{}
  2427. @item --same-order
  2428. @itemx --preserve-order
  2429. @itemx -s
  2430. This option is an optimization for @command{tar} when running on machines with
  2431. small amounts of memory. It informs @command{tar} that the list of file
  2432. arguments has already been sorted to match the order of files in the
  2433. archive. @xref{Reading}.
  2434. @item --same-owner
  2435. When extracting an archive, @command{tar} will attempt to preserve the owner
  2436. specified in the @command{tar} archive with this option present.
  2437. This is the default behavior for the superuser; this option has an
  2438. effect only for ordinary users. @FIXME-xref{}
  2439. @item --same-permissions
  2440. (See @samp{--preserve-permissions}; @pxref{Writing}.)
  2441. @item --show-omitted-dirs
  2442. Instructs @command{tar} to mention directories its skipping over when
  2443. operating on a @command{tar} archive. @FIXME-xref{}
  2444. @item --sparse
  2445. @itemx -S
  2446. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2447. sparse files efficiently. @FIXME-xref{}
  2448. @item --starting-file=@var{name}
  2449. @itemx -K @var{name}
  2450. This option affects extraction only; @command{tar} will skip extracting
  2451. files in the archive until it finds one that matches @var{name}.
  2452. @xref{Scarce}.
  2453. @item --strip-path=@var{number}
  2454. Strip given @var{number} of leading components from file names before
  2455. extraction. For example, if archive @file{archive.tar} contained
  2456. @file{/some/file/name}, then running
  2457. @smallexample
  2458. tar --extract --file archive.tar --strip-path=2
  2459. @end smallexample
  2460. @noindent
  2461. would extracted this file to file @file{name}.
  2462. @item --suffix=@var{suffix}
  2463. Alters the suffix @command{tar} uses when backing up files from the default
  2464. @samp{~}. @FIXME-xref{}
  2465. @item --tape-length=@var{num}
  2466. @itemx -L @var{num}
  2467. Specifies the length of tapes that @command{tar} is writing as being
  2468. @w{@var{num} x 1024} bytes long. @FIXME-xref{}
  2469. @item --to-stdout
  2470. @itemx -O
  2471. During extraction, @command{tar} will extract files to stdout rather
  2472. than to the file system. @xref{Writing}.
  2473. @item --totals
  2474. Displays the total number of bytes written after creating an archive.
  2475. @FIXME-xref{}
  2476. @item --touch
  2477. @itemx -m
  2478. Sets the modification time of extracted files to the extraction time,
  2479. rather than the modification time stored in the archive.
  2480. @xref{Writing}.
  2481. @item --uncompress
  2482. (See @samp{--compress}.) @FIXME-pxref{}
  2483. @item --ungzip
  2484. (See @samp{--gzip}.) @FIXME-pxref{}
  2485. @item --unlink-first
  2486. @itemx -U
  2487. Directs @command{tar} to remove the corresponding file from the file
  2488. system before extracting it from the archive. @xref{Writing}.
  2489. @item --use-compress-program=@var{prog}
  2490. Instructs @command{tar} to access the archive through @var{prog}, which is
  2491. presumed to be a compression program of some sort. @FIXME-xref{}
  2492. @item --verbose
  2493. @itemx -v
  2494. Specifies that @command{tar} should be more verbose about the operations its
  2495. performing. This option can be specified multiple times for some
  2496. operations to increase the amount of information displayed. @FIXME-xref{}
  2497. @item --verify
  2498. @itemx -W
  2499. Verifies that the archive was correctly written when creating an
  2500. archive. @FIXME-xref{}
  2501. @item --version
  2502. @command{tar} will print an informational message about what version
  2503. it is and a copyright message, some credits, and then exit.
  2504. @FIXME-xref{}
  2505. @item --volno-file=@var{file}
  2506. Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
  2507. of which volume of a multi-volume archive its working in @var{file}.
  2508. @FIXME-xref{}
  2509. @item --wildcards
  2510. Use wildcards when excluding files.
  2511. @FIXME-xref{}
  2512. @item --wildcards-match-slash
  2513. Wildcards match @samp{/} when excluding files.
  2514. @FIXME-xref{}
  2515. @end table
  2516. @node Short Option Summary
  2517. @subsection Short Options Cross Reference
  2518. Here is an alphabetized list of all of the short option forms, matching
  2519. them with the equivalent long option.
  2520. @table @kbd
  2521. @item -A
  2522. @samp{--concatenate}
  2523. @item -B
  2524. @samp{--read-full-records}
  2525. @item -C
  2526. @samp{--directory}
  2527. @item -F
  2528. @samp{--info-script}
  2529. @item -G
  2530. @samp{--incremental}
  2531. @item -K
  2532. @samp{--starting-file}
  2533. @item -L
  2534. @samp{--tape-length}
  2535. @item -M
  2536. @samp{--multi-volume}
  2537. @item -N
  2538. @samp{--newer}
  2539. @item -O
  2540. @samp{--to-stdout}
  2541. @item -P
  2542. @samp{--absolute-names}
  2543. @item -R
  2544. @samp{--block-number}
  2545. @item -S
  2546. @samp{--sparse}
  2547. @item -T
  2548. @samp{--files-from}
  2549. @item -U
  2550. @samp{--unlink-first}
  2551. @item -V
  2552. @samp{--label}
  2553. @item -W
  2554. @samp{--verify}
  2555. @item -X
  2556. @samp{--exclude-from}
  2557. @item -Z
  2558. @samp{--compress}
  2559. @item -b
  2560. @samp{--blocking-factor}
  2561. @item -c
  2562. @samp{--create}
  2563. @item -d
  2564. @samp{--compare}
  2565. @item -f
  2566. @samp{--file}
  2567. @item -g
  2568. @samp{--listed-incremental}
  2569. @item -h
  2570. @samp{--dereference}
  2571. @item -i
  2572. @samp{--ignore-zeros}
  2573. @item -j
  2574. @samp{--bzip2}
  2575. @item -k
  2576. @samp{--keep-old-files}
  2577. @item -l
  2578. @samp{--one-file-system}. Use of this short option is deprecated. It
  2579. is retained for compatibility with the earlier versions of GNU
  2580. @command{tar}, and will be changed in future releases.
  2581. @xref{Current status}, for more information.
  2582. @item -m
  2583. @samp{--touch}
  2584. @item -o
  2585. When creating --- @samp{--no-same-owner}, when extracting ---
  2586. @samp{--portability}.
  2587. The later usage is deprecated. It is retained for compatibility with
  2588. the earlier versions of @GNUTAR{}. In the future releases
  2589. @option{-o} will be equivalent to @samp{--no-same-owner} only.
  2590. @item -p
  2591. @samp{--preserve-permissions}
  2592. @item -r
  2593. @samp{--append}
  2594. @item -s
  2595. @samp{--same-order}
  2596. @item -t
  2597. @samp{--list}
  2598. @item -u
  2599. @samp{--update}
  2600. @item -v
  2601. @samp{--verbose}
  2602. @item -w
  2603. @samp{--interactive}
  2604. @item -x
  2605. @samp{--extract}
  2606. @item -z
  2607. @samp{--gzip}
  2608. @end table
  2609. @node help
  2610. @section @GNUTAR{} documentation
  2611. Being careful, the first thing is really checking that you are using
  2612. @GNUTAR{}, indeed. The @value{op-version} option
  2613. will generate a message giving confirmation that you are using
  2614. @GNUTAR{}, with the precise version of @GNUTAR{}
  2615. you are using. @command{tar} identifies itself and
  2616. prints the version number to the standard output, then immediately
  2617. exits successfully, without doing anything else, ignoring all other
  2618. options. For example, @w{@samp{tar --version}} might return:
  2619. @smallexample
  2620. tar (@acronym{GNU} tar) @value{VERSION}
  2621. @end smallexample
  2622. @noindent
  2623. The first occurrence of @samp{tar} in the result above is the program
  2624. name in the package (for example, @command{rmt} is another program),
  2625. while the second occurrence of @samp{tar} is the name of the package
  2626. itself, containing possibly many programs. The package is currently
  2627. named @samp{tar}, after the name of the main program it
  2628. contains@footnote{There are plans to merge the @command{cpio} and
  2629. @command{tar} packages into a single one which would be called
  2630. @code{paxutils}. So, who knows if, one of this days, the
  2631. @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
  2632. paxutils) 3.2}}}.
  2633. Another thing you might want to do is checking the spelling or meaning
  2634. of some particular @command{tar} option, without resorting to this
  2635. manual, for once you have carefully read it. @GNUTAR{}
  2636. has a short help feature, triggerable through the
  2637. @value{op-help} option. By using this option, @command{tar} will
  2638. print a usage message listing all available options on standard
  2639. output, then exit successfully, without doing anything else and
  2640. ignoring all other options. Even if this is only a brief summary, it
  2641. may be several screens long. So, if you are not using some kind of
  2642. scrollable window, you might prefer to use something like:
  2643. @smallexample
  2644. $ @kbd{tar --help | less}
  2645. @end smallexample
  2646. @noindent
  2647. presuming, here, that you like using @command{less} for a pager. Other
  2648. popular pagers are @command{more} and @command{pg}. If you know about some
  2649. @var{keyword} which interests you and do not want to read all the
  2650. @value{op-help} output, another common idiom is doing:
  2651. @smallexample
  2652. tar --help | grep @var{keyword}
  2653. @end smallexample
  2654. @noindent
  2655. for getting only the pertinent lines.
  2656. The perceptive reader would have noticed some contradiction in the
  2657. previous paragraphs. It is written that both @value{op-version} and
  2658. @value{op-help} print something, and have all other options ignored. In
  2659. fact, they cannot ignore each other, and one of them has to win. We do
  2660. not specify which is stronger, here; experiment if you really wonder!
  2661. The short help output is quite succinct, and you might have to get
  2662. back to the full documentation for precise points. If you are reading
  2663. this paragraph, you already have the @command{tar} manual in some
  2664. form. This manual is available in printed form, as a kind of small
  2665. book. It may printed out of the @GNUTAR{}
  2666. distribution, provided you have @TeX{} already installed somewhere,
  2667. and a laser printer around. Just configure the distribution, execute
  2668. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2669. usual way (contact your local guru to know how). If @GNUTAR{}
  2670. has been conveniently installed at your place, this
  2671. manual is also available in interactive, hypertextual form as an Info
  2672. file. Just call @w{@samp{info tar}} or, if you do not have the
  2673. @command{info} program handy, use the Info reader provided within
  2674. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2675. There is currently no @code{man} page for @GNUTAR{}.
  2676. If you observe such a @code{man} page on the system you are running,
  2677. either it does not long to @GNUTAR{}, or it has not
  2678. been produced by @acronym{GNU}. Currently, @GNUTAR{}
  2679. documentation is provided in Texinfo format only, if we
  2680. except, of course, the short result of @kbd{tar --help}.
  2681. @node verbose
  2682. @section Checking @command{tar} progress
  2683. @cindex Progress information
  2684. @cindex Status information
  2685. @cindex Information on progress and status of operations
  2686. @cindex Verbose operation
  2687. @cindex Block number where error occurred
  2688. @cindex Error message, block number of
  2689. @cindex Version of the @command{tar} program
  2690. @cindex Getting more information during the operation
  2691. @cindex Information during operation
  2692. @cindex Feedback from @command{tar}
  2693. Typically, @command{tar} performs most operations without reporting any
  2694. information to the user except error messages. When using @command{tar}
  2695. with many options, particularly ones with complicated or
  2696. difficult-to-predict behavior, it is possible to make serious mistakes.
  2697. @command{tar} provides several options that make observing @command{tar}
  2698. easier. These options cause @command{tar} to print information as it
  2699. progresses in its job, and you might want to use them just for being
  2700. more careful about what is going on, or merely for entertaining
  2701. yourself. If you have encountered a problem when operating on an
  2702. archive, however, you may need more information than just an error
  2703. message in order to solve the problem. The following options can be
  2704. helpful diagnostic tools.
  2705. Normally, the @value{op-list} command to list an archive prints just
  2706. the file names (one per line) and the other commands are silent.
  2707. When used with most operations, the @value{op-verbose} option causes
  2708. @command{tar} to print the name of each file or archive member as it
  2709. is processed. This and the other options which make @command{tar} print
  2710. status information can be useful in monitoring @command{tar}.
  2711. With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
  2712. just prints the names of the files or members as they are processed.
  2713. Using it twice causes @command{tar} to print a longer listing (reminiscent
  2714. of @samp{ls -l}) for each member. Since @value{op-list} already prints
  2715. the names of the members, @value{op-verbose} used once with @value{op-list}
  2716. causes @command{tar} to print an @samp{ls -l} type listing of the files
  2717. in the archive. The following examples both extract members with
  2718. long list output:
  2719. @smallexample
  2720. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2721. $ @kbd{tar xvv archive.tar}
  2722. @end smallexample
  2723. Verbose output appears on the standard output except when an archive is
  2724. being written to the standard output, as with @samp{tar --create
  2725. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2726. installer let standard output be the default archive). In that case
  2727. @command{tar} writes verbose output to the standard error stream.
  2728. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2729. verbose output to @var{file} rather than to standard output or standard
  2730. error.
  2731. The @value{op-totals} option---which is only meaningful when used with
  2732. @value{op-create}---causes @command{tar} to print the total
  2733. amount written to the archive, after it has been fully created.
  2734. The @value{op-checkpoint} option prints an occasional message
  2735. as @command{tar} reads or writes the archive. In fact, it print
  2736. directory names while reading the archive. It is designed for
  2737. those who don't need the more detailed (and voluminous) output of
  2738. @value{op-block-number}, but do want visual confirmation that @command{tar}
  2739. is actually making forward progress.
  2740. @FIXME{There is some confusion here. It seems that -R once wrote a
  2741. message at @samp{every} record read or written.}
  2742. The @value{op-show-omitted-dirs} option, when reading an archive---with
  2743. @value{op-list} or @value{op-extract}, for example---causes a message
  2744. to be printed for each directory in the archive which is skipped.
  2745. This happens regardless of the reason for skipping: the directory might
  2746. not have been named on the command line (implicitly or explicitly),
  2747. it might be excluded by the use of the @value{op-exclude} option, or
  2748. some other reason.
  2749. If @value{op-block-number} is used, @command{tar} prints, along with
  2750. every message it would normally produce, the block number within the
  2751. archive where the message was triggered. Also, supplementary messages
  2752. are triggered when reading blocks full of NULs, or when hitting end of
  2753. file on the archive. As of now, if the archive if properly terminated
  2754. with a NUL block, the reading of the file may stop before end of file
  2755. is met, so the position of end of file will not usually show when
  2756. @value{op-block-number} is used. Note that @GNUTAR{}
  2757. drains the archive before exiting when reading the
  2758. archive from a pipe.
  2759. This option is especially useful when reading damaged archives, since
  2760. it helps pinpoint the damaged sections. It can also be used with
  2761. @value{op-list} when listing a file-system backup tape, allowing you to
  2762. choose among several backup tapes when retrieving a file later, in
  2763. favor of the tape where the file appears earliest (closest to the
  2764. front of the tape). @FIXME-xref{when the node name is set and the
  2765. backup section written.}
  2766. @node interactive
  2767. @section Asking for Confirmation During Operations
  2768. @cindex Interactive operation
  2769. Typically, @command{tar} carries out a command without stopping for
  2770. further instructions. In some situations however, you may want to
  2771. exclude some files and archive members from the operation (for instance
  2772. if disk or storage space is tight). You can do this by excluding
  2773. certain files automatically (@pxref{Choosing}), or by performing
  2774. an operation interactively, using the @value{op-interactive} option.
  2775. @command{tar} also accepts @samp{--confirmation} for this option.
  2776. When the @value{op-interactive} option is specified, before
  2777. reading, writing, or deleting files, @command{tar} first prints a message
  2778. for each such file, telling what operation it intends to take, then asks
  2779. for confirmation on the terminal. The actions which require
  2780. confirmation include adding a file to the archive, extracting a file
  2781. from the archive, deleting a file from the archive, and deleting a file
  2782. from disk. To confirm the action, you must type a line of input
  2783. beginning with @samp{y}. If your input line begins with anything other
  2784. than @samp{y}, @command{tar} skips that file.
  2785. If @command{tar} is reading the archive from the standard input,
  2786. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2787. communications.
  2788. Verbose output is normally sent to standard output, separate from
  2789. other error messages. However, if the archive is produced directly
  2790. on standard output, then verbose output is mixed with errors on
  2791. @code{stderr}. Producing the archive on standard output may be used
  2792. as a way to avoid using disk space, when the archive is soon to be
  2793. consumed by another process reading it, say. Some people felt the need
  2794. of producing an archive on stdout, still willing to segregate between
  2795. verbose output and error output. A possible approach would be using a
  2796. named pipe to receive the archive, and having the consumer process to
  2797. read from that named pipe. This has the advantage of letting standard
  2798. output free to receive verbose output, all separate from errors.
  2799. @node operations
  2800. @chapter @GNUTAR{} Operations
  2801. @menu
  2802. * Basic tar::
  2803. * Advanced tar::
  2804. * create options::
  2805. * extract options::
  2806. * backup::
  2807. * Applications::
  2808. * looking ahead::
  2809. @end menu
  2810. @node Basic tar
  2811. @section Basic @GNUTAR{} Operations
  2812. The basic @command{tar} operations, @value{op-create}, @value{op-list} and
  2813. @value{op-extract}, are currently presented and described in the tutorial
  2814. chapter of this manual. This section provides some complementary notes
  2815. for these operations.
  2816. @table @asis
  2817. @item @value{op-create}
  2818. Creating an empty archive would have some kind of elegance. One can
  2819. initialize an empty archive and later use @value{op-append} for adding
  2820. all members. Some applications would not welcome making an exception
  2821. in the way of adding the first archive member. On the other hand,
  2822. many people reported that it is dangerously too easy for @command{tar}
  2823. to destroy a magnetic tape with an empty archive@footnote{This is well
  2824. described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
  2825. Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
  2826. common errors are:
  2827. @enumerate
  2828. @item
  2829. Mistakingly using @code{create} instead of @code{extract}, when the
  2830. intent was to extract the full contents of an archive. This error
  2831. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2832. the QWERTY keyboard. Instead of being unpacked, the archive then
  2833. gets wholly destroyed. When users speak about @dfn{exploding} an
  2834. archive, they usually mean something else :-).
  2835. @item
  2836. Forgetting the argument to @code{file}, when the intent was to create
  2837. an archive with a single file in it. This error is likely because a
  2838. tired user can easily add the @kbd{f} key to the cluster of option
  2839. letters, by the mere force of habit, without realizing the full
  2840. consequence of doing so. The usual consequence is that the single
  2841. file, which was meant to be saved, is rather destroyed.
  2842. @end enumerate
  2843. So, recognizing the likelihood and the catastrophical nature of these
  2844. errors, @GNUTAR{} now takes some distance from elegance, and
  2845. cowardly refuses to create an archive when @value{op-create} option is
  2846. given, there are no arguments besides options, and @value{op-files-from}
  2847. option is @emph{not} used. To get around the cautiousness of @GNUTAR{}
  2848. and nevertheless create an archive with nothing in it,
  2849. one may still use, as the value for the @value{op-files-from} option,
  2850. a file with no names in it, as shown in the following commands:
  2851. @smallexample
  2852. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2853. @kbd{tar cfT empty-archive.tar /dev/null}
  2854. @end smallexample
  2855. @item @value{op-extract}
  2856. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2857. @item @value{op-list}
  2858. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2859. while it used to show them as @samp{Aug 30 1996}. (One can revert to
  2860. the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
  2861. before reinstalling.) But preferably, people should get used to ISO
  2862. 8601 dates. Local American dates should be made available again with
  2863. full date localization support, once ready. In the meantime, programs
  2864. not being localizable for dates should prefer international dates,
  2865. that's really the way to go.
  2866. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2867. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2868. @end table
  2869. @node Advanced tar
  2870. @section Advanced @GNUTAR{} Operations
  2871. Now that you have learned the basics of using @GNUTAR{}, you may want
  2872. to learn about further ways in which @command{tar} can help you.
  2873. This chapter presents five, more advanced operations which you probably
  2874. won't use on a daily basis, but which serve more specialized functions.
  2875. We also explain the different styles of options and why you might want
  2876. to use one or another, or a combination of them in your @command{tar}
  2877. commands. Additionally, this chapter includes options which allow you to
  2878. define the output from @command{tar} more carefully, and provide help and
  2879. error correction in special circumstances.
  2880. @FIXME{check this after the chapter is actually revised to make sure
  2881. it still introduces the info in the chapter correctly : ).}
  2882. @menu
  2883. * Operations::
  2884. * append::
  2885. * update::
  2886. * concatenate::
  2887. * delete::
  2888. * compare::
  2889. @end menu
  2890. @node Operations
  2891. @subsection The Five Advanced @command{tar} Operations
  2892. @UNREVISED
  2893. In the last chapter, you learned about the first three operations to
  2894. @command{tar}. This chapter presents the remaining five operations to
  2895. @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
  2896. @samp{--delete}, and @samp{--compare}.
  2897. You are not likely to use these operations as frequently as those
  2898. covered in the last chapter; however, since they perform specialized
  2899. functions, they are quite useful when you do need to use them. We
  2900. will give examples using the same directory and files that you created
  2901. in the last chapter. As you may recall, the directory is called
  2902. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2903. @samp{rock}, and the two archive files you created are
  2904. @samp{collection.tar} and @samp{music.tar}.
  2905. We will also use the archive files @samp{afiles.tar} and
  2906. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2907. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2908. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2909. Unless we state otherwise, all practicing you do and examples you follow
  2910. in this chapter will take place in the @file{practice} directory that
  2911. you created in the previous chapter; see @ref{prepare for examples}.
  2912. (Below in this section, we will remind you of the state of the examples
  2913. where the last chapter left them.)
  2914. The five operations that we will cover in this chapter are:
  2915. @table @kbd
  2916. @item --append
  2917. @itemx -r
  2918. Add new entries to an archive that already exists.
  2919. @item --update
  2920. @itemx -r
  2921. Add more recent copies of archive members to the end of an archive, if
  2922. they exist.
  2923. @item --concatenate
  2924. @itemx --catenate
  2925. @itemx -A
  2926. Add one or more pre-existing archives to the end of another archive.
  2927. @item --delete
  2928. Delete items from an archive (does not work on tapes).
  2929. @item --compare
  2930. @itemx --diff
  2931. @itemx -d
  2932. Compare archive members to their counterparts in the file system.
  2933. @end table
  2934. @node append
  2935. @subsection How to Add Files to Existing Archives: @code{--append}
  2936. @UNREVISED
  2937. If you want to add files to an existing archive, you don't need to
  2938. create a new archive; you can use @value{op-append}. The archive must
  2939. already exist in order to use @samp{--append}. (A related operation
  2940. is the @samp{--update} operation; you can use this to add newer
  2941. versions of archive members to an existing archive. To learn how to
  2942. do this with @samp{--update}, @pxref{update}.)
  2943. @FIXME{Explain in second paragraph whether you can get to the previous
  2944. version -- explain whole situation somewhat more clearly.}
  2945. If you use @value{op-append} to add a file that has the same name as an
  2946. archive member to an archive containing that archive member, then the
  2947. old member is not deleted. What does happen, however, is somewhat
  2948. complex. @command{tar} @emph{allows} you to have infinite numbers of files
  2949. with the same name. Some operations treat these same-named members no
  2950. differently than any other set of archive members: for example, if you
  2951. view an archive with @value{op-list}, you will see all of those members
  2952. listed, with their modification times, owners, etc.
  2953. Other operations don't deal with these members as perfectly as you might
  2954. prefer; if you were to use @value{op-extract} to extract the archive,
  2955. only the most recently added copy of a member with the same name as four
  2956. other members would end up in the working directory. This is because
  2957. @samp{--extract} extracts an archive in the order the members appeared
  2958. in the archive; the most recently archived members will be extracted
  2959. last. Additionally, an extracted member will @emph{replace} a file of
  2960. the same name which existed in the directory already, and @command{tar}
  2961. will not prompt you about this. Thus, only the most recently archived
  2962. member will end up being extracted, as it will replace the one
  2963. extracted before it, and so on.
  2964. @FIXME{ hag -- you might want to incorporate some of the above into the
  2965. MMwtSN node; not sure. i didn't know how to make it simpler...}
  2966. There are a few ways to get around this. @FIXME-xref{Multiple Members
  2967. with the Same Name.}
  2968. @cindex Members, replacing with other members
  2969. @cindex Replacing members with other members
  2970. If you want to replace an archive member, use @value{op-delete} to
  2971. delete the member you want to remove from the archive, , and then use
  2972. @samp{--append} to add the member you want to be in the archive. Note
  2973. that you can not change the order of the archive; the most recently
  2974. added member will still appear last. In this sense, you cannot truly
  2975. ``replace'' one member with another. (Replacing one member with another
  2976. will not work on certain types of media, such as tapes; see @ref{delete}
  2977. and @ref{Media}, for more information.)
  2978. @menu
  2979. * appending files:: Appending Files to an Archive
  2980. * multiple::
  2981. @end menu
  2982. @node appending files
  2983. @subsubsection Appending Files to an Archive
  2984. @UNREVISED
  2985. @cindex Adding files to an Archive
  2986. @cindex Appending files to an Archive
  2987. @cindex Archives, Appending files to
  2988. The simplest way to add a file to an already existing archive is the
  2989. @value{op-append} operation, which writes specified files into the
  2990. archive whether or not they are already among the archived files.
  2991. When you use @samp{--append}, you @emph{must} specify file name
  2992. arguments, as there is no default. If you specify a file that already
  2993. exists in the archive, another copy of the file will be added to the
  2994. end of the archive. As with other operations, the member names of the
  2995. newly added files will be exactly the same as their names given on the
  2996. command line. The @value{op-verbose} option will print out the names
  2997. of the files as they are written into the archive.
  2998. @samp{--append} cannot be performed on some tape drives, unfortunately,
  2999. due to deficiencies in the formats those tape drives use. The archive
  3000. must be a valid @command{tar} archive, or else the results of using this
  3001. operation will be unpredictable. @xref{Media}.
  3002. To demonstrate using @samp{--append} to add a file to an archive,
  3003. create a file called @file{rock} in the @file{practice} directory.
  3004. Make sure you are in the @file{practice} directory. Then, run the
  3005. following @command{tar} command to add @file{rock} to
  3006. @file{collection.tar}:
  3007. @smallexample
  3008. $ @kbd{tar --append --file=collection.tar rock}
  3009. @end smallexample
  3010. @noindent
  3011. If you now use the @value{op-list} operation, you will see that
  3012. @file{rock} has been added to the archive:
  3013. @smallexample
  3014. $ @kbd{tar --list --file=collection.tar}
  3015. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3016. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3017. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3018. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3019. @end smallexample
  3020. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3021. title claims it will become...}
  3022. @node multiple
  3023. @subsubsection Multiple Files with the Same Name
  3024. You can use @value{op-append} to add copies of files which have been
  3025. updated since the archive was created. (However, we do not recommend
  3026. doing this since there is another @command{tar} option called
  3027. @samp{--update}; @pxref{update} for more information. We describe this
  3028. use of @samp{--append} here for the sake of completeness.) @FIXME{is
  3029. this really a good idea, to give this whole description for something
  3030. which i believe is basically a Stupid way of doing something? certain
  3031. aspects of it show ways in which tar is more broken than i'd personally
  3032. like to admit to, specifically the last sentence. On the other hand, i
  3033. don't think it's a good idea to be saying that re explicitly don't
  3034. recommend using something, but i can't see any better way to deal with
  3035. the situation.}When you extract the archive, the older version will be
  3036. effectively lost. This works because files are extracted from an
  3037. archive in the order in which they were archived. Thus, when the
  3038. archive is extracted, a file archived later in time will replace a
  3039. file of the same name which was archived earlier, even though the older
  3040. version of the file will remain in the archive unless you delete all
  3041. versions of the file.
  3042. Supposing you change the file @file{blues} and then append the changed
  3043. version to @file{collection.tar}. As you saw above, the original
  3044. @file{blues} is in the archive @file{collection.tar}. If you change the
  3045. file and append the new version of the file to the archive, there will
  3046. be two copies in the archive. When you extract the archive, the older
  3047. version of the file will be extracted first, and then replaced by the
  3048. newer version when it is extracted.
  3049. You can append the new, changed copy of the file @file{blues} to the
  3050. archive in this way:
  3051. @smallexample
  3052. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3053. blues
  3054. @end smallexample
  3055. @noindent
  3056. Because you specified the @samp{--verbose} option, @command{tar} has
  3057. printed the name of the file being appended as it was acted on. Now
  3058. list the contents of the archive:
  3059. @smallexample
  3060. $ @kbd{tar --list --verbose --file=collection.tar}
  3061. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3062. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3063. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3064. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3065. -rw-rw-rw- me user 58 1996-10-24 18:30 blues
  3066. @end smallexample
  3067. @noindent
  3068. The newest version of @file{blues} is now at the end of the archive
  3069. (note the different creation dates and file sizes). If you extract
  3070. the archive, the older version of the file @file{blues} will be
  3071. replaced by the newer version. You can confirm this by extracting
  3072. the archive and running @samp{ls} on the directory. @xref{Writing},
  3073. for more information. (@emph{Please note:} This is the case unless
  3074. you employ the @value{op-backup} option. @FIXME-ref{Multiple Members
  3075. with the Same Name}.)
  3076. @node update
  3077. @subsection Updating an Archive
  3078. @UNREVISED
  3079. @cindex Updating an archive
  3080. In the previous section, you learned how to use @value{op-append} to add
  3081. a file to an existing archive. A related operation is
  3082. @value{op-update}. The @samp{--update} operation updates a @command{tar}
  3083. archive by comparing the date of the specified archive members against
  3084. the date of the file with the same name. If the file has been modified
  3085. more recently than the archive member, then the newer version of the
  3086. file is added to the archive (as with @value{op-append}).
  3087. Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
  3088. The operation will fail.
  3089. @FIXME{other examples of media on which --update will fail? need to ask
  3090. charles and/or mib/thomas/dave shevett..}
  3091. Both @samp{--update} and @samp{--append} work by adding to the end
  3092. of the archive. When you extract a file from the archive, only the
  3093. version stored last will wind up in the file system, unless you use
  3094. the @value{op-backup} option. @FIXME-ref{Multiple Members with the
  3095. Same Name}
  3096. @menu
  3097. * how to update::
  3098. @end menu
  3099. @node how to update
  3100. @subsubsection How to Update an Archive Using @code{--update}
  3101. You must use file name arguments with the @value{op-update} operation.
  3102. If you don't specify any files, @command{tar} won't act on any files and
  3103. won't tell you that it didn't do anything (which may end up confusing
  3104. you).
  3105. @FIXME{note: the above parenthetical added because in fact, this
  3106. behavior just confused the author. :-) }
  3107. To see the @samp{--update} option at work, create a new file,
  3108. @file{classical}, in your practice directory, and some extra text to the
  3109. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3110. the @samp{update} operation and the @value{op-verbose} option specified,
  3111. using the names of all the files in the practice directory as file name
  3112. arguments:
  3113. @smallexample
  3114. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3115. blues
  3116. classical
  3117. $
  3118. @end smallexample
  3119. @noindent
  3120. Because we have specified verbose mode, @command{tar} prints out the names
  3121. of the files it is working on, which in this case are the names of the
  3122. files that needed to be updated. If you run @samp{tar --list} and look
  3123. at the archive, you will see @file{blues} and @file{classical} at its
  3124. end. There will be a total of two versions of the member @samp{blues};
  3125. the one at the end will be newer and larger, since you added text before
  3126. updating it.
  3127. (The reason @command{tar} does not overwrite the older file when updating
  3128. it is because writing to the middle of a section of tape is a difficult
  3129. process. Tapes are not designed to go backward. @xref{Media}, for more
  3130. information about tapes.
  3131. @value{op-update} is not suitable for performing backups for two
  3132. reasons: it does not change directory content entries, and it
  3133. lengthens the archive every time it is used. The @GNUTAR{}
  3134. options intended specifically for backups are more
  3135. efficient. If you need to run backups, please consult @ref{Backups}.
  3136. @node concatenate
  3137. @subsection Combining Archives with @code{--concatenate}
  3138. @cindex Adding archives to an archive
  3139. @cindex Concatenating Archives
  3140. Sometimes it may be convenient to add a second archive onto the end of
  3141. an archive rather than adding individual files to the archive. To add
  3142. one or more archives to the end of another archive, you should use the
  3143. @value{op-concatenate} operation.
  3144. To use @samp{--concatenate}, name the archives to be concatenated on the
  3145. command line. (Nothing happens if you don't list any.) The members,
  3146. and their member names, will be copied verbatim from those archives. If
  3147. this causes multiple members to have the same name, it does not delete
  3148. any members; all the members with the same name coexist. @FIXME-ref{For
  3149. information on how this affects reading the archive, Multiple
  3150. Members with the Same Name.}
  3151. To demonstrate how @samp{--concatenate} works, create two small archives
  3152. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3153. files from @file{practice}:
  3154. @smallexample
  3155. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3156. blues
  3157. classical
  3158. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3159. folk
  3160. jazz
  3161. @end smallexample
  3162. @noindent
  3163. If you like, You can run @samp{tar --list} to make sure the archives
  3164. contain what they are supposed to:
  3165. @smallexample
  3166. $ @kbd{tar -tvf bluesrock.tar}
  3167. -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
  3168. -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
  3169. $ @kbd{tar -tvf folkjazz.tar}
  3170. -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
  3171. -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
  3172. @end smallexample
  3173. We can concatenate these two archives with @command{tar}:
  3174. @smallexample
  3175. $ @kbd{cd ..}
  3176. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3177. @end smallexample
  3178. If you now list the contents of the @file{bluesclass.tar}, you will see
  3179. that now it also contains the archive members of @file{jazzfolk.tar}:
  3180. @smallexample
  3181. $ @kbd{tar --list --file=bluesrock.tar}
  3182. blues
  3183. rock
  3184. jazz
  3185. folk
  3186. @end smallexample
  3187. When you use @samp{--concatenate}, the source and target archives must
  3188. already exist and must have been created using compatible format
  3189. parameters. @FIXME-pxref{Matching Format Parameters}The new,
  3190. concatenated archive will be called by the same name as the first
  3191. archive listed on the command line. @FIXME{is there a way to specify a
  3192. new name?}
  3193. Like @value{op-append}, this operation cannot be performed on some
  3194. tape drives, due to deficiencies in the formats those tape drives use.
  3195. @cindex @code{concatenate} vs @command{cat}
  3196. @cindex @command{cat} vs @code{concatenate}
  3197. It may seem more intuitive to you to want or try to use @command{cat} to
  3198. concatenate two archives instead of using the @samp{--concatenate}
  3199. operation; after all, @command{cat} is the utility for combining files.
  3200. However, @command{tar} archives incorporate an end-of-file marker which
  3201. must be removed if the concatenated archives are to be read properly as
  3202. one archive. @samp{--concatenate} removes the end-of-archive marker
  3203. from the target archive before each new archive is appended. If you use
  3204. @command{cat} to combine the archives, the result will not be a valid
  3205. @command{tar} format archive. If you need to retrieve files from an
  3206. archive that was added to using the @command{cat} utility, use the
  3207. @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
  3208. information on dealing with archives improperly combined using the
  3209. @command{cat} shell utility.
  3210. @FIXME{this shouldn't go here. where should it go?} You must specify
  3211. the source archives using @value{op-file} (@value{pxref-file}). If you
  3212. do not specify the target archive, @command{tar} uses the value of the
  3213. environment variable @env{TAPE}, or, if this has not been set, the
  3214. default archive name.
  3215. @node delete
  3216. @subsection Removing Archive Members Using @samp{--delete}
  3217. @UNREVISED
  3218. @cindex Deleting files from an archive
  3219. @cindex Removing files from an archive
  3220. You can remove members from an archive by using the @value{op-delete}
  3221. option. Specify the name of the archive with @value{op-file} and then
  3222. specify the names of the members to be deleted; if you list no member
  3223. names, nothing will be deleted. The @value{op-verbose} option will
  3224. cause @command{tar} to print the names of the members as they are deleted.
  3225. As with @value{op-extract}, you must give the exact member names when
  3226. using @samp{tar --delete}. @samp{--delete} will remove all versions of
  3227. the named file from the archive. The @samp{--delete} operation can run
  3228. very slowly.
  3229. Unlike other operations, @samp{--delete} has no short form.
  3230. @cindex Tapes, using @code{--delete} and
  3231. @cindex Deleting from tape archives
  3232. This operation will rewrite the archive. You can only use
  3233. @samp{--delete} on an archive if the archive device allows you to
  3234. write to any point on the media, such as a disk; because of this, it
  3235. does not work on magnetic tapes. Do not try to delete an archive member
  3236. from a magnetic tape; the action will not succeed, and you will be
  3237. likely to scramble the archive and damage your tape. There is no safe
  3238. way (except by completely re-writing the archive) to delete files from
  3239. most kinds of magnetic tape. @xref{Media}.
  3240. To delete all versions of the file @file{blues} from the archive
  3241. @file{collection.tar} in the @file{practice} directory, make sure you
  3242. are in that directory, and then,
  3243. @smallexample
  3244. $ @kbd{tar --list --file=collection.tar}
  3245. blues
  3246. folk
  3247. jazz
  3248. rock
  3249. practice/blues
  3250. practice/folk
  3251. practice/jazz
  3252. practice/rock
  3253. practice/blues
  3254. $ @kbd{tar --delete --file=collection.tar blues}
  3255. $ @kbd{tar --list --file=collection.tar}
  3256. folk
  3257. jazz
  3258. rock
  3259. $
  3260. @end smallexample
  3261. @FIXME{I changed the order of these nodes around and haven't had a chance
  3262. to fix the above example's results, yet. I have to play with this and
  3263. follow it and see what it actually does!}
  3264. The @value{op-delete} option has been reported to work properly when
  3265. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3266. @node compare
  3267. @subsection Comparing Archive Members with the File System
  3268. @cindex Verifying the currency of an archive
  3269. @UNREVISED
  3270. The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
  3271. specified archive members against files with the same names, and then
  3272. reports differences in file size, mode, owner, modification date and
  3273. contents. You should @emph{only} specify archive member names, not file
  3274. names. If you do not name any members, then @command{tar} will compare the
  3275. entire archive. If a file is represented in the archive but does not
  3276. exist in the file system, @command{tar} reports a difference.
  3277. You have to specify the record size of the archive when modifying an
  3278. archive with a non-default record size.
  3279. @command{tar} ignores files in the file system that do not have
  3280. corresponding members in the archive.
  3281. The following example compares the archive members @file{rock},
  3282. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3283. files of the same name in the file system. (Note that there is no file,
  3284. @file{funk}; @command{tar} will report an error message.)
  3285. @smallexample
  3286. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3287. rock
  3288. blues
  3289. tar: funk not found in archive
  3290. @end smallexample
  3291. @noindent
  3292. @FIXME{what does this actually depend on? i'm making a guess,
  3293. here.}Depending on the system where you are running @command{tar} and the
  3294. version you are running, @command{tar} may have a different error message,
  3295. such as:
  3296. @smallexample
  3297. funk: does not exist
  3298. @end smallexample
  3299. @FIXME-xref{somewhere, for more information about format parameters.
  3300. Melissa says: such as "format variations"? But why? Clearly I don't
  3301. get it yet; I'll deal when I get to that section.}
  3302. The spirit behind the @value{op-compare} option is to check whether the
  3303. archive represents the current state of files on disk, more than validating
  3304. the integrity of the archive media. For this later goal, @xref{verify}.
  3305. @node create options
  3306. @section Options Used by @code{--create}
  3307. The previous chapter described the basics of how to use
  3308. @value{op-create} to create an archive from a set of files.
  3309. @xref{create}. This section described advanced options to be used with
  3310. @samp{--create}.
  3311. @menu
  3312. * Ignore Failed Read::
  3313. @end menu
  3314. @node Ignore Failed Read
  3315. @subsection Ignore Fail Read
  3316. @table @kbd
  3317. @item --ignore-failed-read
  3318. Do not exit with nonzero on unreadable files or directories.
  3319. @end table
  3320. @node extract options
  3321. @section Options Used by @code{--extract}
  3322. @UNREVISED
  3323. @FIXME{i need to get dan to go over these options with me and see if
  3324. there's a better way of organizing them.}
  3325. The previous chapter showed how to use @value{op-extract} to extract
  3326. an archive into the filesystem. Various options cause @command{tar} to
  3327. extract more information than just file contents, such as the owner,
  3328. the permissions, the modification date, and so forth. This section
  3329. presents options to be used with @samp{--extract} when certain special
  3330. considerations arise. You may review the information presented in
  3331. @ref{extract} for more basic information about the
  3332. @samp{--extract} operation.
  3333. @menu
  3334. * Reading:: Options to Help Read Archives
  3335. * Writing:: Changing How @command{tar} Writes Files
  3336. * Scarce:: Coping with Scarce Resources
  3337. @end menu
  3338. @node Reading
  3339. @subsection Options to Help Read Archives
  3340. @cindex Options when reading archives
  3341. @cindex Reading incomplete records
  3342. @cindex Records, incomplete
  3343. @cindex End-of-archive entries, ignoring
  3344. @cindex Ignoring end-of-archive entries
  3345. @cindex Large lists of file names on small machines
  3346. @cindex Small memory
  3347. @cindex Running out of space
  3348. @UNREVISED
  3349. Normally, @command{tar} will request data in full record increments from
  3350. an archive storage device. If the device cannot return a full record,
  3351. @command{tar} will report an error. However, some devices do not always
  3352. return full records, or do not require the last record of an archive to
  3353. be padded out to the next record boundary. To keep reading until you
  3354. obtain a full record, or to accept an incomplete record if it contains
  3355. an end-of-archive marker, specify the @value{op-read-full-records} option
  3356. in conjunction with the @value{op-extract} or @value{op-list} operations.
  3357. @value{xref-read-full-records}.
  3358. The @value{op-read-full-records} option is turned on by default when
  3359. @command{tar} reads an archive from standard input, or from a remote
  3360. machine. This is because on BSD Unix systems, attempting to read a
  3361. pipe returns however much happens to be in the pipe, even if it is
  3362. less than was requested. If this option were not enabled, @command{tar}
  3363. would fail as soon as it read an incomplete record from the pipe.
  3364. If you're not sure of the blocking factor of an archive, you can
  3365. read the archive by specifying @value{op-read-full-records} and
  3366. @value{op-blocking-factor}, using a blocking factor larger than what the
  3367. archive uses. This lets you avoid having to determine the blocking factor
  3368. of an archive. @value{xref-blocking-factor}.
  3369. @menu
  3370. * read full records::
  3371. * Ignore Zeros::
  3372. @end menu
  3373. @node read full records
  3374. @unnumberedsubsubsec Reading Full Records
  3375. @FIXME{need sentence or so of intro here}
  3376. @table @kbd
  3377. @item --read-full-records
  3378. @item -B
  3379. Use in conjunction with @value{op-extract} to read an archive which
  3380. contains incomplete records, or one which has a blocking factor less
  3381. than the one specified.
  3382. @end table
  3383. @node Ignore Zeros
  3384. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3385. Normally, @command{tar} stops reading when it encounters a block of zeros
  3386. between file entries (which usually indicates the end of the archive).
  3387. @value{op-ignore-zeros} allows @command{tar} to completely read an archive
  3388. which contains a block of zeros before the end (i.e.@: a damaged
  3389. archive, or one which was created by concatenating several archives
  3390. together).
  3391. The @value{op-ignore-zeros} option is turned off by default because many
  3392. versions of @command{tar} write garbage after the end-of-archive entry,
  3393. since that part of the media is never supposed to be read. @GNUTAR{}
  3394. does not write after the end of an archive, but seeks to
  3395. maintain compatiblity among archiving utilities.
  3396. @table @kbd
  3397. @item --ignore-zeros
  3398. @itemx -i
  3399. To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
  3400. encountered while reading an archive. Use in conjunction with
  3401. @value{op-extract} or @value{op-list}.
  3402. @end table
  3403. @node Writing
  3404. @subsection Changing How @command{tar} Writes Files
  3405. @cindex Overwriting old files, prevention
  3406. @cindex Protecting old files
  3407. @cindex Modification times of extracted files
  3408. @cindex Permissions of extracted files
  3409. @cindex Modes of extracted files
  3410. @cindex Writing extracted files to standard output
  3411. @cindex Standard output, writing extracted files to
  3412. @UNREVISED
  3413. @FIXME{need to mention the brand new option, --backup}
  3414. @menu
  3415. * Dealing with Old Files::
  3416. * Overwrite Old Files::
  3417. * Keep Old Files::
  3418. * Unlink First::
  3419. * Recursive Unlink::
  3420. * Modification Times::
  3421. * Setting Access Permissions::
  3422. * Writing to Standard Output::
  3423. * remove files::
  3424. @end menu
  3425. @node Dealing with Old Files
  3426. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3427. When extracting files, if @command{tar} discovers that the extracted
  3428. file already exists, it normally replaces the file by removing it before
  3429. extracting it, to prevent confusion in the presence of hard or symbolic
  3430. links. (If the existing file is a symbolic link, it is removed, not
  3431. followed.) However, if a directory cannot be removed because it is
  3432. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3433. permission, etc.). The @option{--overwrite-dir} option enables this
  3434. default behavior. To be more cautious and preserve the metadata of
  3435. such a directory, use the @option{--no-overwrite-dir} option.
  3436. To be even more cautious and prevent existing files from being replaced, use
  3437. the @value{op-keep-old-files} option. It causes @command{tar} to refuse
  3438. to replace or update a file that already exists, i.e., a file with the
  3439. same name as an archive member prevents extraction of that archive
  3440. member. Instead, it reports an error.
  3441. To be more aggressive about altering existing files, use the
  3442. @value{op-overwrite} option. It causes @command{tar} to overwrite
  3443. existing files and to follow existing symbolic links when extracting.
  3444. Some people argue that @GNUTAR{} should not hesitate
  3445. to overwrite files with other files when extracting. When extracting
  3446. a @command{tar} archive, they expect to see a faithful copy of the
  3447. state of the filesystem when the archive was created. It is debatable
  3448. that this would always be a proper behavior. For example, suppose one
  3449. has an archive in which @file{usr/local} is a link to
  3450. @file{usr/local2}. Since then, maybe the site removed the link and
  3451. renamed the whole hierarchy from @file{/usr/local2} to
  3452. @file{/usr/local}. Such things happen all the time. I guess it would
  3453. not be welcome at all that @GNUTAR{} removes the
  3454. whole hierarchy just to make room for the link to be reinstated
  3455. (unless it @emph{also} simultaneously restores the full
  3456. @file{/usr/local2}, of course! @GNUTAR{} is indeed
  3457. able to remove a whole hierarchy to reestablish a symbolic link, for
  3458. example, but @emph{only if} @value{op-recursive-unlink} is specified
  3459. to allow this behavior. In any case, single files are silently
  3460. removed.
  3461. Finally, the @value{op-unlink-first} option can improve performance in
  3462. some cases by causing @command{tar} to remove files unconditionally
  3463. before extracting them.
  3464. @node Overwrite Old Files
  3465. @unnumberedsubsubsec Overwrite Old Files
  3466. @table @kbd
  3467. @item --overwrite
  3468. Overwrite existing files and directory metadata when extracting files
  3469. from an archive.
  3470. This
  3471. causes @command{tar} to write extracted files into the file system without
  3472. regard to the files already on the system; i.e., files with the same
  3473. names as archive members are overwritten when the archive is extracted.
  3474. It also causes @command{tar} to extract the ownership, permissions,
  3475. and time stamps onto any preexisting files or directories.
  3476. If the name of a corresponding file name is a symbolic link, the file
  3477. pointed to by the symbolic link will be overwritten instead of the
  3478. symbolic link itself (if this is possible). Moreover, special devices,
  3479. empty directories and even symbolic links are automatically removed if
  3480. they are in the way of extraction.
  3481. Be careful when using the @value{op-overwrite} option, particularly when
  3482. combined with the @value{op-absolute-names} option, as this combination
  3483. can change the contents, ownership or permissions of any file on your
  3484. system. Also, many systems do not take kindly to overwriting files that
  3485. are currently being executed.
  3486. @item --overwrite-dir
  3487. Overwrite the metadata of directories when extracting files from an
  3488. archive, but remove other files before extracting.
  3489. @end table
  3490. @node Keep Old Files
  3491. @unnumberedsubsubsec Keep Old Files
  3492. @table @kbd
  3493. @item --keep-old-files
  3494. @itemx -k
  3495. Do not replace existing files from archive. The
  3496. @value{op-keep-old-files} option prevents @command{tar} from replacing
  3497. existing files with files with the same name from the archive.
  3498. The @value{op-keep-old-files} option is meaningless with @value{op-list}.
  3499. Prevents @command{tar} from replacing files in the file system during
  3500. extraction.
  3501. @end table
  3502. @node Unlink First
  3503. @unnumberedsubsubsec Unlink First
  3504. @table @kbd
  3505. @item --unlink-first
  3506. @itemx -U
  3507. Remove files before extracting over them.
  3508. This can make @command{tar} run a bit faster if you know in advance
  3509. that the extracted files all need to be removed. Normally this option
  3510. slows @command{tar} down slightly, so it is disabled by default.
  3511. @end table
  3512. @node Recursive Unlink
  3513. @unnumberedsubsubsec Recursive Unlink
  3514. @table @kbd
  3515. @item --recursive-unlink
  3516. When this option is specified, try removing files and directory hierarchies
  3517. before extracting over them. @emph{This is a dangerous option!}
  3518. @end table
  3519. If you specify the @value{op-recursive-unlink} option,
  3520. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3521. as far as current permissions will allow it. This could include removal
  3522. of the contents of a full directory hierarchy.
  3523. @node Modification Times
  3524. @unnumberedsubsubsec Setting Modification Times
  3525. Normally, @command{tar} sets the modification times of extracted files to
  3526. the modification times recorded for the files in the archive, but
  3527. limits the permissions of extracted files by the current @code{umask}
  3528. setting.
  3529. To set the modification times of extracted files to the time when
  3530. the files were extracted, use the @value{op-touch} option in
  3531. conjunction with @value{op-extract}.
  3532. @table @kbd
  3533. @item --touch
  3534. @itemx -m
  3535. Sets the modification time of extracted archive members to the time
  3536. they were extracted, not the time recorded for them in the archive.
  3537. Use in conjunction with @value{op-extract}.
  3538. @end table
  3539. @node Setting Access Permissions
  3540. @unnumberedsubsubsec Setting Access Permissions
  3541. To set the modes (access permissions) of extracted files to those
  3542. recorded for those files in the archive, use @samp{--same-permissions}
  3543. in conjunction with the @value{op-extract} operation. @FIXME{Should be
  3544. aliased to ignore-umask.}
  3545. @table @kbd
  3546. @item --preserve-permission
  3547. @itemx --same-permission
  3548. @itemx --ignore-umask
  3549. @itemx -p
  3550. Set modes of extracted archive members to those recorded in the
  3551. archive, instead of current umask settings. Use in conjunction with
  3552. @value{op-extract}.
  3553. @end table
  3554. @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
  3555. files together, why is this useful. is it really useful with
  3556. more than one file?}
  3557. @node Writing to Standard Output
  3558. @unnumberedsubsubsec Writing to Standard Output
  3559. To write the extracted files to the standard output, instead of
  3560. creating the files on the file system, use @value{op-to-stdout} in
  3561. conjunction with @value{op-extract}. This option is useful if you are
  3562. extracting files to send them through a pipe, and do not need to
  3563. preserve them in the file system. If you extract multiple members,
  3564. they appear on standard output concatenated, in the order they are
  3565. found in the archive.
  3566. @table @kbd
  3567. @item --to-stdout
  3568. @itemx -O
  3569. Writes files to the standard output. Used in conjunction with
  3570. @value{op-extract}. Extract files to standard output. When this option
  3571. is used, instead of creating the files specified, @command{tar} writes
  3572. the contents of the files extracted to its standard output. This may
  3573. be useful if you are only extracting the files in order to send them
  3574. through a pipe. This option is meaningless with @value{op-list}.
  3575. @end table
  3576. This can be useful, for example, if you have a tar archive containing
  3577. a big file and don't want to store the file on disk before processing
  3578. it. You can use a command like this:
  3579. @smallexample
  3580. tar -xOzf foo.tgz bigfile | process
  3581. @end smallexample
  3582. or even like this if you want to process the concatenation of the files:
  3583. @smallexample
  3584. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3585. @end smallexample
  3586. @node remove files
  3587. @unnumberedsubsubsec Removing Files
  3588. @FIXME{the various macros in the front of the manual think that this
  3589. option goes in this section. i have no idea; i only know it's nowhere
  3590. else in the book...}
  3591. @table @kbd
  3592. @item --remove-files
  3593. Remove files after adding them to the archive.
  3594. @end table
  3595. @node Scarce
  3596. @subsection Coping with Scarce Resources
  3597. @cindex Middle of the archive, starting in the
  3598. @cindex Running out of space during extraction
  3599. @cindex Disk space, running out of
  3600. @cindex Space on the disk, recovering from lack of
  3601. @UNREVISED
  3602. @menu
  3603. * Starting File::
  3604. * Same Order::
  3605. @end menu
  3606. @node Starting File
  3607. @unnumberedsubsubsec Starting File
  3608. @table @kbd
  3609. @item --starting-file=@var{name}
  3610. @itemx -K @var{name}
  3611. Starts an operation in the middle of an archive. Use in conjunction
  3612. with @value{op-extract} or @value{op-list}.
  3613. @end table
  3614. If a previous attempt to extract files failed due to lack of disk
  3615. space, you can use @value{op-starting-file} to start extracting only
  3616. after member @var{name} of the archive. This assumes, of course, that
  3617. there is now free space, or that you are now extracting into a
  3618. different file system. (You could also choose to suspend @command{tar},
  3619. remove unnecessary files from the file system, and then restart the
  3620. same @command{tar} operation. In this case, @value{op-starting-file} is
  3621. not necessary. @value{xref-incremental}, @value{xref-interactive},
  3622. and @value{ref-exclude}.)
  3623. @node Same Order
  3624. @unnumberedsubsubsec Same Order
  3625. @table @kbd
  3626. @item --same-order
  3627. @itemx --preserve-order
  3628. @itemx -s
  3629. To process large lists of file names on machines with small amounts of
  3630. memory. Use in conjunction with @value{op-compare},
  3631. @value{op-list}
  3632. or @value{op-extract}.
  3633. @end table
  3634. @FIXME{we don't need/want --preserve to exist any more (from melissa:
  3635. ie, don't want that *version* of the option to exist, or don't want
  3636. the option to exist in either version?}
  3637. @FIXME{i think this explanation is lacking.}
  3638. The @value{op-same-order} option tells @command{tar} that the list of file
  3639. names to be listed or extracted is sorted in the same order as the
  3640. files in the archive. This allows a large list of names to be used,
  3641. even on a small machine that would not otherwise be able to hold all
  3642. the names in memory at the same time. Such a sorted list can easily be
  3643. created by running @samp{tar -t} on the archive and editing its output.
  3644. This option is probably never needed on modern computer systems.
  3645. @node backup
  3646. @section Backup options
  3647. @cindex backup options
  3648. @GNUTAR{} offers options for making backups of files
  3649. before writing new versions. These options control the details of
  3650. these backups. They may apply to the archive itself before it is
  3651. created or rewritten, as well as individual extracted members. Other
  3652. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3653. and @command{mv}, for example) offer similar options.
  3654. Backup options may prove unexpectedly useful when extracting archives
  3655. containing many members having identical name, or when extracting archives
  3656. on systems having file name limitations, making different members appear
  3657. has having similar names through the side-effect of name truncation.
  3658. (This is true only if we have a good scheme for truncated backup names,
  3659. which I'm not sure at all: I suspect work is needed in this area.)
  3660. When any existing file is backed up before being overwritten by extraction,
  3661. then clashing files are automatically be renamed to be unique, and the
  3662. true name is kept for only the last file of a series of clashing files.
  3663. By using verbose mode, users may track exactly what happens.
  3664. At the detail level, some decisions are still experimental, and may
  3665. change in the future, we are waiting comments from our users. So, please
  3666. do not learn to depend blindly on the details of the backup features.
  3667. For example, currently, directories themselves are never renamed through
  3668. using these options, so, extracting a file over a directory still has
  3669. good chances to fail. Also, backup options apply to created archives,
  3670. not only to extracted members. For created archives, backups will not
  3671. be attempted when the archive is a block or character device, or when it
  3672. refers to a remote file.
  3673. For the sake of simplicity and efficiency, backups are made by renaming old
  3674. files prior to creation or extraction, and not by copying. The original
  3675. name is restored if the file creation fails. If a failure occurs after a
  3676. partial extraction of a file, both the backup and the partially extracted
  3677. file are kept.
  3678. @table @samp
  3679. @item --backup[=@var{method}]
  3680. @opindex --backup
  3681. @vindex VERSION_CONTROL
  3682. @cindex backups
  3683. Back up files that are about to be overwritten or removed.
  3684. Without this option, the original versions are destroyed.
  3685. Use @var{method} to determine the type of backups made.
  3686. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3687. environment variable. And if @env{VERSION_CONTROL} is not set,
  3688. use the @samp{existing} method.
  3689. @vindex version-control @r{Emacs variable}
  3690. This option corresponds to the Emacs variable @samp{version-control};
  3691. the same values for @var{method} are accepted as in Emacs. This option
  3692. also allows more descriptive names. The valid @var{method}s are:
  3693. @table @samp
  3694. @item t
  3695. @itemx numbered
  3696. @opindex numbered @r{backup method}
  3697. Always make numbered backups.
  3698. @item nil
  3699. @itemx existing
  3700. @opindex existing @r{backup method}
  3701. Make numbered backups of files that already have them, simple backups
  3702. of the others.
  3703. @item never
  3704. @itemx simple
  3705. @opindex simple @r{backup method}
  3706. Always make simple backups.
  3707. @end table
  3708. @item --suffix=@var{suffix}
  3709. @opindex --suffix
  3710. @cindex backup suffix
  3711. @vindex SIMPLE_BACKUP_SUFFIX
  3712. Append @var{suffix} to each backup file made with @samp{--backup}. If this
  3713. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3714. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3715. set, the default is @samp{~}, just as in Emacs.
  3716. @end table
  3717. Some people express the desire to @emph{always} use the @value{op-backup}
  3718. option, by defining some kind of alias or script. This is not as easy
  3719. as one may think, due to the fact that old style options should appear first
  3720. and consume arguments a bit unpredictably for an alias or script. But,
  3721. if you are ready to give up using old style options, you may resort to
  3722. using something like (a Bourne shell function here):
  3723. @smallexample
  3724. tar () @{ /usr/local/bin/tar --backup $*; @}
  3725. @end smallexample
  3726. @node Applications
  3727. @section Notable @command{tar} Usages
  3728. @UNREVISED
  3729. @FIXME{Using Unix file linking capability to recreate directory
  3730. structures---linking files into one subdirectory and then
  3731. @command{tar}ring that directory.}
  3732. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3733. @findex uuencode
  3734. You can easily use archive files to transport a group of files from
  3735. one system to another: put all relevant files into an archive on one
  3736. computer system, transfer the archive to another system, and extract
  3737. the contents there. The basic transfer medium might be magnetic tape,
  3738. Internet FTP, or even electronic mail (though you must encode the
  3739. archive with @command{uuencode} in order to transport it properly by
  3740. mail). Both machines do not have to use the same operating system, as
  3741. long as they both support the @command{tar} program.
  3742. For example, here is how you might copy a directory's contents from
  3743. one disk to another, while preserving the dates, modes, owners and
  3744. link-structure of all the files therein. In this case, the transfer
  3745. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3746. @smallexample
  3747. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3748. @end smallexample
  3749. @noindent
  3750. The command also works using short option forms:
  3751. @FIXME{The following using standard input/output correct??}
  3752. @smallexample
  3753. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3754. @end smallexample
  3755. @noindent
  3756. This is one of the easiest methods to transfer a @command{tar} archive.
  3757. @node looking ahead
  3758. @section Looking Ahead: The Rest of this Manual
  3759. You have now seen how to use all eight of the operations available to
  3760. @command{tar}, and a number of the possible options. The next chapter
  3761. explains how to choose and change file and archive names, how to use
  3762. files to store names of other files which you can then call as
  3763. arguments to @command{tar} (this can help you save time if you expect to
  3764. archive the same list of files a number of times), and so forth.
  3765. @FIXME{in case it's not obvious, i'm making this up in some sense
  3766. based on my limited memory of what the next chapter *really* does. i
  3767. just wanted to flesh out this final section a little bit so i'd
  3768. remember to stick it in here. :-)}
  3769. If there are too many files to conveniently list on the command line,
  3770. you can list the names in a file, and @command{tar} will read that file.
  3771. @value{xref-files-from}.
  3772. There are various ways of causing @command{tar} to skip over some files,
  3773. and not archive them. @xref{Choosing}.
  3774. @node Backups
  3775. @chapter Performing Backups and Restoring Files
  3776. @UNREVISED
  3777. @GNUTAR{} is distributed along with the scripts
  3778. which the Free Software Foundation uses for performing backups. There
  3779. is no corresponding scripts available yet for doing restoration of
  3780. files. Even if there is a good chance those scripts may be satisfying
  3781. to you, they are not the only scripts or methods available for doing
  3782. backups and restore. You may well create your own, or use more
  3783. sophisticated packages dedicated to that purpose.
  3784. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3785. Automatic Network Disk Archiver), a backup system developed by James
  3786. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3787. This is free software, and it is available at these places:
  3788. @smallexample
  3789. http://www.cs.umd.edu/projects/amanda/amanda.html
  3790. ftp://ftp.cs.umd.edu/pub/amanda
  3791. @end smallexample
  3792. @ifclear PUBLISH
  3793. Here is a possible plan for a future documentation about the backuping
  3794. scripts which are provided within the @GNUTAR{}
  3795. distribution.
  3796. @smallexample
  3797. .* dumps
  3798. . + what are dumps
  3799. . + different levels of dumps
  3800. . - full dump = dump everything
  3801. . - level 1, level 2 dumps etc, -
  3802. A level n dump dumps everything changed since the last level
  3803. n-1 dump (?)
  3804. . + how to use scripts for dumps (ie, the concept)
  3805. . - scripts to run after editing backup specs (details)
  3806. . + Backup Specs, what is it.
  3807. . - how to customize
  3808. . - actual text of script [/sp/dump/backup-specs]
  3809. . + Problems
  3810. . - rsh doesn't work
  3811. . - rtape isn't installed
  3812. . - (others?)
  3813. . + the --incremental option of tar
  3814. . + tapes
  3815. . - write protection
  3816. . - types of media
  3817. . : different sizes and types, useful for different things
  3818. . - files and tape marks
  3819. one tape mark between files, two at end.
  3820. . - positioning the tape
  3821. MT writes two at end of write,
  3822. backspaces over one when writing again.
  3823. @end smallexample
  3824. @end ifclear
  3825. This chapter documents both the provided FSF scripts and @command{tar}
  3826. options which are more specific to usage as a backup tool.
  3827. To @dfn{back up} a file system means to create archives that contain
  3828. all the files in that file system. Those archives can then be used to
  3829. restore any or all of those files (for instance if a disk crashes or a
  3830. file is accidentally deleted). File system @dfn{backups} are also
  3831. called @dfn{dumps}.
  3832. @menu
  3833. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  3834. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  3835. * incremental and listed-incremental:: The Incremental Options
  3836. * Backup Levels:: Levels of Backups
  3837. * Backup Parameters:: Setting Parameters for Backups and Restoration
  3838. * Scripted Backups:: Using the Backup Scripts
  3839. * Scripted Restoration:: Using the Restore Script
  3840. @end menu
  3841. @node Full Dumps
  3842. @section Using @command{tar} to Perform Full Dumps
  3843. @UNREVISED
  3844. @cindex full dumps
  3845. @cindex dumps, full
  3846. @cindex corrupted archives
  3847. Full dumps should only be made when no other people or programs
  3848. are modifying files in the filesystem. If files are modified while
  3849. @command{tar} is making the backup, they may not be stored properly in
  3850. the archive, in which case you won't be able to restore them if you
  3851. have to. (Files not being modified are written with no trouble, and do
  3852. not corrupt the entire archive.)
  3853. You will want to use the @value{op-label} option to give the archive a
  3854. volume label, so you can tell what this archive is even if the label
  3855. falls off the tape, or anything like that.
  3856. Unless the filesystem you are dumping is guaranteed to fit on
  3857. one volume, you will need to use the @value{op-multi-volume} option.
  3858. Make sure you have enough tapes on hand to complete the backup.
  3859. If you want to dump each filesystem separately you will need to use
  3860. the @value{op-one-file-system} option to prevent @command{tar} from crossing
  3861. filesystem boundaries when storing (sub)directories.
  3862. The @value{op-incremental} option is not needed, since this is a complete
  3863. copy of everything in the filesystem, and a full restore from this
  3864. backup would only be done onto a completely empty disk.
  3865. Unless you are in a hurry, and trust the @command{tar} program (and your
  3866. tapes), it is a good idea to use the @value{op-verify} option, to make
  3867. sure your files really made it onto the dump properly. This will
  3868. also detect cases where the file was modified while (or just after)
  3869. it was being archived. Not all media (notably cartridge tapes) are
  3870. capable of being verified, unfortunately.
  3871. @value{op-listed-incremental} take a file name argument always. If the
  3872. file doesn't exist, run a level zero dump, creating the file. If the
  3873. file exists, uses that file to see what has changed.
  3874. @value{op-incremental} @FIXME{look it up}
  3875. @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
  3876. This option should only be used when creating an incremental backup of
  3877. a filesystem. When the @value{op-incremental} option is used, @command{tar}
  3878. writes, at the beginning of the archive, an entry for each of the
  3879. directories that will be operated on. The entry for a directory
  3880. includes a list of all the files in the directory at the time the
  3881. dump was done, and a flag for each file indicating whether the file
  3882. is going to be put in the archive. This information is used when
  3883. doing a complete incremental restore.
  3884. Note that this option causes @command{tar} to create a non-standard
  3885. archive that may not be readable by non-@acronym{GNU} versions of the
  3886. @command{tar} program.
  3887. The @value{op-incremental} option means the archive is an incremental
  3888. backup. Its meaning depends on the command that it modifies.
  3889. If the @value{op-incremental} option is used with @value{op-list},
  3890. @command{tar} will list, for each directory in the archive, the list
  3891. of files in that directory at the time the archive was created. This
  3892. information is put out in a format that is not easy for humans to
  3893. read, but which is unambiguous for a program: each file name is
  3894. preceded by either a @samp{Y} if the file is present in the archive,
  3895. an @samp{N} if the file is not included in the archive, or a @samp{D}
  3896. if the file is a directory (and is included in the archive). Each
  3897. file name is terminated by a null character. The last file is
  3898. followed by an additional null and a newline to indicate the end of
  3899. the data.
  3900. If the @value{op-incremental} option is used with @value{op-extract}, then
  3901. when the entry for a directory is found, all files that currently
  3902. exist in that directory but are not listed in the archive @emph{are
  3903. deleted from the directory}.
  3904. This behavior is convenient when you are restoring a damaged file
  3905. system from a succession of incremental backups: it restores the
  3906. entire state of the file system to that which obtained when the backup
  3907. was made. If you don't use @value{op-incremental}, the file system will
  3908. probably fill up with files that shouldn't exist any more.
  3909. @value{op-listed-incremental} handle new @acronym{GNU}-format
  3910. incremental backup. This option handles new @acronym{GNU}-format
  3911. incremental backup. It has much the same effect as
  3912. @value{op-incremental}, but also the time when the dump is done and
  3913. the list of directories dumped is written to the given
  3914. @var{file}. When restoring, only files newer than the saved time are
  3915. restored, and the directory list is used to speed up operations.
  3916. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  3917. used in conjunction with @value{op-create} will also cause @command{tar} to
  3918. use the file @var{file}, which contains information about the state
  3919. of the filesystem at the time of the last backup, to decide which
  3920. files to include in the archive being created. That file will then
  3921. be updated by @command{tar}. If the file @var{file} does not exist when
  3922. this option is specified, @command{tar} will create it, and include all
  3923. appropriate files in the archive.
  3924. The file, which is archive independent, contains the date it was last
  3925. modified and a list of devices, inode numbers and directory names.
  3926. @command{tar} will archive files with newer mod dates or inode change
  3927. times, and directories with an unchanged inode number and device but
  3928. a changed directory name. The file is updated after the files to
  3929. be archived are determined, but before the new archive is actually
  3930. created.
  3931. @node Inc Dumps
  3932. @section Using @command{tar} to Perform Incremental Dumps
  3933. @UNREVISED
  3934. @cindex incremental dumps
  3935. @cindex dumps, incremental
  3936. Performing incremental dumps is similar to performing full dumps,
  3937. although a few more options will usually be needed.
  3938. A standard scheme is to do a @emph{monthly} (full) dump once a month,
  3939. a @emph{weekly} dump once a week of everything since the last monthly
  3940. and a @emph{daily} every day of everything since the last (weekly or
  3941. monthly) dump.
  3942. Here is a sample script to dump the directory hierarchies @samp{/usr}
  3943. and @samp{/var}.
  3944. @smallexample
  3945. #! /bin/sh
  3946. tar --create \
  3947. --blocking-factor=126 \
  3948. --file=/dev/rmt/0 \
  3949. --label="`hostname` /usr /var `date +%Y-%m-%d`" \
  3950. --listed-incremental=/var/log/usr-var.snar \
  3951. --verbose \
  3952. /usr /var
  3953. @end smallexample
  3954. This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
  3955. store information about the previous tar dump.
  3956. The blocking factor 126 is an attempt to make the tape drive stream.
  3957. Some tape devices cannot handle 64 kB blocks or larger, and require the
  3958. block size to be a multiple of 1 kB; for these devices, 126 is the
  3959. largest blocking factor that can be used.
  3960. @node incremental and listed-incremental
  3961. @section The Incremental Options
  3962. @UNREVISED
  3963. @value{op-incremental} is used in conjunction with @value{op-create},
  3964. @value{op-extract} or @value{op-list} when backing up and restoring file
  3965. systems. An archive cannot be extracted or listed with the
  3966. @value{op-incremental} option specified unless it was created with the
  3967. option specified. This option should only be used by a script, not by
  3968. the user, and is usually disregarded in favor of
  3969. @value{op-listed-incremental}, which is described below.
  3970. @value{op-incremental} in conjunction with @value{op-create} causes
  3971. @command{tar} to write, at the beginning of the archive, an entry for
  3972. each of the directories that will be archived. The entry for a
  3973. directory includes a list of all the files in the directory at the
  3974. time the archive was created and a flag for each file indicating
  3975. whether or not the file is going to be put in the archive.
  3976. Note that this option causes @command{tar} to create a non-standard
  3977. archive that may not be readable by non-@acronym{GNU} versions of the
  3978. @command{tar} program.
  3979. @value{op-incremental} in conjunction with @value{op-extract} causes
  3980. @command{tar} to read the lists of directory contents previously stored
  3981. in the archive, @emph{delete} files in the file system that did not
  3982. exist in their directories when the archive was created, and then
  3983. extract the files in the archive.
  3984. This behavior is convenient when restoring a damaged file system from
  3985. a succession of incremental backups: it restores the entire state of
  3986. the file system to that which obtained when the backup was made. If
  3987. @value{op-incremental} isn't specified, the file system will probably
  3988. fill up with files that shouldn't exist any more.
  3989. @value{op-incremental} in conjunction with @value{op-list} causes
  3990. @command{tar} to print, for each directory in the archive, the list of
  3991. files in that directory at the time the archive was created. This
  3992. information is put out in a format that is not easy for humans to
  3993. read, but which is unambiguous for a program: each file name is
  3994. preceded by either a @samp{Y} if the file is present in the archive,
  3995. an @samp{N} if the file is not included in the archive, or a @samp{D}
  3996. if the file is a directory (and is included in the archive). Each
  3997. file name is terminated by a null character. The last file is followed
  3998. by an additional null and a newline to indicate the end of the data.
  3999. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  4000. used in conjunction with @value{op-create} will also cause @command{tar}
  4001. to use the file @var{snapshot-file}, which contains information about
  4002. the state of the file system at the time of the last backup, to decide
  4003. which files to include in the archive being created. That file will
  4004. then be updated by @command{tar}. If the file @var{file} does not exist
  4005. when this option is specified, @command{tar} will create it, and include
  4006. all appropriate files in the archive.
  4007. The file @var{file}, which is archive independent, contains the date
  4008. it was last modified and a list of devices, inode numbers and
  4009. directory names. @command{tar} will archive files with newer mod dates
  4010. or inode change times, and directories with an unchanged inode number
  4011. and device but a changed directory name. The file is updated after
  4012. the files to be archived are determined, but before the new archive is
  4013. actually created.
  4014. Incremental dumps depend crucially on time stamps, so the results are
  4015. unreliable if you modify a file's time stamps during dumping (e.g.@:
  4016. with the @samp{--atime-preserve} option), or if you set the clock
  4017. backwards.
  4018. Despite it should be obvious that a device has a non-volatile value, NFS
  4019. devices have non-dependable values when an automounter gets in the picture.
  4020. This led to a great deal of spurious redumping in incremental dumps,
  4021. so it is somewhat useless to compare two NFS devices numbers over time.
  4022. So @command{tar} now considers all NFS devices as being equal when it comes
  4023. to comparing directories; this is fairly gross, but there does not seem
  4024. to be a better way to go.
  4025. @command{tar} doesn't access @var{snapshot-file} when
  4026. @value{op-create} or @value{op-list} are specified, but the
  4027. @value{op-listed-incremental} option must still be given. A
  4028. placeholder @var{snapshot-file} can be specified, e.g.,
  4029. @file{/dev/null}.
  4030. @FIXME{this section needs to be written}
  4031. @node Backup Levels
  4032. @section Levels of Backups
  4033. @UNREVISED
  4034. An archive containing all the files in the file system is called a
  4035. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4036. creating a full dump every day. This strategy, however, would waste a
  4037. substantial amount of archive media and user time, as unchanged files
  4038. are daily re-archived.
  4039. It is more efficient to do a full dump only occasionally. To back up
  4040. files between full dumps, you can a incremental dump. A @dfn{level
  4041. one} dump archives all the files that have changed since the last full
  4042. dump.
  4043. A typical dump strategy would be to perform a full dump once a week,
  4044. and a level one dump once a day. This means some versions of files
  4045. will in fact be archived more than once, but this dump strategy makes
  4046. it possible to restore a file system to within one day of accuracy by
  4047. only extracting two archives---the last weekly (full) dump and the
  4048. last daily (level one) dump. The only information lost would be in
  4049. files changed or created since the last daily backup. (Doing dumps
  4050. more than once a day is usually not worth the trouble).
  4051. @GNUTAR{} comes with scripts you can use to do full
  4052. and level-one dumps. Using scripts (shell programs) to perform
  4053. backups and restoration is a convenient and reliable alternative to
  4054. typing out file name lists and @command{tar} commands by hand.
  4055. Before you use these scripts, you need to edit the file
  4056. @file{backup-specs}, which specifies parameters used by the backup
  4057. scripts and by the restore script. @FIXME{There is no such restore
  4058. script!}@FIXME-xref{Script Syntax}Once the backup parameters
  4059. are set, you can perform backups or restoration by running the
  4060. appropriate script.
  4061. The name of the restore script is @code{restore}. @FIXME{There is
  4062. no such restore script!}The names of the level one and full backup
  4063. scripts are, respectively, @code{level-1} and @code{level-0}.
  4064. The @code{level-0} script also exists under the name @code{weekly}, and
  4065. the @code{level-1} under the name @code{daily}---these additional names
  4066. can be changed according to your backup schedule. @FIXME-xref{Scripted
  4067. Restoration, for more information on running the restoration script.}
  4068. @FIXME-xref{Scripted Backups, for more information on running the
  4069. backup scripts.}
  4070. @emph{Please Note:} The backup scripts and the restoration scripts are
  4071. designed to be used together. While it is possible to restore files by
  4072. hand from an archive which was created using a backup script, and to create
  4073. an archive by hand which could then be extracted using the restore script,
  4074. it is easier to use the scripts.@FIXME{There is no such restore script!}
  4075. @value{xref-incremental}, and @value{xref-listed-incremental},
  4076. before making such an attempt.
  4077. @FIXME{shorten node names}
  4078. @node Backup Parameters
  4079. @section Setting Parameters for Backups and Restoration
  4080. @UNREVISED
  4081. The file @file{backup-specs} specifies backup parameters for the
  4082. backup and restoration scripts provided with @command{tar}. You must
  4083. edit @file{backup-specs} to fit your system configuration and schedule
  4084. before using these scripts.
  4085. @FIXME{This about backup scripts needs to be written: BS is a shell
  4086. script .... thus ... @file{backup-specs} is in shell script syntax.}
  4087. @FIXME-xref{Script Syntax, for an explanation of this syntax.}
  4088. @FIXME{Whats a parameter .... looked at by the backup scripts
  4089. ... which will be expecting to find ... now syntax ... value is linked
  4090. to lame ... @file{backup-specs} specifies the following parameters:}
  4091. @table @samp
  4092. @item ADMINISTRATOR
  4093. The user name of the backup administrator.
  4094. @item BACKUP_HOUR
  4095. The hour at which the backups are done. This can be a number from 0
  4096. to 23, or the string @samp{now}.
  4097. @item TAPE_FILE
  4098. The device @command{tar} writes the archive to. This device should be
  4099. attached to the host on which the dump scripts are run.
  4100. @FIXME{examples for all ...}
  4101. @item TAPE_STATUS
  4102. The command to use to obtain the status of the archive device,
  4103. including error count. On some tape drives there may not be such a
  4104. command; in that case, simply use @samp{TAPE_STATUS=false}.
  4105. @item BLOCKING
  4106. The blocking factor @command{tar} will use when writing the dump archive.
  4107. @value{xref-blocking-factor}.
  4108. @item BACKUP_DIRS
  4109. A list of file systems to be dumped. You can include any directory
  4110. name in the list---subdirectories on that file system will be
  4111. included, regardless of how they may look to other networked machines.
  4112. Subdirectories on other file systems will be ignored.
  4113. The host name specifies which host to run @command{tar} on, and should
  4114. normally be the host that actually contains the file system. However,
  4115. the host machine must have @GNUTAR{} installed, and
  4116. must be able to access the directory containing the backup scripts and
  4117. their support files using the same file name that is used on the
  4118. machine where the scripts are run (ie. what @command{pwd} will print
  4119. when in that directory on that machine). If the host that contains
  4120. the file system does not have this capability, you can specify another
  4121. host as long as it can access the file system through NFS.
  4122. @item BACKUP_FILES
  4123. A list of individual files to be dumped. These should be accessible
  4124. from the machine on which the backup script is run.
  4125. @FIXME{Same file name, be specific. Through NFS ...}
  4126. @end table
  4127. @menu
  4128. * backup-specs example:: An Example Text of @file{Backup-specs}
  4129. * Script Syntax:: Syntax for @file{Backup-specs}
  4130. @end menu
  4131. @node backup-specs example
  4132. @subsection An Example Text of @file{Backup-specs}
  4133. @UNREVISED
  4134. The following is the text of @file{backup-specs} as it appears at FSF:
  4135. @smallexample
  4136. # site-specific parameters for file system backup.
  4137. ADMINISTRATOR=friedman
  4138. BACKUP_HOUR=1
  4139. TAPE_FILE=/dev/nrsmt0
  4140. TAPE_STATUS="mts -t $TAPE_FILE"
  4141. BLOCKING=124
  4142. BACKUP_DIRS="
  4143. albert:/fs/fsf
  4144. apple-gunkies:/gd
  4145. albert:/fs/gd2
  4146. albert:/fs/gp
  4147. geech:/usr/jla
  4148. churchy:/usr/roland
  4149. albert:/
  4150. albert:/usr
  4151. apple-gunkies:/
  4152. apple-gunkies:/usr
  4153. gnu:/hack
  4154. gnu:/u
  4155. apple-gunkies:/com/mailer/gnu
  4156. apple-gunkies:/com/archive/gnu"
  4157. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4158. @end smallexample
  4159. @node Script Syntax
  4160. @subsection Syntax for @file{Backup-specs}
  4161. @UNREVISED
  4162. @file{backup-specs} is in shell script syntax. The following
  4163. conventions should be considered when editing the script:
  4164. @FIXME{"conventions?"}
  4165. A quoted string is considered to be contiguous, even if it is on more
  4166. than one line. Therefore, you cannot include commented-out lines
  4167. within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
  4168. the two most likely parameters to be multi-line.
  4169. A quoted string typically cannot contain wildcards. In
  4170. @file{backup-specs}, however, the parameters BACKUP_DIRS and
  4171. BACKUP_FILES can contain wildcards.
  4172. @node Scripted Backups
  4173. @section Using the Backup Scripts
  4174. @UNREVISED
  4175. The syntax for running a backup script is:
  4176. @smallexample
  4177. @file{script-name} [@var{time-to-be-run}]
  4178. @end smallexample
  4179. where @var{time-to-be-run} can be a specific system time, or can be
  4180. @kbd{now}. If you do not specify a time, the script runs at the time
  4181. specified in @file{backup-specs}. @FIXME-pxref{Script Syntax}
  4182. You should start a script with a tape or disk mounted. Once you
  4183. start a script, it prompts you for new tapes or disks as it
  4184. needs them. Media volumes don't have to correspond to archive
  4185. files---a multi-volume archive can be started in the middle of a
  4186. tape that already contains the end of another multi-volume archive.
  4187. The @code{restore} script prompts for media by its archive volume,
  4188. so to avoid an error message you should keep track of which tape
  4189. (or disk) contains which volume of the archive. @FIXME{There is
  4190. no such restore script!} @FIXME-xref{Scripted Restoration}
  4191. @FIXME{Have file names changed?}
  4192. The backup scripts write two files on the file system. The first is a
  4193. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4194. to store and retrieve information about which files were dumped. This
  4195. file is not meant to be read by humans, and should not be deleted by
  4196. them. @FIXME-xref{incremental and listed-incremental, for a more
  4197. detailed explanation of this file.}
  4198. The second file is a log file containing the names of the file systems
  4199. and files dumped, what time the backup was made, and any error
  4200. messages that were generated, as well as how much space was left in
  4201. the media volume after the last volume of the archive was written.
  4202. You should check this log file after every backup. The file name is
  4203. @file{log-@var{mmm-ddd-yyyy}-level-1} or
  4204. @file{log-@var{mmm-ddd-yyyy}-full}.
  4205. The script also prints the name of each system being dumped to the
  4206. standard output.
  4207. @node Scripted Restoration
  4208. @section Using the Restore Script
  4209. @UNREVISED
  4210. @ifset PUBLISH
  4211. The @command{tar} distribution does not provide restoring scripts.
  4212. @end ifset
  4213. @ifclear PUBLISH
  4214. @quotation
  4215. @strong{Warning:} The @GNUTAR{} distribution does @emph{not}
  4216. provide any such @code{restore} script yet. This section is only
  4217. listed here for documentation maintenance purposes. In any case,
  4218. all contents is subject to change as things develop.
  4219. @end quotation
  4220. @FIXME{A section on non-scripted restore may be a good idea.}
  4221. To restore files that were archived using a scripted backup, use the
  4222. @code{restore} script. The syntax for the script is:
  4223. where ***** are the file systems to restore from, and
  4224. ***** is a regular expression which specifies which files to
  4225. restore. If you specify --all, the script restores all the files
  4226. in the file system.
  4227. You should start the restore script with the media containing the
  4228. first volume of the archive mounted. The script will prompt for other
  4229. volumes as they are needed. If the archive is on tape, you don't need
  4230. to rewind the tape to to its beginning---if the tape head is
  4231. positioned past the beginning of the archive, the script will rewind
  4232. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4233. positioning.}
  4234. If you specify @samp{--all} as the @var{files} argument, the
  4235. @code{restore} script extracts all the files in the archived file
  4236. system into the active file system.
  4237. @quotation
  4238. @strong{Warning:} The script will delete files from the active file
  4239. system if they were not in the file system when the archive was made.
  4240. @end quotation
  4241. @value{xref-incremental}, and @value{ref-listed-incremental},
  4242. for an explanation of how the script makes that determination.
  4243. @FIXME{this may be an option, not a given}
  4244. @end ifclear
  4245. @node Choosing
  4246. @chapter Choosing Files and Names for @command{tar}
  4247. @UNREVISED
  4248. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4249. Certain options to @command{tar} enable you to specify a name for your
  4250. archive. Other options let you decide which files to include or exclude
  4251. from the archive, based on when or whether files were modified, whether
  4252. the file names do or don't match specified patterns, or whether files
  4253. are in specified directories.
  4254. @menu
  4255. * file:: Choosing the Archive's Name
  4256. * Selecting Archive Members::
  4257. * files:: Reading Names from a File
  4258. * exclude:: Excluding Some Files
  4259. * Wildcards::
  4260. * after:: Operating Only on New Files
  4261. * recurse:: Descending into Directories
  4262. * one:: Crossing Filesystem Boundaries
  4263. @end menu
  4264. @node file
  4265. @section Choosing and Naming Archive Files
  4266. @cindex Naming an archive
  4267. @cindex Archive Name
  4268. @cindex Directing output
  4269. @cindex Choosing an archive file
  4270. @cindex Where is the archive?
  4271. @UNREVISED
  4272. @FIXME{should the title of this section actually be, "naming an
  4273. archive"?}
  4274. By default, @command{tar} uses an archive file name that was compiled when
  4275. it was built on the system; usually this name refers to some physical
  4276. tape drive on the machine. However, the person who installed @command{tar}
  4277. on the system may not set the default to a meaningful value as far as
  4278. most users are concerned. As a result, you will usually want to tell
  4279. @command{tar} where to find (or create) the archive. The @value{op-file}
  4280. option allows you to either specify or name a file to use as the archive
  4281. instead of the default archive file location.
  4282. @table @kbd
  4283. @item --file=@var{archive-name}
  4284. @itemx -f @var{archive-name}
  4285. Name the archive to create or operate on. Use in conjunction with
  4286. any operation.
  4287. @end table
  4288. For example, in this @command{tar} command,
  4289. @smallexample
  4290. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4291. @end smallexample
  4292. @noindent
  4293. @file{collection.tar} is the name of the archive. It must directly
  4294. follow the @samp{-f} option, since whatever directly follows @samp{-f}
  4295. @emph{will} end up naming the archive. If you neglect to specify an
  4296. archive name, you may end up overwriting a file in the working directory
  4297. with the archive you create since @command{tar} will use this file's name
  4298. for the archive name.
  4299. An archive can be saved as a file in the file system, sent through a
  4300. pipe or over a network, or written to an I/O device such as a tape,
  4301. floppy disk, or CD write drive.
  4302. @cindex Writing new archives
  4303. @cindex Archive creation
  4304. If you do not name the archive, @command{tar} uses the value of the
  4305. environment variable @env{TAPE} as the file name for the archive. If
  4306. that is not available, @command{tar} uses a default, compiled-in archive
  4307. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4308. @command{tar} always needs an archive name.
  4309. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4310. archive from standard input (when listing or extracting files), or
  4311. writes it to standard output (when creating an archive). If you use
  4312. @file{-} as an @var{archive-name} when modifying an archive,
  4313. @command{tar} reads the original archive from its standard input and
  4314. writes the entire new archive to its standard output.
  4315. @FIXME{might want a different example here; this is already used in
  4316. "notable tar usages".}
  4317. @smallexample
  4318. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4319. @end smallexample
  4320. @FIXME{help!}
  4321. @cindex Standard input and output
  4322. @cindex tar to standard input and output
  4323. To specify an archive file on a device attached to a remote machine,
  4324. use the following:
  4325. @smallexample
  4326. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4327. @end smallexample
  4328. @noindent
  4329. @command{tar} will complete the remote connection, if possible, and
  4330. prompt you for a username and password. If you use
  4331. @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4332. will complete the remote connection, if possible, using your username
  4333. as the username on the remote machine.
  4334. If the archive file name includes a colon (@samp{:}), then it is assumed
  4335. to be a file on another machine. If the archive file is
  4336. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4337. host @var{host}. The remote host is accessed using the @command{rsh}
  4338. program, with a username of @var{user}. If the username is omitted
  4339. (along with the @samp{@@} sign), then your user name will be used.
  4340. (This is the normal @command{rsh} behavior.) It is necessary for the
  4341. remote machine, in addition to permitting your @command{rsh} access, to
  4342. have the @file{/usr/ucb/rmt} program installed. If you need to use a
  4343. file whose name includes a colon, then the remote tape drive behavior
  4344. can be inhibited by using the @value{op-force-local} option.
  4345. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4346. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4347. into what came before it well enough <<i moved it now, is it better
  4348. here?>>. bob also comments that if Amanda isn't free software, we
  4349. shouldn't mention it..}
  4350. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4351. tries to minimize input and output operations. The
  4352. Amanda backup system, when used with @GNUTAR{}, has
  4353. an initial sizing pass which uses this feature.
  4354. @node Selecting Archive Members
  4355. @section Selecting Archive Members
  4356. @cindex Specifying files to act on
  4357. @cindex Specifying archive members
  4358. @dfn{File Name arguments} specify which files in the file system
  4359. @command{tar} operates on, when creating or adding to an archive, or which
  4360. archive members @command{tar} operates on, when reading or deleting from
  4361. an archive. @xref{Operations}.
  4362. To specify file names, you can include them as the last arguments on
  4363. the command line, as follows:
  4364. @smallexample
  4365. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4366. @end smallexample
  4367. If you specify a directory name as a file name argument, all the files
  4368. in that directory are operated on by @command{tar}.
  4369. If you do not specify files when @command{tar} is invoked with
  4370. @value{op-create}, @command{tar} operates on all the non-directory files in
  4371. the working directory. If you specify either @value{op-list} or
  4372. @value{op-extract}, @command{tar} operates on all the archive members in the
  4373. archive. If you specify any operation other than one of these three,
  4374. @command{tar} does nothing.
  4375. By default, @command{tar} takes file names from the command line. However,
  4376. there are other ways to specify file or member names, or to modify the
  4377. manner in which @command{tar} selects the files or members upon which to
  4378. operate. @FIXME{add xref here}In general, these methods work both for
  4379. specifying the names of files and archive members.
  4380. @node files
  4381. @section Reading Names from a File
  4382. @UNREVISED
  4383. @cindex Reading file names from a file
  4384. @cindex Lists of file names
  4385. @cindex File Name arguments, alternatives
  4386. Instead of giving the names of files or archive members on the command
  4387. line, you can put the names into a file, and then use the
  4388. @value{op-files-from} option to @command{tar}. Give the name of the file
  4389. which contains the list of files to include as the argument to
  4390. @samp{--files-from}. In the list, the file names should be separated by
  4391. newlines. You will frequently use this option when you have generated
  4392. the list of files to archive with the @command{find} utility.
  4393. @table @kbd
  4394. @item --files-from=@var{file name}
  4395. @itemx -T @var{file name}
  4396. Get names to extract or create from file @var{file name}.
  4397. @end table
  4398. If you give a single dash as a file name for @samp{--files-from}, (i.e.,
  4399. you specify either @samp{--files-from=-} or @samp{-T -}), then the file
  4400. names are read from standard input.
  4401. Unless you are running @command{tar} with @samp{--create}, you can not use
  4402. both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
  4403. command.
  4404. @FIXME{add bob's example, from his message on 2-10-97}
  4405. The following example shows how to use @command{find} to generate a list of
  4406. files smaller than 400K in length and put that list into a file
  4407. called @file{small-files}. You can then use the @samp{-T} option to
  4408. @command{tar} to specify the files from that file, @file{small-files}, to
  4409. create the archive @file{little.tgz}. (The @samp{-z} option to
  4410. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4411. more information.)
  4412. @smallexample
  4413. $ @kbd{find . -size -400 -print > small-files}
  4414. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4415. @end smallexample
  4416. @noindent
  4417. @FIXME{say more here to conclude the example/section?}
  4418. @menu
  4419. * nul::
  4420. @end menu
  4421. @node nul
  4422. @subsection @kbd{NUL} Terminated File Names
  4423. @cindex File names, terminated by @kbd{NUL}
  4424. @cindex @kbd{NUL} terminated file names
  4425. The @value{op-null} option causes @value{op-files-from} to read file
  4426. names terminated by a @code{NUL} instead of a newline, so files whose
  4427. names contain newlines can be archived using @samp{--files-from}.
  4428. @table @kbd
  4429. @item --null
  4430. Only consider @kbd{NUL} terminated file names, instead of files that
  4431. terminate in a newline.
  4432. @end table
  4433. The @samp{--null} option is just like the one in @acronym{GNU}
  4434. @command{xargs} and @command{cpio}, and is useful with the
  4435. @samp{-print0} predicate of @acronym{GNU} @command{find}. In
  4436. @command{tar}, @samp{--null} also causes @value{op-directory} options
  4437. to be treated as file names to archive, in case there are any files
  4438. out there called @file{-C}.
  4439. This example shows how to use @command{find} to generate a list of files
  4440. larger than 800K in length and put that list into a file called
  4441. @file{long-files}. The @samp{-print0} option to @command{find} just just
  4442. like @samp{-print}, except that it separates files with a @kbd{NUL}
  4443. rather than with a newline. You can then run @command{tar} with both the
  4444. @samp{--null} and @samp{-T} options to specify that @command{tar} get the
  4445. files from that file, @file{long-files}, to create the archive
  4446. @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
  4447. @command{tar} to recognize the @kbd{NUL} separator between files.
  4448. @smallexample
  4449. $ @kbd{find . -size +800 -print0 > long-files}
  4450. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4451. @end smallexample
  4452. @FIXME{say anything else here to conclude the section?}
  4453. @node exclude
  4454. @section Excluding Some Files
  4455. @cindex File names, excluding files by
  4456. @cindex Excluding files by name and pattern
  4457. @cindex Excluding files by file system
  4458. @UNREVISED
  4459. To avoid operating on files whose names match a particular pattern,
  4460. use the @value{op-exclude} or @value{op-exclude-from} options.
  4461. @table @kbd
  4462. @item --exclude=@var{pattern}
  4463. Causes @command{tar} to ignore files that match the @var{pattern}.
  4464. @end table
  4465. @findex exclude
  4466. The @value{op-exclude} option prevents any file or member whose name
  4467. matches the shell wildcard (@var{pattern}) from being operated on.
  4468. For example, to create an archive with all the contents of the directory
  4469. @file{src} except for files whose names end in @file{.o}, use the
  4470. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4471. You may give multiple @samp{--exclude} options.
  4472. @table @kbd
  4473. @item --exclude-from=@var{file}
  4474. @itemx -X @var{file}
  4475. Causes @command{tar} to ignore files that match the patterns listed in
  4476. @var{file}.
  4477. @end table
  4478. @findex exclude-from
  4479. Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
  4480. list of patterns, one per line, from @var{file}; @command{tar} will
  4481. ignore files matching those patterns. Thus if @command{tar} is
  4482. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4483. single line @file{*.o}, no files whose names end in @file{.o} will be
  4484. added to the archive.
  4485. @FIXME{do the exclude options files need to have stuff separated by
  4486. newlines the same as the files-from option does?}
  4487. @menu
  4488. * controlling pattern-patching with exclude::
  4489. * problems with exclude::
  4490. @end menu
  4491. @node controlling pattern-patching with exclude
  4492. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  4493. Normally, a pattern matches a name if an initial subsequence of the
  4494. name's components matches the pattern, where @samp{*}, @samp{?}, and
  4495. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  4496. and wildcards can match @samp{/}.
  4497. Other than optionally stripping leading @samp{/} from names
  4498. (@pxref{absolute}), patterns and names are used as-is. For
  4499. example, trailing @samp{/} is not trimmed from a user-specified name
  4500. before deciding whether to exclude it.
  4501. However, this matching procedure can be altered by the options listed
  4502. below. These options accumulate. For example:
  4503. @smallexample
  4504. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  4505. @end smallexample
  4506. ignores case when excluding @samp{makefile}, but not when excluding
  4507. @samp{readme}.
  4508. @table @option
  4509. @item --anchored
  4510. @itemx --no-anchored
  4511. If anchored (the default), a pattern must match an initial subsequence
  4512. of the name's components. Otherwise, the pattern can match any subsequence.
  4513. @item --ignore-case
  4514. @itemx --no-ignore-case
  4515. When ignoring case, upper-case patterns match lower-case names and vice versa.
  4516. When not ignoring case (the default), matching is case-sensitive.
  4517. @item --wildcards
  4518. @itemx --no-wildcards
  4519. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  4520. are the usual shell wildcards, and @samp{\} escapes wildcards.
  4521. Otherwise, none of these characters are special, and patterns must match
  4522. names literally.
  4523. @item --wildcards-match-slash
  4524. @itemx --no-wildcards-match-slash
  4525. When wildcards match slash (the default), a wildcard like @samp{*} in
  4526. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  4527. matched only by @samp{/}.
  4528. @end table
  4529. The @option{--recursion} and @option{--no-recursion} options
  4530. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  4531. recursion is in effect, a pattern excludes a name if it matches any of
  4532. the name's parent directories.
  4533. @node problems with exclude
  4534. @unnumberedsubsec Problems with Using the @code{exclude} Options
  4535. Some users find @samp{exclude} options confusing. Here are some common
  4536. pitfalls:
  4537. @itemize @bullet
  4538. @item
  4539. The main operating mode of @command{tar} does not act on a path name
  4540. explicitly listed on the command line if one of its file name
  4541. components is excluded. In the example above, if
  4542. you create an archive and exclude files that end with @samp{*.o}, but
  4543. explicitly name the file @samp{dir.o/foo} after all the options have been
  4544. listed, @samp{dir.o/foo} will be excluded from the archive.
  4545. @item
  4546. You can sometimes confuse the meanings of @value{op-exclude} and
  4547. @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
  4548. to be excluded are given as a pattern on the command line. Use
  4549. @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
  4550. file which contains a list of patterns, one per line; each of these
  4551. patterns can exclude zero, one, or many files.
  4552. @item
  4553. When you use @value{op-exclude}, be sure to quote the @var{pattern}
  4554. parameter, so @GNUTAR{} sees wildcard characters
  4555. like @samp{*}. If you do not do this, the shell might expand the
  4556. @samp{*} itself using files at hand, so @command{tar} might receive a
  4557. list of files instead of one pattern, or none at all, making the
  4558. command somewhat illegal. This might not correspond to what you want.
  4559. For example, write:
  4560. @smallexample
  4561. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  4562. @end smallexample
  4563. @noindent
  4564. rather than:
  4565. @smallexample
  4566. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  4567. @end smallexample
  4568. @item
  4569. You must use use shell syntax, or globbing, rather than @code{regexp}
  4570. syntax, when using exclude options in @command{tar}. If you try to use
  4571. @code{regexp} syntax to describe files to be excluded, your command
  4572. might fail.
  4573. @item
  4574. In earlier versions of @command{tar}, what is now the
  4575. @samp{--exclude-from=@var{file-of-patterns}} option was called
  4576. @samp{--exclude=@var{pattern}} instead. Now,
  4577. @samp{--exclude=@var{pattern}} applies to patterns listed on the command
  4578. line and @samp{--exclude-from=@var{file-of-patterns}} applies to
  4579. patterns listed in a file.
  4580. @end itemize
  4581. @node Wildcards
  4582. @section Wildcards Patterns and Matching
  4583. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  4584. @samp{*} or @samp{?} for example, are replaced and expanded into all
  4585. existing files matching the given pattern. However, @command{tar} often
  4586. uses wildcard patterns for matching (or globbing) archive members instead
  4587. of actual files in the filesystem. Wildcard patterns are also used for
  4588. verifying volume labels of @command{tar} archives. This section has the
  4589. purpose of explaining wildcard syntax for @command{tar}.
  4590. @FIXME{the next few paragraphs need work.}
  4591. A @var{pattern} should be written according to shell syntax, using wildcard
  4592. characters to effect globbing. Most characters in the pattern stand
  4593. for themselves in the matched string, and case is significant: @samp{a}
  4594. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  4595. pattern matches any single character in the matched string. The character
  4596. @samp{*} in the pattern matches zero, one, or more single characters in
  4597. the matched string. The character @samp{\} says to take the following
  4598. character of the pattern @emph{literally}; it is useful when one needs to
  4599. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  4600. The character @samp{[}, up to the matching @samp{]}, introduces a character
  4601. class. A @dfn{character class} is a list of acceptable characters
  4602. for the next single character of the matched string. For example,
  4603. @samp{[abcde]} would match any of the first five letters of the alphabet.
  4604. Note that within a character class, all of the ``special characters''
  4605. listed above other than @samp{\} lose their special meaning; for example,
  4606. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  4607. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  4608. the characters @samp{-} and @samp{]} must either come @emph{first} or
  4609. @emph{last} in a character class.)
  4610. @cindex Excluding characters from a character class
  4611. @cindex Character class, excluding characters from
  4612. If the first character of the class after the opening @samp{[}
  4613. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  4614. Rather than listing character to match, it lists those characters which
  4615. are @emph{forbidden} as the next single character of the matched string.
  4616. Other characters of the class stand for themselves. The special
  4617. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  4618. letters, is meant to represent all characters between @var{a} and
  4619. @var{e}, inclusive.
  4620. @FIXME{need to add a sentence or so here to make this clear for those
  4621. who don't have dan around.}
  4622. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  4623. special for wildcard matches. However, if a pattern completely matches
  4624. a directory prefix of a matched string, then it matches the full matched
  4625. string: excluding a directory also excludes all the files beneath it.
  4626. @node after
  4627. @section Operating Only on New Files
  4628. @cindex Excluding file by age
  4629. @cindex Modification time, excluding files by
  4630. @cindex Age, excluding files by
  4631. @UNREVISED
  4632. The @value{op-after-date} option causes @command{tar} to only work on files
  4633. whose modification or inode-changed times are newer than the @var{date}
  4634. given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
  4635. be a file name; the last-modified time of that file is used as the date.
  4636. If you use this option when creating or appending to an archive,
  4637. the archive will only include new files. If you use @samp{--after-date}
  4638. when extracting an archive, @command{tar} will only extract files newer
  4639. than the @var{date} you specify.
  4640. If you only want @command{tar} to make the date comparison based on
  4641. modification of the actual contents of the file (rather than inode
  4642. changes), then use the @value{op-newer-mtime} option.
  4643. You may use these options with any operation. Note that these options
  4644. differ from the @value{op-update} operation in that they allow you to
  4645. specify a particular date against which @command{tar} can compare when
  4646. deciding whether or not to archive the files.
  4647. @table @kbd
  4648. @item --after-date=@var{date}
  4649. @itemx --newer=@var{date}
  4650. @itemx -N @var{date}
  4651. Only store files newer than @var{date}.
  4652. Acts on files only if their modification or inode-changed times are
  4653. later than @var{date}. Use in conjunction with any operation.
  4654. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  4655. name; the last-modified time of that file is used as the date.
  4656. @item --newer-mtime=@var{date}
  4657. Acts like @value{op-after-date}, but only looks at modification times.
  4658. @end table
  4659. These options limit @command{tar} to only operating on files which have
  4660. been modified after the date specified. A file is considered to have
  4661. changed if the contents have been modified, or if the owner,
  4662. permissions, and so forth, have been changed. (For more information on
  4663. how to specify a date, see @ref{Date input formats}; remember that the
  4664. entire date argument must be quoted if it contains any spaces.)
  4665. Gurus would say that @value{op-after-date} tests both the @code{mtime}
  4666. (time the contents of the file were last modified) and @code{ctime}
  4667. (time the file's status was last changed: owner, permissions, etc)
  4668. fields, while @value{op-newer-mtime} tests only @code{mtime} field.
  4669. To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
  4670. @code{ctime} and processes the file if either one is more recent than
  4671. @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
  4672. disregards @code{ctime}. Neither uses @code{atime} (the last time the
  4673. contents of the file were looked at).
  4674. Date specifiers can have embedded spaces. Because of this, you may need
  4675. to quote date arguments to keep the shell from parsing them as separate
  4676. arguments.
  4677. @FIXME{Need example of --newer-mtime with quoted argument.}
  4678. @quotation
  4679. @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
  4680. should not be used for incremental backups. Some files (such as those
  4681. in renamed directories) are not selected properly by these options.
  4682. @xref{incremental and listed-incremental}.
  4683. @end quotation
  4684. @noindent
  4685. @FIXME{which tells -- need to fill this in!}
  4686. @node recurse
  4687. @section Descending into Directories
  4688. @cindex Avoiding recursion in directories
  4689. @cindex Descending directories, avoiding
  4690. @cindex Directories, avoiding recursion
  4691. @cindex Recursion in directories, avoiding
  4692. @UNREVISED
  4693. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  4694. @FIXME{show dan bob's comments, from 2-10-97}
  4695. Usually, @command{tar} will recursively explore all directories (either
  4696. those given on the command line or through the @value{op-files-from}
  4697. option) for the various files they contain. However, you may not always
  4698. want @command{tar} to act this way.
  4699. The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
  4700. into specified directories. If you specify @samp{--no-recursion}, you can
  4701. use the @command{find} utility for hunting through levels of directories to
  4702. construct a list of file names which you could then pass to @command{tar}.
  4703. @command{find} allows you to be more selective when choosing which files to
  4704. archive; see @ref{files} for more information on using @command{find} with
  4705. @command{tar}, or look.
  4706. @table @kbd
  4707. @item --no-recursion
  4708. Prevents @command{tar} from recursively descending directories.
  4709. @item --recursion
  4710. Requires @command{tar} to recursively descend directories.
  4711. This is the default.
  4712. @end table
  4713. When you use @samp{--no-recursion}, @GNUTAR{} grabs
  4714. directory entries themselves, but does not descend on them
  4715. recursively. Many people use @command{find} for locating files they
  4716. want to back up, and since @command{tar} @emph{usually} recursively
  4717. descends on directories, they have to use the @samp{@w{! -d}} option
  4718. to @command{find} @FIXME{needs more explanation or a cite to another
  4719. info file}as they usually do not want all the files in a directory.
  4720. They then use the @value{op-files-from} option to archive the files
  4721. located via @command{find}.
  4722. The problem when restoring files archived in this manner is that the
  4723. directories themselves are not in the archive; so the
  4724. @value{op-same-permissions} option does not affect them---while users
  4725. might really like it to. Specifying @value{op-no-recursion} is a way to
  4726. tell @command{tar} to grab only the directory entries given to it, adding
  4727. no new files on its own.
  4728. The @value{op-no-recursion} option also applies when extracting: it
  4729. causes @command{tar} to extract only the matched directory entries, not
  4730. the files under those directories.
  4731. The @value{op-no-recursion} option also affects how exclude patterns
  4732. are interpreted (@pxref{controlling pattern-patching with exclude}).
  4733. The @option{--no-recursion} and @option{--recursion} options apply to
  4734. later options and operands, and can be overridden by later occurrences
  4735. of @option{--no-recursion} and @option{--recursion}. For example:
  4736. @smallexample
  4737. $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
  4738. @end smallexample
  4739. @noindent
  4740. creates an archive with one entry for @file{grape}, and the recursive
  4741. contents of @file{grape/concord}, but no entries under @file{grape}
  4742. other than @file{grape/concord}.
  4743. @node one
  4744. @section Crossing Filesystem Boundaries
  4745. @cindex File system boundaries, not crossing
  4746. @UNREVISED
  4747. @command{tar} will normally automatically cross file system boundaries in
  4748. order to archive files which are part of a directory tree. You can
  4749. change this behavior by running @command{tar} and specifying
  4750. @value{op-one-file-system}. This option only affects files that are
  4751. archived because they are in a directory that is being archived;
  4752. @command{tar} will still archive files explicitly named on the command line
  4753. or through @value{op-files-from}, regardless of where they reside.
  4754. @table @kbd
  4755. @item --one-file-system
  4756. @itemx -l
  4757. Prevents @command{tar} from crossing file system boundaries when
  4758. archiving. Use in conjunction with any write operation.
  4759. @end table
  4760. The @samp{--one-file-system} option causes @command{tar} to modify its
  4761. normal behavior in archiving the contents of directories. If a file in
  4762. a directory is not on the same filesystem as the directory itself, then
  4763. @command{tar} will not archive that file. If the file is a directory
  4764. itself, @command{tar} will not archive anything beneath it; in other words,
  4765. @command{tar} will not cross mount points.
  4766. It is reported that using this option, the mount point is is archived,
  4767. but nothing under it.
  4768. This option is useful for making full or incremental archival backups of
  4769. a file system. If this option is used in conjunction with
  4770. @value{op-verbose}, files that are excluded are mentioned by name on the
  4771. standard error.
  4772. @menu
  4773. * directory:: Changing Directory
  4774. * absolute:: Absolute File Names
  4775. @end menu
  4776. @node directory
  4777. @subsection Changing the Working Directory
  4778. @FIXME{need to read over this node now for continuity; i've switched
  4779. things around some.}
  4780. @cindex Changing directory mid-stream
  4781. @cindex Directory, changing mid-stream
  4782. @cindex Working directory, specifying
  4783. @UNREVISED
  4784. To change the working directory in the middle of a list of file names,
  4785. either on the command line or in a file specified using
  4786. @value{op-files-from}, use @value{op-directory}. This will change the
  4787. working directory to the directory @var{directory} after that point in
  4788. the list.
  4789. @table @kbd
  4790. @item --directory=@var{directory}
  4791. @itemx -C @var{directory}
  4792. Changes the working directory in the middle of a command line.
  4793. @end table
  4794. For example,
  4795. @smallexample
  4796. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  4797. @end smallexample
  4798. @noindent
  4799. will place the files @file{grape} and @file{prune} from the current
  4800. directory into the archive @file{jams.tar}, followed by the file
  4801. @file{cherry} from the directory @file{food}. This option is especially
  4802. useful when you have several widely separated files that you want to
  4803. store in the same archive.
  4804. Note that the file @file{cherry} is recorded in the archive under the
  4805. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  4806. archive will contain three files that all appear to have come from the
  4807. same directory; if the archive is extracted with plain @samp{tar
  4808. --extract}, all three files will be written in the current directory.
  4809. Contrast this with the command,
  4810. @smallexample
  4811. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  4812. @end smallexample
  4813. @noindent
  4814. which records the third file in the archive under the name
  4815. @file{red/cherry} so that, if the archive is extracted using
  4816. @samp{tar --extract}, the third file will be written in a subdirectory
  4817. named @file{orange-colored}.
  4818. You can use the @samp{--directory} option to make the archive
  4819. independent of the original name of the directory holding the files.
  4820. The following command places the files @file{/etc/passwd},
  4821. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  4822. @file{foo.tar}:
  4823. @smallexample
  4824. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  4825. @end smallexample
  4826. @noindent
  4827. However, the names of the archive members will be exactly what they were
  4828. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  4829. They will not appear to be related by file name to the original
  4830. directories where those files were located.
  4831. Note that @samp{--directory} options are interpreted consecutively. If
  4832. @samp{--directory} specifies a relative file name, it is interpreted
  4833. relative to the then current directory, which might not be the same as
  4834. the original current working directory of @command{tar}, due to a previous
  4835. @samp{--directory} option.
  4836. @FIXME{dan: does this mean that you *can* use the short option form, but
  4837. you can *not* use the long option form with --files-from? or is this
  4838. totally screwed?}
  4839. When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
  4840. options in the file list. Unfortunately, you cannot put
  4841. @samp{--directory} options in the file list. (This interpretation can
  4842. be disabled by using the @value{op-null} option.)
  4843. @node absolute
  4844. @subsection Absolute File Names
  4845. @UNREVISED
  4846. @table @kbd
  4847. @item -P
  4848. @itemx --absolute-names
  4849. Do not strip leading slashes from file names, and permit file names
  4850. containing a @file{..} file name component.
  4851. @end table
  4852. By default, @GNUTAR{} drops a leading @samp{/} on
  4853. input or output, and complains about file names containing a @file{..}
  4854. component. This option turns off this behavior.
  4855. When @command{tar} extracts archive members from an archive, it strips any
  4856. leading slashes (@samp{/}) from the member name. This causes absolute
  4857. member names in the archive to be treated as relative file names. This
  4858. allows you to have such members extracted wherever you want, instead of
  4859. being restricted to extracting the member in the exact directory named
  4860. in the archive. For example, if the archive member has the name
  4861. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  4862. really @file{etc/passwd}.
  4863. File names containing @file{..} can cause problems when extracting, so
  4864. @command{tar} normally warns you about such files when creating an
  4865. archive, and rejects attempts to extracts such files.
  4866. Other @command{tar} programs do not do this. As a result, if you
  4867. create an archive whose member names start with a slash, they will be
  4868. difficult for other people with a non-@GNUTAR{}
  4869. program to use. Therefore, @GNUTAR{} also strips
  4870. leading slashes from member names when putting members into the
  4871. archive. For example, if you ask @command{tar} to add the file
  4872. @file{/bin/ls} to an archive, it will do so, but the member name will
  4873. be @file{bin/ls}.
  4874. If you use the @value{op-absolute-names} option, @command{tar} will do
  4875. none of these transformations.
  4876. To archive or extract files relative to the root directory, specify
  4877. the @value{op-absolute-names} option.
  4878. Normally, @command{tar} acts on files relative to the working
  4879. directory---ignoring superior directory names when archiving, and
  4880. ignoring leading slashes when extracting.
  4881. When you specify @value{op-absolute-names}, @command{tar} stores file names
  4882. including all superior directory names, and preserves leading slashes.
  4883. If you only invoked @command{tar} from the root directory you would never
  4884. need the @value{op-absolute-names} option, but using this option may be
  4885. more convenient than switching to root.
  4886. @FIXME{Should be an example in the tutorial/wizardry section using this
  4887. to transfer files between systems.}
  4888. @FIXME{Is write access an issue?}
  4889. @table @kbd
  4890. @item --absolute-names
  4891. Preserves full file names (including superior directory names) when
  4892. archiving files. Preserves leading slash when extracting files.
  4893. @end table
  4894. @FIXME{this is still horrible; need to talk with dan on monday.}
  4895. @command{tar} prints out a message about removing the @samp{/} from
  4896. file names. This message appears once per @GNUTAR{}
  4897. invocation. It represents something which ought to be told; ignoring
  4898. what it means can cause very serious surprises, later.
  4899. Some people, nevertheless, do not want to see this message. Wanting to
  4900. play really dangerously, one may of course redirect @command{tar} standard
  4901. error to the sink. For example, under @command{sh}:
  4902. @smallexample
  4903. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  4904. @end smallexample
  4905. @noindent
  4906. Another solution, both nicer and simpler, would be to change to
  4907. the @file{/} directory first, and then avoid absolute notation.
  4908. For example:
  4909. @smallexample
  4910. $ @kbd{(cd / && tar -c -f archive.tar home)}
  4911. $ @kbd{tar -c -f archive.tar -C / home}
  4912. @end smallexample
  4913. @include getdate.texi
  4914. @node Formats
  4915. @chapter Controlling the Archive Format
  4916. Due to historical reasons, there are several formats of tar archives.
  4917. All of them are based on the same principles, but have some subtle
  4918. differences that often make them incompatible with each other.
  4919. GNU tar is able to create and handle archives in a variety of formats.
  4920. The most frequently used formats are (in alphabetical order):
  4921. @table @asis
  4922. @item gnu
  4923. Format used by @GNUTAR{}.
  4924. @item v7
  4925. Archive format, compatible with the V7 implementation of tar.
  4926. @item oldgnu
  4927. Format used by @GNUTAR{} of versions prior to 1.12.
  4928. @item posix
  4929. Archive format defined by POSIX.1-2001 specification.
  4930. @item star
  4931. Format used by J@"org Schilling @command{star} implementation.
  4932. @end table
  4933. @GNUTAR{} is able to create archives in any of these formats,
  4934. except @samp{star}. It is able to read archives in any of these
  4935. formats.
  4936. The default format for @GNUTAR{} is defined at compilation
  4937. time. You may check it by running @command{tar --help}, and examining
  4938. the last lines of its output. Usually, @GNUTAR{} is configured
  4939. to create archives in @samp{gnu} format, however, future version will
  4940. switch to @samp{posix}.
  4941. @menu
  4942. * Portability:: Making @command{tar} Archives More Portable
  4943. * Compression:: Using Less Space through Compression
  4944. * Attributes:: Handling File Attributes
  4945. * Standard:: The Standard Format
  4946. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  4947. * cpio:: Comparison of @command{tar} and @command{cpio}
  4948. @end menu
  4949. @node Portability
  4950. @section Making @command{tar} Archives More Portable
  4951. Creating a @command{tar} archive on a particular system that is meant to be
  4952. useful later on many other machines and with other versions of @command{tar}
  4953. is more challenging than you might think. @command{tar} archive formats
  4954. have been evolving since the first versions of Unix. Many such formats
  4955. are around, and are not always compatible with each other. This section
  4956. discusses a few problems, and gives some advice about making @command{tar}
  4957. archives more portable.
  4958. One golden rule is simplicity. For example, limit your @command{tar}
  4959. archives to contain only regular files and directories, avoiding
  4960. other kind of special files. Do not attempt to save sparse files or
  4961. contiguous files as such. Let's discuss a few more problems, in turn.
  4962. @menu
  4963. * Portable Names:: Portable Names
  4964. * dereference:: Symbolic Links
  4965. * old:: Old V7 Archives
  4966. * gnu:: GNU and old GNU format archives.
  4967. * posix:: @sc{posix} archives
  4968. * Checksumming:: Checksumming Problems
  4969. * Large or Negative Values:: Large files, negative time stamps, etc.
  4970. @end menu
  4971. @node Portable Names
  4972. @subsection Portable Names
  4973. Use portable file and member names. A name is portable if it contains
  4974. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  4975. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  4976. contain @samp{/-}. Avoid deep directory nesting. For portability to
  4977. old Unix hosts, limit your file name components to 14 characters or
  4978. less.
  4979. If you intend to have your @command{tar} archives to be read under
  4980. MSDOS, you should not rely on case distinction for file names, and you
  4981. might use the @acronym{GNU} @command{doschk} program for helping you
  4982. further diagnosing illegal MSDOS names, which are even more limited
  4983. than System V's.
  4984. @node dereference
  4985. @subsection Symbolic Links
  4986. @cindex File names, using symbolic links
  4987. @cindex Symbolic link as file name
  4988. Normally, when @command{tar} archives a symbolic link, it writes a
  4989. block to the archive naming the target of the link. In that way, the
  4990. @command{tar} archive is a faithful record of the filesystem contents.
  4991. @value{op-dereference} is used with @value{op-create}, and causes
  4992. @command{tar} to archive the files symbolic links point to, instead of
  4993. the links themselves. When this option is used, when @command{tar}
  4994. encounters a symbolic link, it will archive the linked-to file,
  4995. instead of simply recording the presence of a symbolic link.
  4996. The name under which the file is stored in the file system is not
  4997. recorded in the archive. To record both the symbolic link name and
  4998. the file name in the system, archive the file under both names. If
  4999. all links were recorded automatically by @command{tar}, an extracted file
  5000. might be linked to a file name that no longer exists in the file
  5001. system.
  5002. If a linked-to file is encountered again by @command{tar} while creating
  5003. the same archive, an entire second copy of it will be stored. (This
  5004. @emph{might} be considered a bug.)
  5005. So, for portable archives, do not archive symbolic links as such,
  5006. and use @value{op-dereference}: many systems do not support
  5007. symbolic links, and moreover, your distribution might be unusable if
  5008. it contains unresolved symbolic links.
  5009. @node old
  5010. @subsection Old V7 Archives
  5011. @cindex Format, old style
  5012. @cindex Old style format
  5013. @cindex Old style archives
  5014. Certain old versions of @command{tar} cannot handle additional
  5015. information recorded by newer @command{tar} programs. To create an
  5016. archive in V7 format (not ANSI), which can be read by these old
  5017. versions, specify the @value{op-format-v7} option in
  5018. conjunction with the @value{op-create} (@command{tar} also
  5019. accepts @samp{--portability} or @samp{op-old-archive} for this
  5020. option). When you specify it,
  5021. @command{tar} leaves out information about directories, pipes, fifos,
  5022. contiguous files, and device files, and specifies file ownership by
  5023. group and user IDs instead of group and user names.
  5024. When updating an archive, do not use @value{op-format-v7}
  5025. unless the archive was created with using this option.
  5026. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5027. @command{tar} program without serious trouble, so this option should
  5028. seldom be needed. On the other hand, most modern @command{tar}s are
  5029. able to read old format archives, so it might be safer for you to
  5030. always use @value{op-format-v7} for your distributions.
  5031. @node gnu
  5032. @subsection @acronym{GNU} and old @GNUTAR{} format
  5033. @GNUTAR{} was based on an early draft of the
  5034. @sc{posix} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5035. @command{tar}, such as the support for file names longer than 100
  5036. characters, use portions of the @command{tar} header record which were
  5037. specified in that @sc{posix} draft as unused. Subsequent changes in
  5038. @sc{posix} have allocated the same parts of the header record for
  5039. other purposes. As a result, @GNUTAR{} format is
  5040. incompatible with the current @sc{posix} specification, and with
  5041. @command{tar} programs that follow it.
  5042. In the majority of cases, @command{tar} will be configured to create
  5043. this format by default. This may change in the future, since we plan
  5044. to make @samp{posix} format the default.
  5045. To force creation a @GNUTAR{} archive, use option
  5046. @value{op-format-gnu}.
  5047. Some @command{tar} options are currently basing on @GNUTAR{}
  5048. format, and can therefore be used only with @samp{gnu}
  5049. or @samp{oldgnu} archive formats. The list of such options follows:
  5050. @itemize @bullet
  5051. @item @value{op-label}, when used with @value{op-create}.
  5052. @item @value{op-incremental}
  5053. @item @value{op-multi-volume}
  5054. @item @value{op-sparse}
  5055. @end itemize
  5056. These options will be re-implemented for the @samp{posix} archive
  5057. format in the future.
  5058. @node posix
  5059. @subsection @GNUTAR{} and @sc{posix} @command{tar}
  5060. The version @value{VERSION} of @GNUTAR{} is able
  5061. to read and create archives conforming to @sc{posix.1-2001} standard.
  5062. A @sc{posix} conformant archive will be created if @command{tar}
  5063. was given @value{op-format-posix} option, or if it was given
  5064. @value{op-format-gnu} option and the environment variable
  5065. @env{POSIXLY_CORRECT} is set. The later usage is retained for
  5066. compatibility with previous versions of @GNUTAR{}
  5067. and is discouraged.
  5068. Notice, that currently @acronym{GNU} extensions are not
  5069. allowed with this format. Following is the list of options that
  5070. cannot be used with @value{op-format-posix}:
  5071. @itemize @bullet
  5072. @item @value{op-label}, when used with @value{op-create}.
  5073. @item @value{op-incremental}
  5074. @item @value{op-multi-volume}
  5075. @item @value{op-sparse}
  5076. @end itemize
  5077. This restriction will disappear in the future versions.
  5078. @node Checksumming
  5079. @subsection Checksumming Problems
  5080. SunOS and HP-UX @command{tar} fail to accept archives created using
  5081. @GNUTAR{} and containing non-ASCII file names, that
  5082. is, file names having characters with the eight bit set, because they
  5083. use signed checksums, while @GNUTAR{} uses unsigned
  5084. checksums while creating archives, as per @sc{posix} standards. On
  5085. reading, @GNUTAR{} computes both checksums and
  5086. accept any. It is somewhat worrying that a lot of people may go
  5087. around doing backup of their files using faulty (or at least
  5088. non-standard) software, not learning about it until it's time to
  5089. restore their missing files with an incompatible file extractor, or
  5090. vice versa.
  5091. @GNUTAR{} compute checksums both ways, and accept
  5092. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5093. wrong checksums. @GNUTAR{} produces the standard
  5094. checksum, however, raising incompatibilities with Sun. That is to
  5095. say, @GNUTAR{} has not been modified to
  5096. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5097. I've been told that more recent Sun @command{tar} now read standard
  5098. archives, so maybe Sun did a similar patch, after all?
  5099. The story seems to be that when Sun first imported @command{tar}
  5100. sources on their system, they recompiled it without realizing that
  5101. the checksums were computed differently, because of a change in
  5102. the default signing of @code{char}'s in their compiler. So they
  5103. started computing checksums wrongly. When they later realized their
  5104. mistake, they merely decided to stay compatible with it, and with
  5105. themselves afterwards. Presumably, but I do not really know, HP-UX
  5106. has chosen that their @command{tar} archives to be compatible with Sun's.
  5107. The current standards do not favor Sun @command{tar} format. In any
  5108. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5109. a @command{tar} able to read the good archives they receive.
  5110. @node Large or Negative Values
  5111. @subsection Large or Negative Values
  5112. @cindex large values
  5113. @cindex future time stamps
  5114. @cindex negative time stamps
  5115. @sc{posix} @command{tar} format uses fixed-sized unsigned octal strings
  5116. to represent numeric values. User and group IDs and device major and
  5117. minor numbers have unsigned 21-bit representations, and file sizes and
  5118. times have unsigned 33-bit representations. @GNUTAR{}
  5119. generates @sc{posix} representations when possible, but for values
  5120. outside the @sc{posix} range it generates two's-complement base-256
  5121. strings: uids, gids, and device numbers have signed 57-bit
  5122. representations, and file sizes and times have signed 89-bit
  5123. representations. These representations are an extension to @sc{posix}
  5124. @command{tar} format, so they are not universally portable.
  5125. The most common portability problems with out-of-range numeric values
  5126. are large files and future or negative time stamps.
  5127. Portable archives should avoid members of 8 GB or larger, as @sc{posix}
  5128. @command{tar} format cannot represent them.
  5129. Portable archives should avoid time stamps from the future. @sc{posix}
  5130. @command{tar} format can represent time stamps in the range 1970-01-01
  5131. 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
  5132. hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
  5133. and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
  5134. portable archives must avoid these time stamps for many years to come.
  5135. Portable archives should also avoid time stamps before 1970. These time
  5136. stamps are a common @sc{posix} extension but their @code{time_t}
  5137. representations are negative. Many traditional @command{tar}
  5138. implementations generate a two's complement representation for negative
  5139. time stamps that assumes a signed 32-bit @code{time_t}; hence they
  5140. generate archives that are not portable to hosts with differing
  5141. @code{time_t} representations. @GNUTAR{} recognizes this
  5142. situation when it is run on host with a signed 32-bit @code{time_t}, but
  5143. it issues a warning, as these time stamps are nonstandard and unportable.
  5144. @node Compression
  5145. @section Using Less Space through Compression
  5146. @menu
  5147. * gzip:: Creating and Reading Compressed Archives
  5148. * sparse:: Archiving Sparse Files
  5149. @end menu
  5150. @node gzip
  5151. @subsection Creating and Reading Compressed Archives
  5152. @cindex Compressed archives
  5153. @cindex Storing archives in compressed format
  5154. @UNREVISED
  5155. @table @kbd
  5156. @item -z
  5157. @itemx --gzip
  5158. @itemx --ungzip
  5159. Filter the archive through @command{gzip}.
  5160. @end table
  5161. @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
  5162. format parameters must be taken into consideration when modifying an
  5163. archive.@FIXME{???} Compressed archives cannot be modified.
  5164. You can use @samp{--gzip} and @samp{--gunzip} on physical devices
  5165. (tape drives, etc.) and remote files as well as on normal files; data
  5166. to or from such devices or remote files is reblocked by another copy
  5167. of the @command{tar} program to enforce the specified (or default) record
  5168. size. The default compression parameters are used; if you need to
  5169. override them, avoid the @value{op-gzip} option and run @command{gzip}
  5170. explicitly. (Or set the @env{GZIP} environment variable.)
  5171. The @value{op-gzip} option does not work with the @value{op-multi-volume}
  5172. option, or with the @value{op-update}, @value{op-append},
  5173. @value{op-concatenate}, or @value{op-delete} operations.
  5174. It is not exact to say that @GNUTAR{} is to work in concert
  5175. with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
  5176. possible that @command{tar} and @command{gzip} be done with a single call,
  5177. like in:
  5178. @smallexample
  5179. $ @kbd{tar cfz archive.tar.gz subdir}
  5180. @end smallexample
  5181. @noindent
  5182. to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
  5183. can do:
  5184. @smallexample
  5185. $ @kbd{tar xfz archive.tar.gz}
  5186. @end smallexample
  5187. @noindent
  5188. to explode and unpack.
  5189. The difference is that the whole archive is compressed. With
  5190. @command{zip}, archive members are archived individually. @command{tar}'s
  5191. method yields better compression. On the other hand, one can view the
  5192. contents of a @command{zip} archive without having to decompress it. As
  5193. for the @command{tar} and @command{gzip} tandem, you need to decompress the
  5194. archive to see its contents. However, this may be done without needing
  5195. disk space, by using pipes internally:
  5196. @smallexample
  5197. $ @kbd{tar tfz archive.tar.gz}
  5198. @end smallexample
  5199. @cindex corrupted archives
  5200. About corrupted compressed archives: @command{gzip}'ed files have no
  5201. redundancy, for maximum compression. The adaptive nature of the
  5202. compression scheme means that the compression tables are implicitly
  5203. spread all over the archive. If you lose a few blocks, the dynamic
  5204. construction of the compression tables becomes unsynchronized, and there
  5205. is little chance that you could recover later in the archive.
  5206. There are pending suggestions for having a per-volume or per-file
  5207. compression in @GNUTAR{}. This would allow for viewing the
  5208. contents without decompression, and for resynchronizing decompression at
  5209. every volume or file, in case of corrupted archives. Doing so, we might
  5210. lose some compressibility. But this would have make recovering easier.
  5211. So, there are pros and cons. We'll see!
  5212. @table @kbd
  5213. @item -j
  5214. @itemx --bzip2
  5215. Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
  5216. @item -Z
  5217. @itemx --compress
  5218. @itemx --uncompress
  5219. Filter the archive through @command{compress}. Otherwise like
  5220. @value{op-gzip}.
  5221. @item --use-compress-program=@var{prog}
  5222. Filter through @var{prog} (must accept @samp{-d}).
  5223. @end table
  5224. @value{op-compress} stores an archive in compressed format. This
  5225. option is useful in saving time over networks and space in pipes, and
  5226. when storage space is at a premium. @value{op-compress} causes
  5227. @command{tar} to compress when writing the archive, or to uncompress when
  5228. reading the archive.
  5229. To perform compression and uncompression on the archive, @command{tar}
  5230. runs the @command{compress} utility. @command{tar} uses the default
  5231. compression parameters; if you need to override them, avoid the
  5232. @value{op-compress} option and run the @command{compress} utility
  5233. explicitly. It is useful to be able to call the @command{compress}
  5234. utility from within @command{tar} because the @command{compress} utility by
  5235. itself cannot access remote tape drives.
  5236. The @value{op-compress} option will not work in conjunction with the
  5237. @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
  5238. and @value{op-delete} operations. @xref{Operations}, for
  5239. more information on these operations.
  5240. If there is no compress utility available, @command{tar} will report an error.
  5241. @strong{Please note} that the @command{compress} program may be covered by
  5242. a patent, and therefore we recommend you stop using it.
  5243. @value{op-bzip2} acts like @value{op-compress}, except that it uses
  5244. the @code{bzip2} utility.
  5245. @table @kbd
  5246. @item --compress
  5247. @itemx --uncompress
  5248. @itemx -z
  5249. @itemx -Z
  5250. When this option is specified, @command{tar} will compress (when
  5251. writing an archive), or uncompress (when reading an archive). Used in
  5252. conjunction with the @value{op-create}, @value{op-extract},
  5253. @value{op-list} and @value{op-compare} operations.
  5254. @end table
  5255. You can have archives be compressed by using the @value{op-gzip} option.
  5256. This will arrange for @command{tar} to use the @command{gzip} program to be
  5257. used to compress or uncompress the archive wren writing or reading it.
  5258. To use the older, obsolete, @command{compress} program, use the
  5259. @value{op-compress} option. The @acronym{GNU} Project recommends you not use
  5260. @command{compress}, because there is a patent covering the algorithm it
  5261. uses. You could be sued for patent infringement merely by running
  5262. @command{compress}.
  5263. I have one question, or maybe it's a suggestion if there isn't a way
  5264. to do it now. I would like to use @value{op-gzip}, but I'd also like
  5265. the output to be fed through a program like @acronym{GNU}
  5266. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5267. to use :-)), basically adding ECC protection on top of compression.
  5268. It seems as if this should be quite easy to do, but I can't work out
  5269. exactly how to go about it. Of course, I can pipe the standard output
  5270. of @command{tar} through @command{ecc}, but then I lose (though I
  5271. haven't started using it yet, I confess) the ability to have
  5272. @command{tar} use @command{rmt} for it's I/O (I think).
  5273. I think the most straightforward thing would be to let me specify a
  5274. general set of filters outboard of compression (preferably ordered,
  5275. so the order can be automatically reversed on input operations, and
  5276. with the options they require specifiable), but beggars shouldn't be
  5277. choosers and anything you decide on would be fine with me.
  5278. By the way, I like @command{ecc} but if (as the comments say) it can't
  5279. deal with loss of block sync, I'm tempted to throw some time at adding
  5280. that capability. Supposing I were to actually do such a thing and
  5281. get it (apparently) working, do you accept contributed changes to
  5282. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5283. Isn't that exactly the role of the @value{op-use-compress-prog} option?
  5284. I never tried it myself, but I suspect you may want to write a
  5285. @var{prog} script or program able to filter stdin to stdout to
  5286. way you want. It should recognize the @samp{-d} option, for when
  5287. extraction is needed rather than creation.
  5288. It has been reported that if one writes compressed data (through the
  5289. @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
  5290. the DLT compression mode, the data will actually get bigger and one will
  5291. end up with less space on the tape.
  5292. @node sparse
  5293. @subsection Archiving Sparse Files
  5294. @cindex Sparse Files
  5295. @UNREVISED
  5296. @table @kbd
  5297. @item -S
  5298. @itemx --sparse
  5299. Handle sparse files efficiently.
  5300. @end table
  5301. This option causes all files to be put in the archive to be tested for
  5302. sparseness, and handled specially if they are. The @value{op-sparse}
  5303. option is useful when many @code{dbm} files, for example, are being
  5304. backed up. Using this option dramatically decreases the amount of
  5305. space needed to store such a file.
  5306. In later versions, this option may be removed, and the testing and
  5307. treatment of sparse files may be done automatically with any special
  5308. @acronym{GNU} options. For now, it is an option needing to be specified on
  5309. the command line with the creation or updating of an archive.
  5310. Files in the filesystem occasionally have ``holes.'' A hole in a file
  5311. is a section of the file's contents which was never written. The
  5312. contents of a hole read as all zeros. On many operating systems,
  5313. actual disk storage is not allocated for holes, but they are counted
  5314. in the length of the file. If you archive such a file, @command{tar}
  5315. could create an archive longer than the original. To have @command{tar}
  5316. attempt to recognize the holes in a file, use @value{op-sparse}. When
  5317. you use the @value{op-sparse} option, then, for any file using less
  5318. disk space than would be expected from its length, @command{tar} searches
  5319. the file for consecutive stretches of zeros. It then records in the
  5320. archive for the file where the consecutive stretches of zeros are, and
  5321. only archives the ``real contents'' of the file. On extraction (using
  5322. @value{op-sparse} is not needed on extraction) any such files have
  5323. holes created wherever the continuous stretches of zeros were found.
  5324. Thus, if you use @value{op-sparse}, @command{tar} archives won't take
  5325. more space than the original.
  5326. A file is sparse if it contains blocks of zeros whose existence is
  5327. recorded, but that have no space allocated on disk. When you specify
  5328. the @value{op-sparse} option in conjunction with the @value{op-create}
  5329. operation, @command{tar} tests all files for sparseness while archiving.
  5330. If @command{tar} finds a file to be sparse, it uses a sparse representation of
  5331. the file in the archive. @value{xref-create}, for more information
  5332. about creating archives.
  5333. @value{op-sparse} is useful when archiving files, such as dbm files,
  5334. likely to contain many nulls. This option dramatically
  5335. decreases the amount of space needed to store such an archive.
  5336. @quotation
  5337. @strong{Please Note:} Always use @value{op-sparse} when performing file
  5338. system backups, to avoid archiving the expanded forms of files stored
  5339. sparsely in the system.
  5340. Even if your system has no sparse files currently, some may be
  5341. created in the future. If you use @value{op-sparse} while making file
  5342. system backups as a matter of course, you can be assured the archive
  5343. will never take more space on the media than the files take on disk
  5344. (otherwise, archiving a disk filled with sparse files might take
  5345. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5346. @end quotation
  5347. @command{tar} ignores the @value{op-sparse} option when reading an archive.
  5348. @table @kbd
  5349. @item --sparse
  5350. @itemx -S
  5351. Files stored sparsely in the file system are represented sparsely in
  5352. the archive. Use in conjunction with write operations.
  5353. @end table
  5354. However, users should be well aware that at archive creation time,
  5355. @GNUTAR{} still has to read whole disk file to
  5356. locate the @dfn{holes}, and so, even if sparse files use little space
  5357. on disk and in the archive, they may sometimes require inordinate
  5358. amount of time for reading and examining all-zero blocks of a file.
  5359. Although it works, it's painfully slow for a large (sparse) file, even
  5360. though the resulting tar archive may be small. (One user reports that
  5361. dumping a @file{core} file of over 400 megabytes, but with only about
  5362. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5363. ELC, with full CPU utilization.)
  5364. This reading is required in all cases and is not related to the fact
  5365. the @value{op-sparse} option is used or not, so by merely @emph{not}
  5366. using the option, you are not saving time@footnote{Well! We should say
  5367. the whole truth, here. When @value{op-sparse} is selected while creating
  5368. an archive, the current @command{tar} algorithm requires sparse files to be
  5369. read twice, not once. We hope to develop a new archive format for saving
  5370. sparse files in which one pass will be sufficient.}.
  5371. Programs like @command{dump} do not have to read the entire file; by
  5372. examining the file system directly, they can determine in advance
  5373. exactly where the holes are and thus avoid reading through them. The
  5374. only data it need read are the actual allocated data blocks.
  5375. @GNUTAR{} uses a more portable and straightforward
  5376. archiving approach, it would be fairly difficult that it does
  5377. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5378. 1990-12-10:
  5379. @quotation
  5380. What I did say is that you cannot tell the difference between a hole and an
  5381. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  5382. best tells you how many holes there are; it doesn't tell you @emph{where}.
  5383. Just as programs may, conceivably, care what @code{st_blocks} is (care
  5384. to name one that does?), they may also care where the holes are (I have
  5385. no examples of this one either, but it's equally imaginable).
  5386. I conclude from this that good archivers are not portable. One can
  5387. arguably conclude that if you want a portable program, you can in good
  5388. conscience restore files with as many holes as possible, since you can't
  5389. get it right.
  5390. @end quotation
  5391. @node Attributes
  5392. @section Handling File Attributes
  5393. @UNREVISED
  5394. When @command{tar} reads files, this causes them to have the access
  5395. times updated. To have @command{tar} attempt to set the access times
  5396. back to what they were before they were read, use the
  5397. @value{op-atime-preserve} option.
  5398. Handling of file attributes
  5399. @table @kbd
  5400. @item --atime-preserve
  5401. Preserve access times on files that are read.
  5402. This doesn't work for files that
  5403. you don't own, unless you're root, and it doesn't interact with
  5404. incremental dumps nicely (@pxref{Backups}), and it can set access or
  5405. modification times incorrectly if other programs access the file while
  5406. @command{tar} is running; but it is good enough for some purposes.
  5407. @item -m
  5408. @itemx --touch
  5409. Do not extract file modified time.
  5410. When this option is used, @command{tar} leaves the modification times
  5411. of the files it extracts as the time when the files were extracted,
  5412. instead of setting it to the time recorded in the archive.
  5413. This option is meaningless with @value{op-list}.
  5414. @item --same-owner
  5415. Create extracted files with the same ownership they have in the
  5416. archive.
  5417. This is the default behavior for the superuser,
  5418. so this option is meaningful only for non-root users, when @command{tar}
  5419. is executed on those systems able to give files away. This is
  5420. considered as a security flaw by many people, at least because it
  5421. makes quite difficult to correctly account users for the disk space
  5422. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  5423. files are easily and silently lost when files are given away.
  5424. When writing an archive, @command{tar} writes the user id and user name
  5425. separately. If it can't find a user name (because the user id is not
  5426. in @file{/etc/passwd}), then it does not write one. When restoring,
  5427. and doing a @code{chmod} like when you use @value{op-same-permissions},
  5428. @FIXME{same-owner?}it tries to look the name (if one was written)
  5429. up in @file{/etc/passwd}. If it fails, then it uses the user id
  5430. stored in the archive instead.
  5431. @item --no-same-owner
  5432. @itemx -o
  5433. Do not attempt to restore ownership when extracting. This is the
  5434. default behavior for ordinary users, so this option has an effect
  5435. only for the superuser.
  5436. @item --numeric-owner
  5437. The @value{op-numeric-owner} option allows (ANSI) archives to be written
  5438. without user/group name information or such information to be ignored
  5439. when extracting. It effectively disables the generation and/or use
  5440. of user/group name information. This option forces extraction using
  5441. the numeric ids from the archive, ignoring the names.
  5442. This is useful in certain circumstances, when restoring a backup from
  5443. an emergency floppy with different passwd/group files for example.
  5444. It is otherwise impossible to extract files with the right ownerships
  5445. if the password file in use during the extraction does not match the
  5446. one belonging to the filesystem(s) being extracted. This occurs,
  5447. for example, if you are restoring your files after a major crash and
  5448. had booted from an emergency floppy with no password file or put your
  5449. disk into another machine to do the restore.
  5450. The numeric ids are @emph{always} saved into @command{tar} archives.
  5451. The identifying names are added at create time when provided by the
  5452. system, unless @value{op-old-archive} is used. Numeric ids could be
  5453. used when moving archives between a collection of machines using
  5454. a centralized management for attribution of numeric ids to users
  5455. and groups. This is often made through using the NIS capabilities.
  5456. When making a @command{tar} file for distribution to other sites, it
  5457. is sometimes cleaner to use a single owner for all files in the
  5458. distribution, and nicer to specify the write permission bits of the
  5459. files as stored in the archive independently of their actual value on
  5460. the file system. The way to prepare a clean distribution is usually
  5461. to have some Makefile rule creating a directory, copying all needed
  5462. files in that directory, then setting ownership and permissions as
  5463. wanted (there are a lot of possible schemes), and only then making a
  5464. @command{tar} archive out of this directory, before cleaning
  5465. everything out. Of course, we could add a lot of options to
  5466. @GNUTAR{} for fine tuning permissions and ownership.
  5467. This is not the good way, I think. @GNUTAR{} is
  5468. already crowded with options and moreover, the approach just explained
  5469. gives you a great deal of control already.
  5470. @item -p
  5471. @itemx --same-permissions
  5472. @itemx --preserve-permissions
  5473. Extract all protection information.
  5474. This option causes @command{tar} to set the modes (access permissions) of
  5475. extracted files exactly as recorded in the archive. If this option
  5476. is not used, the current @code{umask} setting limits the permissions
  5477. on extracted files.
  5478. This option is meaningless with @value{op-list}.
  5479. @item --preserve
  5480. Same as both @value{op-same-permissions} and @value{op-same-order}.
  5481. The @value{op-preserve} option has no equivalent short option name.
  5482. It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
  5483. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  5484. @end table
  5485. @node Standard
  5486. @section The Standard Format
  5487. @UNREVISED
  5488. While an archive may contain many files, the archive itself is a
  5489. single ordinary file. Like any other file, an archive file can be
  5490. written to a storage device such as a tape or disk, sent through a
  5491. pipe or over a network, saved on the active file system, or even
  5492. stored in another archive. An archive file is not easy to read or
  5493. manipulate without using the @command{tar} utility or Tar mode in
  5494. @acronym{GNU} Emacs.
  5495. Physically, an archive consists of a series of file entries terminated
  5496. by an end-of-archive entry, which consists of 512 zero bytes. A file
  5497. entry usually describes one of the files in the archive (an
  5498. @dfn{archive member}), and consists of a file header and the contents
  5499. of the file. File headers contain file names and statistics, checksum
  5500. information which @command{tar} uses to detect file corruption, and
  5501. information about file types.
  5502. Archives are permitted to have more than one member with the same
  5503. member name. One way this situation can occur is if more than one
  5504. version of a file has been stored in the archive. For information
  5505. about adding new versions of a file to an archive, see @ref{update}.
  5506. @FIXME-xref{To learn more about having more than one archive member with the
  5507. same name, see -backup node, when it's written.}
  5508. In addition to entries describing archive members, an archive may
  5509. contain entries which @command{tar} itself uses to store information.
  5510. @value{xref-label}, for an example of such an archive entry.
  5511. A @command{tar} archive file contains a series of blocks. Each block
  5512. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  5513. of as being on magnetic tape, other media are often used.
  5514. Each file archived is represented by a header block which describes
  5515. the file, followed by zero or more blocks which give the contents
  5516. of the file. At the end of the archive file there may be a block
  5517. filled with binary zeros as an end-of-file marker. A reasonable system
  5518. should write a block of zeros at the end, but must not assume that
  5519. such a block exists when reading an archive.
  5520. The blocks may be @dfn{blocked} for physical I/O operations.
  5521. Each record of @var{n} blocks (where @var{n} is set by the
  5522. @value{op-blocking-factor} option to @command{tar}) is written with a single
  5523. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  5524. such a write is a single record. When writing an archive,
  5525. the last record of blocks should be written at the full size, with
  5526. blocks after the zero block containing all zeros. When reading
  5527. an archive, a reasonable system should properly handle an archive
  5528. whose last record is shorter than the rest, or which contains garbage
  5529. records after a zero block.
  5530. The header block is defined in C as follows. In the @GNUTAR{}
  5531. distribution, this is part of file @file{src/tar.h}:
  5532. @smallexample
  5533. @include header.texi
  5534. @end smallexample
  5535. All characters in header blocks are represented by using 8-bit
  5536. characters in the local variant of ASCII. Each field within the
  5537. structure is contiguous; that is, there is no padding used within
  5538. the structure. Each character on the archive medium is stored
  5539. contiguously.
  5540. Bytes representing the contents of files (after the header block
  5541. of each file) are not translated in any way and are not constrained
  5542. to represent characters in any character set. The @command{tar} format
  5543. does not distinguish text files from binary files, and no translation
  5544. of file contents is performed.
  5545. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  5546. @code{gname} are null-terminated character strings. All other fields
  5547. are zero-filled octal numbers in ASCII. Each numeric field of width
  5548. @var{w} contains @var{w} minus 2 digits, a space, and a null, except
  5549. @code{size}, and @code{mtime}, which do not contain the trailing null.
  5550. The @code{name} field is the file name of the file, with directory names
  5551. (if any) preceding the file name, separated by slashes.
  5552. @FIXME{how big a name before field overflows?}
  5553. The @code{mode} field provides nine bits specifying file permissions
  5554. and three bits to specify the Set UID, Set GID, and Save Text
  5555. (@dfn{sticky}) modes. Values for these bits are defined above.
  5556. When special permissions are required to create a file with a given
  5557. mode, and the user restoring files from the archive does not hold such
  5558. permissions, the mode bit(s) specifying those special permissions
  5559. are ignored. Modes which are not supported by the operating system
  5560. restoring files from the archive will be ignored. Unsupported modes
  5561. should be faked up when creating or updating an archive; e.g.@: the
  5562. group permission could be copied from the @emph{other} permission.
  5563. The @code{uid} and @code{gid} fields are the numeric user and group
  5564. ID of the file owners, respectively. If the operating system does
  5565. not support numeric user or group IDs, these fields should be ignored.
  5566. The @code{size} field is the size of the file in bytes; linked files
  5567. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  5568. particular the @value{op-incremental} option.}
  5569. The @code{mtime} field is the modification time of the file at the time
  5570. it was archived. It is the ASCII representation of the octal value of
  5571. the last time the file was modified, represented as an integer number of
  5572. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  5573. The @code{chksum} field is the ASCII representation of the octal value
  5574. of the simple sum of all bytes in the header block. Each 8-bit
  5575. byte in the header is added to an unsigned integer, initialized to
  5576. zero, the precision of which shall be no less than seventeen bits.
  5577. When calculating the checksum, the @code{chksum} field is treated as
  5578. if it were all blanks.
  5579. The @code{typeflag} field specifies the type of file archived. If a
  5580. particular implementation does not recognize or permit the specified
  5581. type, the file will be extracted as if it were a regular file. As this
  5582. action occurs, @command{tar} issues a warning to the standard error.
  5583. The @code{atime} and @code{ctime} fields are used in making incremental
  5584. backups; they store, respectively, the particular file's access time
  5585. and last inode-change time.
  5586. The @code{offset} is used by the @value{op-multi-volume} option, when
  5587. making a multi-volume archive. The offset is number of bytes into
  5588. the file that we need to restart at to continue the file on the next
  5589. tape, i.e., where we store the location that a continued file is
  5590. continued at.
  5591. The following fields were added to deal with sparse files. A file
  5592. is @dfn{sparse} if it takes in unallocated blocks which end up being
  5593. represented as zeros, i.e., no useful data. A test to see if a file
  5594. is sparse is to look at the number blocks allocated for it versus the
  5595. number of characters in the file; if there are fewer blocks allocated
  5596. for the file than would normally be allocated for a file of that
  5597. size, then the file is sparse. This is the method @command{tar} uses to
  5598. detect a sparse file, and once such a file is detected, it is treated
  5599. differently from non-sparse files.
  5600. Sparse files are often @code{dbm} files, or other database-type files
  5601. which have data at some points and emptiness in the greater part of
  5602. the file. Such files can appear to be very large when an @samp{ls
  5603. -l} is done on them, when in truth, there may be a very small amount
  5604. of important data contained in the file. It is thus undesirable
  5605. to have @command{tar} think that it must back up this entire file, as
  5606. great quantities of room are wasted on empty blocks, which can lead
  5607. to running out of room on a tape far earlier than is necessary.
  5608. Thus, sparse files are dealt with so that these empty blocks are
  5609. not written to the tape. Instead, what is written to the tape is a
  5610. description, of sorts, of the sparse file: where the holes are, how
  5611. big the holes are, and how much data is found at the end of the hole.
  5612. This way, the file takes up potentially far less room on the tape,
  5613. and when the file is extracted later on, it will look exactly the way
  5614. it looked beforehand. The following is a description of the fields
  5615. used to handle a sparse file:
  5616. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  5617. sparse} contains two 12-character strings which represent an offset
  5618. into the file and a number of bytes to be written at that offset.
  5619. The offset is absolute, and not relative to the offset in preceding
  5620. array element.
  5621. The header can hold four of these @code{struct sparse} at the moment;
  5622. if more are needed, they are not stored in the header.
  5623. The @code{isextended} flag is set when an @code{extended_header}
  5624. is needed to deal with a file. Note that this means that this flag
  5625. can only be set when dealing with a sparse file, and it is only set
  5626. in the event that the description of the file will not fit in the
  5627. allotted room for sparse structures in the header. In other words,
  5628. an extended_header is needed.
  5629. The @code{extended_header} structure is used for sparse files which
  5630. need more sparse structures than can fit in the header. The header can
  5631. fit 4 such structures; if more are needed, the flag @code{isextended}
  5632. gets set and the next block is an @code{extended_header}.
  5633. Each @code{extended_header} structure contains an array of 21
  5634. sparse structures, along with a similar @code{isextended} flag
  5635. that the header had. There can be an indeterminate number of such
  5636. @code{extended_header}s to describe a sparse file.
  5637. @table @asis
  5638. @item @code{REGTYPE}
  5639. @itemx @code{AREGTYPE}
  5640. These flags represent a regular file. In order to be compatible
  5641. with older versions of @command{tar}, a @code{typeflag} value of
  5642. @code{AREGTYPE} should be silently recognized as a regular file.
  5643. New archives should be created using @code{REGTYPE}. Also, for
  5644. backward compatibility, @command{tar} treats a regular file whose name
  5645. ends with a slash as a directory.
  5646. @item @code{LNKTYPE}
  5647. This flag represents a file linked to another file, of any type,
  5648. previously archived. Such files are identified in Unix by each
  5649. file having the same device and inode number. The linked-to name is
  5650. specified in the @code{linkname} field with a trailing null.
  5651. @item @code{SYMTYPE}
  5652. This represents a symbolic link to another file. The linked-to name
  5653. is specified in the @code{linkname} field with a trailing null.
  5654. @item @code{CHRTYPE}
  5655. @itemx @code{BLKTYPE}
  5656. These represent character special files and block special files
  5657. respectively. In this case the @code{devmajor} and @code{devminor}
  5658. fields will contain the major and minor device numbers respectively.
  5659. Operating systems may map the device specifications to their own
  5660. local specification, or may ignore the entry.
  5661. @item @code{DIRTYPE}
  5662. This flag specifies a directory or sub-directory. The directory
  5663. name in the @code{name} field should end with a slash. On systems where
  5664. disk allocation is performed on a directory basis, the @code{size} field
  5665. will contain the maximum number of bytes (which may be rounded to
  5666. the nearest disk block allocation unit) which the directory may
  5667. hold. A @code{size} field of zero indicates no such limiting. Systems
  5668. which do not support limiting in this manner should ignore the
  5669. @code{size} field.
  5670. @item @code{FIFOTYPE}
  5671. This specifies a FIFO special file. Note that the archiving of a
  5672. FIFO file archives the existence of this file and not its contents.
  5673. @item @code{CONTTYPE}
  5674. This specifies a contiguous file, which is the same as a normal
  5675. file except that, in operating systems which support it, all its
  5676. space is allocated contiguously on the disk. Operating systems
  5677. which do not allow contiguous allocation should silently treat this
  5678. type as a normal file.
  5679. @item @code{A} @dots{} @code{Z}
  5680. These are reserved for custom implementations. Some of these are
  5681. used in the @acronym{GNU} modified format, as described below.
  5682. @end table
  5683. Other values are reserved for specification in future revisions of
  5684. the P1003 standard, and should not be used by any @command{tar} program.
  5685. The @code{magic} field indicates that this archive was output in
  5686. the P1003 archive format. If this field contains @code{TMAGIC},
  5687. the @code{uname} and @code{gname} fields will contain the ASCII
  5688. representation of the owner and group of the file respectively.
  5689. If found, the user and group IDs are used rather than the values in
  5690. the @code{uid} and @code{gid} fields.
  5691. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  5692. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  5693. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  5694. (section E.4.48) for @cite{pax - Portable archive interchange}.
  5695. @node Extensions
  5696. @section @acronym{GNU} Extensions to the Archive Format
  5697. @UNREVISED
  5698. The @acronym{GNU} format uses additional file types to describe new types of
  5699. files in an archive. These are listed below.
  5700. @table @code
  5701. @item GNUTYPE_DUMPDIR
  5702. @itemx 'D'
  5703. This represents a directory and a list of files created by the
  5704. @value{op-incremental} option. The @code{size} field gives the total
  5705. size of the associated list of files. Each file name is preceded by
  5706. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  5707. (The file is a directory, or is not stored in the archive.) Each file
  5708. name is terminated by a null. There is an additional null after the
  5709. last file name.
  5710. @item GNUTYPE_MULTIVOL
  5711. @itemx 'M'
  5712. This represents a file continued from another volume of a multi-volume
  5713. archive created with the @value{op-multi-volume} option. The original
  5714. type of the file is not given here. The @code{size} field gives the
  5715. maximum size of this piece of the file (assuming the volume does
  5716. not end before the file is written out). The @code{offset} field
  5717. gives the offset from the beginning of the file where this part of
  5718. the file begins. Thus @code{size} plus @code{offset} should equal
  5719. the original size of the file.
  5720. @item GNUTYPE_SPARSE
  5721. @itemx 'S'
  5722. This flag indicates that we are dealing with a sparse file. Note
  5723. that archiving a sparse file requires special operations to find
  5724. holes in the file, which mark the positions of these holes, along
  5725. with the number of bytes of data to be found after the hole.
  5726. @item GNUTYPE_VOLHDR
  5727. @itemx 'V'
  5728. This file type is used to mark the volume header that was given with
  5729. the @value{op-label} option when the archive was created. The @code{name}
  5730. field contains the @code{name} given after the @value{op-label} option.
  5731. The @code{size} field is zero. Only the first file in each volume
  5732. of an archive should have this type.
  5733. @end table
  5734. You may have trouble reading a @acronym{GNU} format archive on a
  5735. non-@acronym{GNU} system if the options @value{op-incremental},
  5736. @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
  5737. used when writing the archive. In general, if @command{tar} does not
  5738. use the @acronym{GNU}-added fields of the header, other versions of
  5739. @command{tar} should be able to read the archive. Otherwise, the
  5740. @command{tar} program will give an error, the most likely one being a
  5741. checksum error.
  5742. @node cpio
  5743. @section Comparison of @command{tar} and @command{cpio}
  5744. @UNREVISED
  5745. @FIXME{Reorganize the following material}
  5746. The @command{cpio} archive formats, like @command{tar}, do have maximum
  5747. pathname lengths. The binary and old ASCII formats have a max path
  5748. length of 256, and the new ASCII and CRC ASCII formats have a max
  5749. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  5750. with arbitrary pathname lengths, but other @command{cpio} implementations
  5751. may crash unexplainedly trying to read them.
  5752. @command{tar} handles symbolic links in the form in which it comes in BSD;
  5753. @command{cpio} doesn't handle symbolic links in the form in which it comes
  5754. in System V prior to SVR4, and some vendors may have added symlinks
  5755. to their system without enhancing @command{cpio} to know about them.
  5756. Others may have enhanced it in a way other than the way I did it
  5757. at Sun, and which was adopted by AT&T (and which is, I think, also
  5758. present in the @command{cpio} that Berkeley picked up from AT&T and put
  5759. into a later BSD release---I think I gave them my changes).
  5760. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  5761. can handle @command{tar} format input, and write it on output, and it
  5762. probably handles symbolic links. They may not have bothered doing
  5763. anything to enhance @command{tar} as a result.)
  5764. @command{cpio} handles special files; traditional @command{tar} doesn't.
  5765. @command{tar} comes with V7, System III, System V, and BSD source;
  5766. @command{cpio} comes only with System III, System V, and later BSD
  5767. (4.3-tahoe and later).
  5768. @command{tar}'s way of handling multiple hard links to a file can handle
  5769. file systems that support 32-bit inumbers (e.g., the BSD file system);
  5770. @command{cpio}s way requires you to play some games (in its "binary"
  5771. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  5772. they're 18 bits---it would have to play games with the "file system ID"
  5773. field of the header to make sure that the file system ID/i-number pairs
  5774. of different files were always different), and I don't know which
  5775. @command{cpio}s, if any, play those games. Those that don't might get
  5776. confused and think two files are the same file when they're not, and
  5777. make hard links between them.
  5778. @command{tar}s way of handling multiple hard links to a file places only
  5779. one copy of the link on the tape, but the name attached to that copy
  5780. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  5781. way puts one copy for every link, but you can retrieve it using any
  5782. of the names.
  5783. @quotation
  5784. What type of check sum (if any) is used, and how is this calculated.
  5785. @end quotation
  5786. See the attached manual pages for @command{tar} and @command{cpio} format.
  5787. @command{tar} uses a checksum which is the sum of all the bytes in the
  5788. @command{tar} header for a file; @command{cpio} uses no checksum.
  5789. @quotation
  5790. If anyone knows why @command{cpio} was made when @command{tar} was present
  5791. at the unix scene,
  5792. @end quotation
  5793. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  5794. generally-available version of UNIX had @command{tar} at the time. I don't
  5795. know whether any version that was generally available @emph{within AT&T}
  5796. had @command{tar}, or, if so, whether the people within AT&T who did
  5797. @command{cpio} knew about it.
  5798. On restore, if there is a corruption on a tape @command{tar} will stop at
  5799. that point, while @command{cpio} will skip over it and try to restore the
  5800. rest of the files.
  5801. The main difference is just in the command syntax and header format.
  5802. @command{tar} is a little more tape-oriented in that everything is blocked
  5803. to start on a record boundary.
  5804. @quotation
  5805. Is there any differences between the ability to recover crashed
  5806. archives between the two of them. (Is there any chance of recovering
  5807. crashed archives at all.)
  5808. @end quotation
  5809. Theoretically it should be easier under @command{tar} since the blocking
  5810. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  5811. However, modern @command{cpio}'s and variations have an option to just
  5812. search for the next file header after an error with a reasonable chance
  5813. of resyncing. However, lots of tape driver software won't allow you to
  5814. continue past a media error which should be the only reason for getting
  5815. out of sync unless a file changed sizes while you were writing the
  5816. archive.
  5817. @quotation
  5818. If anyone knows why @command{cpio} was made when @command{tar} was present
  5819. at the unix scene, please tell me about this too.
  5820. @end quotation
  5821. Probably because it is more media efficient (by not blocking everything
  5822. and using only the space needed for the headers where @command{tar}
  5823. always uses 512 bytes per file header) and it knows how to archive
  5824. special files.
  5825. You might want to look at the freely available alternatives. The
  5826. major ones are @command{afio}, @GNUTAR{}, and
  5827. @command{pax}, each of which have their own extensions with some
  5828. backwards compatibility.
  5829. Sparse files were @command{tar}red as sparse files (which you can
  5830. easily test, because the resulting archive gets smaller, and
  5831. @acronym{GNU} @command{cpio} can no longer read it).
  5832. @node Media
  5833. @chapter Tapes and Other Archive Media
  5834. @UNREVISED
  5835. A few special cases about tape handling warrant more detailed
  5836. description. These special cases are discussed below.
  5837. Many complexities surround the use of @command{tar} on tape drives. Since
  5838. the creation and manipulation of archives located on magnetic tape was
  5839. the original purpose of @command{tar}, it contains many features making
  5840. such manipulation easier.
  5841. Archives are usually written on dismountable media---tape cartridges,
  5842. mag tapes, or floppy disks.
  5843. The amount of data a tape or disk holds depends not only on its size,
  5844. but also on how it is formatted. A 2400 foot long reel of mag tape
  5845. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  5846. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  5847. Magnetic media are re-usable---once the archive on a tape is no longer
  5848. needed, the archive can be erased and the tape or disk used over.
  5849. Media quality does deteriorate with use, however. Most tapes or disks
  5850. should be discarded when they begin to produce data errors. EXABYTE
  5851. tape cartridges should be discarded when they generate an @dfn{error
  5852. count} (number of non-usable bits) of more than 10k.
  5853. Magnetic media are written and erased using magnetic fields, and
  5854. should be protected from such fields to avoid damage to stored data.
  5855. Sticking a floppy disk to a filing cabinet using a magnet is probably
  5856. not a good idea.
  5857. @menu
  5858. * Device:: Device selection and switching
  5859. * Remote Tape Server::
  5860. * Common Problems and Solutions::
  5861. * Blocking:: Blocking
  5862. * Many:: Many archives on one tape
  5863. * Using Multiple Tapes:: Using Multiple Tapes
  5864. * label:: Including a Label in the Archive
  5865. * verify::
  5866. * Write Protection::
  5867. @end menu
  5868. @node Device
  5869. @section Device Selection and Switching
  5870. @UNREVISED
  5871. @table @kbd
  5872. @item -f [@var{hostname}:]@var{file}
  5873. @itemx --file=[@var{hostname}:]@var{file}
  5874. Use archive file or device @var{file} on @var{hostname}.
  5875. @end table
  5876. This option is used to specify the file name of the archive @command{tar}
  5877. works on.
  5878. If the file name is @samp{-}, @command{tar} reads the archive from standard
  5879. input (when listing or extracting), or writes it to standard output
  5880. (when creating). If the @samp{-} file name is given when updating an
  5881. archive, @command{tar} will read the original archive from its standard
  5882. input, and will write the entire new archive to its standard output.
  5883. If the file name contains a @samp{:}, it is interpreted as
  5884. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  5885. sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
  5886. either case, @command{tar} will invoke the command @command{rsh} (or
  5887. @command{remsh}) to start up an @file{/etc/rmt} on the remote machine. If
  5888. you give an alternate login name, it will be given to the @command{rsh}.
  5889. Naturally, the remote machine must have an executable @file{/etc/rmt}.
  5890. This program is free software from the University of California, and a
  5891. copy of the source code can be found with the sources for @command{tar};
  5892. it's compiled and installed by default.
  5893. If this option is not given, but the environment variable @env{TAPE}
  5894. is set, its value is used; otherwise, old versions of @command{tar}
  5895. used a default archive name (which was picked when @command{tar} was
  5896. compiled). The default is normally set up to be the @dfn{first} tape
  5897. drive or other transportable I/O medium on the system.
  5898. Starting with version 1.11.5, @GNUTAR{} uses
  5899. standard input and standard output as the default device, and I will
  5900. not try anymore supporting automatic device detection at installation
  5901. time. This was failing really in too many cases, it was hopeless.
  5902. This is now completely left to the installer to override standard
  5903. input and standard output for default device, if this seems
  5904. preferable. Further, I think @emph{most} actual usages of
  5905. @command{tar} are done with pipes or disks, not really tapes,
  5906. cartridges or diskettes.
  5907. Some users think that using standard input and output is running
  5908. after trouble. This could lead to a nasty surprise on your screen if
  5909. you forget to specify an output file name---especially if you are going
  5910. through a network or terminal server capable of buffering large amounts
  5911. of output. We had so many bug reports in that area of configuring
  5912. default tapes automatically, and so many contradicting requests, that
  5913. we finally consider the problem to be portably intractable. We could
  5914. of course use something like @samp{/dev/tape} as a default, but this
  5915. is @emph{also} running after various kind of trouble, going from hung
  5916. processes to accidental destruction of real tapes. After having seen
  5917. all this mess, using standard input and output as a default really
  5918. sounds like the only clean choice left, and a very useful one too.
  5919. @GNUTAR{} reads and writes archive in records, I
  5920. suspect this is the main reason why block devices are preferred over
  5921. character devices. Most probably, block devices are more efficient
  5922. too. The installer could also check for @samp{DEFTAPE} in
  5923. @file{<sys/mtio.h>}.
  5924. @table @kbd
  5925. @item --force-local
  5926. Archive file is local even if it contains a colon.
  5927. @item --rsh-command=@var{command}
  5928. Use remote @var{command} instead of @command{rsh}. This option exists
  5929. so that people who use something other than the standard @command{rsh}
  5930. (e.g., a Kerberized @command{rsh}) can access a remote device.
  5931. When this command is not used, the shell command found when
  5932. the @command{tar} program was installed is used instead. This is
  5933. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  5934. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  5935. The installer may have overridden this by defining the environment
  5936. variable @env{RSH} @emph{at installation time}.
  5937. @item -[0-7][lmh]
  5938. Specify drive and density.
  5939. @item -M
  5940. @itemx --multi-volume
  5941. Create/list/extract multi-volume archive.
  5942. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  5943. that may be larger than will fit on the medium used to hold it.
  5944. @xref{Multi-Volume Archives}.
  5945. @item -L @var{num}
  5946. @itemx --tape-length=@var{num}
  5947. Change tape after writing @var{num} x 1024 bytes.
  5948. This option might be useful when your tape drivers do not properly
  5949. detect end of physical tapes. By being slightly conservative on the
  5950. maximum tape length, you might avoid the problem entirely.
  5951. @item -F @var{file}
  5952. @itemx --info-script=@var{file}
  5953. @itemx --new-volume-script=@var{file}
  5954. Execute @file{file} at end of each tape. If @file{file} exits with
  5955. nonzero status, exit. This implies @value{op-multi-volume}.
  5956. @end table
  5957. @node Remote Tape Server
  5958. @section The Remote Tape Server
  5959. @cindex remote tape drive
  5960. @pindex rmt
  5961. In order to access the tape drive on a remote machine, @command{tar}
  5962. uses the remote tape server written at the University of California at
  5963. Berkeley. The remote tape server must be installed as @file{/etc/rmt}
  5964. on any machine whose tape drive you want to use. @command{tar} calls
  5965. @file{/etc/rmt} by running an @command{rsh} or @command{remsh} to the remote
  5966. machine, optionally using a different login name if one is supplied.
  5967. A copy of the source for the remote tape server is provided. It is
  5968. Copyright @copyright{} 1983 by the Regents of the University of
  5969. California, but can be freely distributed. Instructions for compiling
  5970. and installing it are included in the @file{Makefile}.
  5971. @cindex absolute file names
  5972. Unless you use the @value{op-absolute-names} option, @GNUTAR{}
  5973. will not allow you to create an archive that contains
  5974. absolute file names (a file name beginning with @samp{/}.) If you try,
  5975. @command{tar} will automatically remove the leading @samp{/} from the
  5976. file names it stores in the archive. It will also type a warning
  5977. message telling you what it is doing.
  5978. When reading an archive that was created with a different
  5979. @command{tar} program, @GNUTAR{} automatically
  5980. extracts entries in the archive which have absolute file names as if
  5981. the file names were not absolute. This is an important feature. A
  5982. visitor here once gave a @command{tar} tape to an operator to restore;
  5983. the operator used Sun @command{tar} instead of @GNUTAR{},
  5984. and the result was that it replaced large portions of
  5985. our @file{/bin} and friends with versions from the tape; needless to
  5986. say, we were unhappy about having to recover the file system from
  5987. backup tapes.
  5988. For example, if the archive contained a file @file{/usr/bin/computoy},
  5989. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  5990. relative to the current directory. If you want to extract the files in
  5991. an archive to the same absolute names that they had when the archive
  5992. was created, you should do a @samp{cd /} before extracting the files
  5993. from the archive, or you should either use the @value{op-absolute-names}
  5994. option, or use the command @samp{tar -C / @dots{}}.
  5995. @cindex Ultrix 3.1 and write failure
  5996. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  5997. can claim that a short write near the end of a tape succeeded,
  5998. when it actually failed. This will result in the -M option not
  5999. working correctly. The best workaround at the moment is to use a
  6000. significantly larger blocking factor than the default 20.
  6001. In order to update an archive, @command{tar} must be able to backspace the
  6002. archive in order to reread or rewrite a record that was just read (or
  6003. written). This is currently possible only on two kinds of files: normal
  6004. disk files (or any other file that can be backspaced with @samp{lseek}),
  6005. and industry-standard 9-track magnetic tape (or any other kind of tape
  6006. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6007. This means that the @value{op-append}, @value{op-update},
  6008. @value{op-concatenate}, and @value{op-delete} commands will not work on any
  6009. other kind of file. Some media simply cannot be backspaced, which
  6010. means these commands and options will never be able to work on them.
  6011. These non-backspacing media include pipes and cartridge tape drives.
  6012. Some other media can be backspaced, and @command{tar} will work on them
  6013. once @command{tar} is modified to do so.
  6014. Archives created with the @value{op-multi-volume}, @value{op-label}, and
  6015. @value{op-incremental} options may not be readable by other version
  6016. of @command{tar}. In particular, restoring a file that was split over
  6017. a volume boundary will require some careful work with @command{dd}, if
  6018. it can be done at all. Other versions of @command{tar} may also create
  6019. an empty file whose name is that of the volume header. Some versions
  6020. of @command{tar} may create normal files instead of directories archived
  6021. with the @value{op-incremental} option.
  6022. @node Common Problems and Solutions
  6023. @section Some Common Problems and their Solutions
  6024. @ifclear PUBLISH
  6025. @format
  6026. errors from system:
  6027. permission denied
  6028. no such file or directory
  6029. not owner
  6030. errors from @command{tar}:
  6031. directory checksum error
  6032. header format error
  6033. errors from media/system:
  6034. i/o error
  6035. device busy
  6036. @end format
  6037. @end ifclear
  6038. @node Blocking
  6039. @section Blocking
  6040. @UNREVISED
  6041. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6042. is also confusing to the expert reader. On the other hand, readers
  6043. who are new to the field have a fresh mind, and they may safely skip
  6044. the next two paragraphs, as the remainder of this manual uses those
  6045. two terms in a quite consistent way.
  6046. John Gilmore, the writer of the public domain @command{tar} from which
  6047. @GNUTAR{} was originally derived, wrote (June 1995):
  6048. @quotation
  6049. The nomenclature of tape drives comes from IBM, where I believe
  6050. they were invented for the IBM 650 or so. On IBM mainframes, what
  6051. is recorded on tape are tape blocks. The logical organization of
  6052. data is into records. There are various ways of putting records into
  6053. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6054. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6055. to a block), @code{VB} (variable size records, @var{n} to a block),
  6056. @code{VSB} (variable spanned blocked: variable sized records that can
  6057. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6058. parameter specified this to the operating system.
  6059. The Unix man page on @command{tar} was totally confused about this.
  6060. When I wrote @code{PD TAR}, I used the historically correct terminology
  6061. (@command{tar} writes data records, which are grouped into blocks).
  6062. It appears that the bogus terminology made it into @sc{posix} (no surprise
  6063. here), and now Fran@,{c}ois has migrated that terminology back
  6064. into the source code too.
  6065. @end quotation
  6066. The term @dfn{physical block} means the basic transfer chunk from or
  6067. to a device, after which reading or writing may stop without anything
  6068. being lost. In this manual, the term @dfn{block} usually refers to
  6069. a disk physical block, @emph{assuming} that each disk block is 512
  6070. bytes in length. It is true that some disk devices have different
  6071. physical blocks, but @command{tar} ignore these differences in its own
  6072. format, which is meant to be portable, so a @command{tar} block is always
  6073. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6074. The term @dfn{logical block} often represents the basic chunk of
  6075. allocation of many disk blocks as a single entity, which the operating
  6076. system treats somewhat atomically; this concept is only barely used
  6077. in @GNUTAR{}.
  6078. The term @dfn{physical record} is another way to speak of a physical
  6079. block, those two terms are somewhat interchangeable. In this manual,
  6080. the term @dfn{record} usually refers to a tape physical block,
  6081. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6082. It is true that archives may be put on disk or used with pipes,
  6083. but nevertheless, @command{tar} tries to read and write the archive one
  6084. @dfn{record} at a time, whatever the medium in use. One record is made
  6085. up of an integral number of blocks, and this operation of putting many
  6086. disk blocks into a single tape block is called @dfn{reblocking}, or
  6087. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6088. the logical organization of many characters into something meaningful
  6089. to the application. The term @dfn{unit record} describes a small set
  6090. of characters which are transmitted whole to or by the application,
  6091. and often refers to a line of text. Those two last terms are unrelated
  6092. to what we call a @dfn{record} in @GNUTAR{}.
  6093. When writing to tapes, @command{tar} writes the contents of the archive
  6094. in chunks known as @dfn{records}. To change the default blocking
  6095. factor, use the @value{op-blocking-factor} option. Each record will
  6096. then be composed of @var{512-size} blocks. (Each @command{tar} block is
  6097. 512 bytes. @xref{Standard}.) Each file written to the archive uses
  6098. at least one full record. As a result, using a larger record size
  6099. can result in more wasted space for small files. On the other hand, a
  6100. larger record size can often be read and written much more efficiently.
  6101. Further complicating the problem is that some tape drives ignore the
  6102. blocking entirely. For these, a larger record size can still improve
  6103. performance (because the software layers above the tape drive still
  6104. honor the blocking), but not as dramatically as on tape drives that
  6105. honor blocking.
  6106. When reading an archive, @command{tar} can usually figure out the
  6107. record size on itself. When this is the case, and a non-standard
  6108. record size was used when the archive was created, @command{tar} will
  6109. print a message about a non-standard blocking factor, and then operate
  6110. normally. On some tape devices, however, @command{tar} cannot figure
  6111. out the record size itself. On most of those, you can specify a
  6112. blocking factor (with @value{op-blocking-factor}) larger than the
  6113. actual blocking factor, and then use the @value{op-read-full-records}
  6114. option. (If you specify a blocking factor with
  6115. @value{op-blocking-factor} and don't use the
  6116. @value{op-read-full-records} option, then @command{tar} will not
  6117. attempt to figure out the recording size itself.) On some devices,
  6118. you must always specify the record size exactly with
  6119. @value{op-blocking-factor} when reading, because @command{tar} cannot
  6120. figure it out. In any case, use @value{op-list} before doing any
  6121. extractions to see whether @command{tar} is reading the archive
  6122. correctly.
  6123. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6124. putting them into records is to put a whole number of them (one or
  6125. more) into each record. @command{tar} records are all the same size;
  6126. at the end of the file there's a block containing all zeros, which
  6127. is how you tell that the remainder of the last record(s) are garbage.
  6128. In a standard @command{tar} file (no options), the block size is 512
  6129. and the record size is 10240, for a blocking factor of 20. What the
  6130. @value{op-blocking-factor} option does is sets the blocking factor,
  6131. changing the record size while leaving the block size at 512 bytes.
  6132. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6133. most tape drives these days prefer much bigger records in order to
  6134. stream and not waste tape. When writing tapes for myself, some tend
  6135. to use a factor of the order of 2048, say, giving a record size of
  6136. around one megabyte.
  6137. If you use a blocking factor larger than 20, older @command{tar}
  6138. programs might not be able to read the archive, so we recommend this
  6139. as a limit to use in practice. @GNUTAR{}, however,
  6140. will support arbitrarily large record sizes, limited only by the
  6141. amount of virtual memory or the physical characteristics of the tape
  6142. device.
  6143. @menu
  6144. * Format Variations:: Format Variations
  6145. * Blocking Factor:: The Blocking Factor of an Archive
  6146. @end menu
  6147. @node Format Variations
  6148. @subsection Format Variations
  6149. @cindex Format Parameters
  6150. @cindex Format Options
  6151. @cindex Options, archive format specifying
  6152. @cindex Options, format specifying
  6153. @UNREVISED
  6154. Format parameters specify how an archive is written on the archive
  6155. media. The best choice of format parameters will vary depending on
  6156. the type and number of files being archived, and on the media used to
  6157. store the archive.
  6158. To specify format parameters when accessing or creating an archive,
  6159. you can use the options described in the following sections.
  6160. If you do not specify any format parameters, @command{tar} uses
  6161. default parameters. You cannot modify a compressed archive.
  6162. If you create an archive with the @value{op-blocking-factor} option
  6163. specified (@value{pxref-blocking-factor}), you must specify that
  6164. blocking-factor when operating on the archive. @xref{Formats}, for other
  6165. examples of format parameter considerations.
  6166. @node Blocking Factor
  6167. @subsection The Blocking Factor of an Archive
  6168. @cindex Blocking Factor
  6169. @cindex Record Size
  6170. @cindex Number of blocks per record
  6171. @cindex Number of bytes per record
  6172. @cindex Bytes per record
  6173. @cindex Blocks per record
  6174. @UNREVISED
  6175. The data in an archive is grouped into blocks, which are 512 bytes.
  6176. Blocks are read and written in whole number multiples called
  6177. @dfn{records}. The number of blocks in a record (ie. the size of a
  6178. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6179. The @value{op-blocking-factor} option specifies the blocking factor of
  6180. an archive. The default blocking factor is typically 20 (ie.@:
  6181. 10240 bytes), but can be specified at installation. To find out
  6182. the blocking factor of an existing archive, use @samp{tar --list
  6183. --file=@var{archive-name}}. This may not work on some devices.
  6184. Records are separated by gaps, which waste space on the archive media.
  6185. If you are archiving on magnetic tape, using a larger blocking factor
  6186. (and therefore larger records) provides faster throughput and allows you
  6187. to fit more data on a tape (because there are fewer gaps). If you are
  6188. archiving on cartridge, a very large blocking factor (say 126 or more)
  6189. greatly increases performance. A smaller blocking factor, on the other
  6190. hand, may be useful when archiving small files, to avoid archiving lots
  6191. of nulls as @command{tar} fills out the archive to the end of the record.
  6192. In general, the ideal record size depends on the size of the
  6193. inter-record gaps on the tape you are using, and the average size of the
  6194. files you are archiving. @xref{create}, for information on
  6195. writing archives.
  6196. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6197. Archives with blocking factors larger than 20 cannot be read
  6198. by very old versions of @command{tar}, or by some newer versions
  6199. of @command{tar} running on old machines with small address spaces.
  6200. With @GNUTAR{}, the blocking factor of an archive is limited
  6201. only by the maximum record size of the device containing the archive,
  6202. or by the amount of available virtual memory.
  6203. Also, on some systems, not using adequate blocking factors, as sometimes
  6204. imposed by the device drivers, may yield unexpected diagnostics. For
  6205. example, this has been reported:
  6206. @smallexample
  6207. Cannot write to /dev/dlt: Invalid argument
  6208. @end smallexample
  6209. @noindent
  6210. In such cases, it sometimes happen that the @command{tar} bundled by
  6211. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6212. requires an explicit specification for the block size,
  6213. which it cannot guess. This yields some people to consider
  6214. @GNUTAR{} is misbehaving, because by comparison,
  6215. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6216. for example, might resolve the problem.
  6217. If you use a non-default blocking factor when you create an archive, you
  6218. must specify the same blocking factor when you modify that archive. Some
  6219. archive devices will also require you to specify the blocking factor when
  6220. reading that archive, however this is not typically the case. Usually, you
  6221. can use @value{op-list} without specifying a blocking factor---@command{tar}
  6222. reports a non-default record size and then lists the archive members as
  6223. it would normally. To extract files from an archive with a non-standard
  6224. blocking factor (particularly if you're not sure what the blocking factor
  6225. is), you can usually use the @value{op-read-full-records} option while
  6226. specifying a blocking factor larger then the blocking factor of the archive
  6227. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6228. @xref{list}, for more information on the @value{op-list}
  6229. operation. @xref{Reading}, for a more detailed explanation of that option.
  6230. @table @kbd
  6231. @item --blocking-factor=@var{number}
  6232. @itemx -b @var{number}
  6233. Specifies the blocking factor of an archive. Can be used with any
  6234. operation, but is usually not necessary with @value{op-list}.
  6235. @end table
  6236. Device blocking
  6237. @table @kbd
  6238. @item -b @var{blocks}
  6239. @itemx --blocking-factor=@var{blocks}
  6240. Set record size to @math{@var{blocks} * 512} bytes.
  6241. This option is used to specify a @dfn{blocking factor} for the archive.
  6242. When reading or writing the archive, @command{tar}, will do reads and writes
  6243. of the archive in records of @math{@var{block}*512} bytes. This is true
  6244. even when the archive is compressed. Some devices requires that all
  6245. write operations be a multiple of a certain size, and so, @command{tar}
  6246. pads the archive out to the next record boundary.
  6247. The default blocking factor is set when @command{tar} is compiled, and is
  6248. typically 20. Blocking factors larger than 20 cannot be read by very
  6249. old versions of @command{tar}, or by some newer versions of @command{tar}
  6250. running on old machines with small address spaces.
  6251. With a magnetic tape, larger records give faster throughput and fit
  6252. more data on a tape (because there are fewer inter-record gaps).
  6253. If the archive is in a disk file or a pipe, you may want to specify
  6254. a smaller blocking factor, since a large one will result in a large
  6255. number of null bytes at the end of the archive.
  6256. When writing cartridge or other streaming tapes, a much larger
  6257. blocking factor (say 126 or more) will greatly increase performance.
  6258. However, you must specify the same blocking factor when reading or
  6259. updating the archive.
  6260. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6261. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6262. seems to disappear. Id est, we are using block size of 112 right
  6263. now, and we haven't had the problem since we switched@dots{}
  6264. With @GNUTAR{} the blocking factor is limited only
  6265. by the maximum record size of the device containing the archive, or by
  6266. the amount of available virtual memory.
  6267. However, deblocking or reblocking is virtually avoided in a special
  6268. case which often occurs in practice, but which requires all the
  6269. following conditions to be simultaneously true:
  6270. @itemize @bullet
  6271. @item
  6272. the archive is subject to a compression option,
  6273. @item
  6274. the archive is not handled through standard input or output, nor
  6275. redirected nor piped,
  6276. @item
  6277. the archive is directly handled to a local disk, instead of any special
  6278. device,
  6279. @item
  6280. @value{op-blocking-factor} is not explicitly specified on the @command{tar}
  6281. invocation.
  6282. @end itemize
  6283. If the output goes directly to a local disk, and not through
  6284. stdout, then the last write is not extended to a full record size.
  6285. Otherwise, reblocking occurs. Here are a few other remarks on this
  6286. topic:
  6287. @itemize @bullet
  6288. @item
  6289. @command{gzip} will complain about trailing garbage if asked to
  6290. uncompress a compressed archive on tape, there is an option to turn
  6291. the message off, but it breaks the regularity of simply having to use
  6292. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6293. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6294. Gailly, by sending a copy of this message to him.
  6295. @item
  6296. @command{compress} does not show this problem, but as Jean-loup pointed
  6297. out to Michael, @samp{compress -d} silently adds garbage after
  6298. the result of decompression, which tar ignores because it already
  6299. recognized its end-of-file indicator. So this bug may be safely
  6300. ignored.
  6301. @item
  6302. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6303. but will still return an exit status of 2 which tar reports in turn.
  6304. @command{tar} might ignore the exit status returned, but I hate doing
  6305. that, as it weakens the protection @command{tar} offers users against
  6306. other possible problems at decompression time. If @command{gzip} was
  6307. silently skipping trailing zeros @emph{and} also avoiding setting the
  6308. exit status in this innocuous case, that would solve this situation.
  6309. @item
  6310. @command{tar} should become more solid at not stopping to read a pipe at
  6311. the first null block encountered. This inelegantly breaks the pipe.
  6312. @command{tar} should rather drain the pipe out before exiting itself.
  6313. @end itemize
  6314. @item -i
  6315. @itemx --ignore-zeros
  6316. Ignore blocks of zeros in archive (means EOF).
  6317. The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
  6318. of zeros in the archive. Normally a block of zeros indicates the
  6319. end of the archive, but when reading a damaged archive, or one which
  6320. was created by concatenating several archives together, this option
  6321. allows @command{tar} to read the entire archive. This option is not on
  6322. by default because many versions of @command{tar} write garbage after
  6323. the zeroed blocks.
  6324. Note that this option causes @command{tar} to read to the end of the
  6325. archive file, which may sometimes avoid problems when multiple files
  6326. are stored on a single physical tape.
  6327. @item -B
  6328. @itemx --read-full-records
  6329. Reblock as we read (for reading 4.2BSD pipes).
  6330. If @value{op-read-full-records} is used, @command{tar} will not panic if an
  6331. attempt to read a record from the archive does not return a full record.
  6332. Instead, @command{tar} will keep reading until it has obtained a full
  6333. record.
  6334. This option is turned on by default when @command{tar} is reading
  6335. an archive from standard input, or from a remote machine. This is
  6336. because on BSD Unix systems, a read of a pipe will return however
  6337. much happens to be in the pipe, even if it is less than @command{tar}
  6338. requested. If this option was not used, @command{tar} would fail as
  6339. soon as it read an incomplete record from the pipe.
  6340. This option is also useful with the commands for updating an archive.
  6341. @end table
  6342. Tape blocking
  6343. @FIXME{Appropriate options should be moved here from elsewhere.}
  6344. @cindex blocking factor
  6345. @cindex tape blocking
  6346. When handling various tapes or cartridges, you have to take care of
  6347. selecting a proper blocking, that is, the number of disk blocks you
  6348. put together as a single tape block on the tape, without intervening
  6349. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  6350. with no information on it, used for decelerating the tape to a
  6351. full stop, and for later regaining the reading or writing speed.
  6352. When the tape driver starts reading a record, the record has to
  6353. be read whole without stopping, as a tape gap is needed to stop the
  6354. tape motion without loosing information.
  6355. @cindex Exabyte blocking
  6356. @cindex DAT blocking
  6357. Using higher blocking (putting more disk blocks per tape block) will use
  6358. the tape more efficiently as there will be less tape gaps. But reading
  6359. such tapes may be more difficult for the system, as more memory will be
  6360. required to receive at once the whole record. Further, if there is a
  6361. reading error on a huge record, this is less likely that the system will
  6362. succeed in recovering the information. So, blocking should not be too
  6363. low, nor it should be too high. @command{tar} uses by default a blocking of
  6364. 20 for historical reasons, and it does not really matter when reading or
  6365. writing to disk. Current tape technology would easily accommodate higher
  6366. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  6367. We were told that for some DLT drives, the blocking should be a multiple
  6368. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  6369. Other manufacturers may use different recommendations for the same tapes.
  6370. This might also depends of the buffering techniques used inside modern
  6371. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  6372. Others request blocking to be some exponent of two.
  6373. So, there is no fixed rule for blocking. But blocking at read time
  6374. should ideally be the same as blocking used at write time. At one place
  6375. I know, with a wide variety of equipment, they found it best to use a
  6376. blocking of 32 to guarantee that their tapes are fully interchangeable.
  6377. I was also told that, for recycled tapes, prior erasure (by the same
  6378. drive unit that will be used to create the archives) sometimes lowers
  6379. the error rates observed at rewriting time.
  6380. I might also use @samp{--number-blocks} instead of
  6381. @samp{--block-number}, so @samp{--block} will then expand to
  6382. @samp{--blocking-factor} unambiguously.
  6383. @node Many
  6384. @section Many Archives on One Tape
  6385. @FIXME{Appropriate options should be moved here from elsewhere.}
  6386. @findex ntape @r{device}
  6387. Most tape devices have two entries in the @file{/dev} directory, or
  6388. entries that come in pairs, which differ only in the minor number for
  6389. this device. Let's take for example @file{/dev/tape}, which often
  6390. points to the only or usual tape device of a given system. There might
  6391. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  6392. name is the @emph{rewinding} version of the device, while the name
  6393. having @samp{nr} in it is the @emph{no rewinding} version of the same
  6394. device.
  6395. A rewinding tape device will bring back the tape to its beginning point
  6396. automatically when this device is opened or closed. Since @command{tar}
  6397. opens the archive file before using it and closes it afterwards, this
  6398. means that a simple:
  6399. @smallexample
  6400. $ @kbd{tar cf /dev/tape @var{directory}}
  6401. @end smallexample
  6402. @noindent
  6403. will reposition the tape to its beginning both prior and after saving
  6404. @var{directory} contents to it, thus erasing prior tape contents and
  6405. making it so that any subsequent write operation will destroy what has
  6406. just been saved.
  6407. @cindex tape positioning
  6408. So, a rewinding device is normally meant to hold one and only one file.
  6409. If you want to put more than one @command{tar} archive on a given tape, you
  6410. will need to avoid using the rewinding version of the tape device. You
  6411. will also have to pay special attention to tape positioning. Errors in
  6412. positioning may overwrite the valuable data already on your tape. Many
  6413. people, burnt by past experiences, will only use rewinding devices and
  6414. limit themselves to one file per tape, precisely to avoid the risk of
  6415. such errors. Be fully aware that writing at the wrong position on a
  6416. tape loses all information past this point and most probably until the
  6417. end of the tape, and this destroyed information @emph{cannot} be
  6418. recovered.
  6419. To save @var{directory-1} as a first archive at the beginning of a
  6420. tape, and leave that tape ready for a second archive, you should use:
  6421. @smallexample
  6422. $ @kbd{mt -f /dev/nrtape rewind}
  6423. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  6424. @end smallexample
  6425. @cindex tape marks
  6426. @dfn{Tape marks} are special magnetic patterns written on the tape
  6427. media, which are later recognizable by the reading hardware. These
  6428. marks are used after each file, when there are many on a single tape.
  6429. An empty file (that is to say, two tape marks in a row) signal the
  6430. logical end of the tape, after which no file exist. Usually,
  6431. non-rewinding tape device drivers will react to the close request issued
  6432. by @command{tar} by first writing two tape marks after your archive, and by
  6433. backspacing over one of these. So, if you remove the tape at that time
  6434. from the tape drive, it is properly terminated. But if you write
  6435. another file at the current position, the second tape mark will be
  6436. erased by the new information, leaving only one tape mark between files.
  6437. So, you may now save @var{directory-2} as a second archive after the
  6438. first on the same tape by issuing the command:
  6439. @smallexample
  6440. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  6441. @end smallexample
  6442. @noindent
  6443. and so on for all the archives you want to put on the same tape.
  6444. Another usual case is that you do not write all the archives the same
  6445. day, and you need to remove and store the tape between two archive
  6446. sessions. In general, you must remember how many files are already
  6447. saved on your tape. Suppose your tape already has 16 files on it, and
  6448. that you are ready to write the 17th. You have to take care of skipping
  6449. the first 16 tape marks before saving @var{directory-17}, say, by using
  6450. these commands:
  6451. @smallexample
  6452. $ @kbd{mt -f /dev/nrtape rewind}
  6453. $ @kbd{mt -f /dev/nrtape fsf 16}
  6454. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  6455. @end smallexample
  6456. In all the previous examples, we put aside blocking considerations, but
  6457. you should do the proper things for that as well. @xref{Blocking}.
  6458. @menu
  6459. * Tape Positioning:: Tape Positions and Tape Marks
  6460. * mt:: The @command{mt} Utility
  6461. @end menu
  6462. @node Tape Positioning
  6463. @subsection Tape Positions and Tape Marks
  6464. @UNREVISED
  6465. Just as archives can store more than one file from the file system,
  6466. tapes can store more than one archive file. To keep track of where
  6467. archive files (or any other type of file stored on tape) begin and
  6468. end, tape archive devices write magnetic @dfn{tape marks} on the
  6469. archive media. Tape drives write one tape mark between files,
  6470. two at the end of all the file entries.
  6471. If you think of data as a series of records "rrrr"'s, and tape marks as
  6472. "*"'s, a tape might look like the following:
  6473. @smallexample
  6474. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  6475. @end smallexample
  6476. Tape devices read and write tapes using a read/write @dfn{tape
  6477. head}---a physical part of the device which can only access one
  6478. point on the tape at a time. When you use @command{tar} to read or
  6479. write archive data from a tape device, the device will begin reading
  6480. or writing from wherever on the tape the tape head happens to be,
  6481. regardless of which archive or what part of the archive the tape
  6482. head is on. Before writing an archive, you should make sure that no
  6483. data on the tape will be overwritten (unless it is no longer needed).
  6484. Before reading an archive, you should make sure the tape head is at
  6485. the beginning of the archive you want to read. (The @code{restore}
  6486. script will find the archive automatically. @FIXME{There is no such
  6487. restore script!}@FIXME-xref{Scripted Restoration}@xref{mt}, for
  6488. an explanation of the tape moving utility.
  6489. If you want to add new archive file entries to a tape, you should
  6490. advance the tape to the end of the existing file entries, backspace
  6491. over the last tape mark, and write the new archive file. If you were
  6492. to add two archives to the example above, the tape might look like the
  6493. following:
  6494. @smallexample
  6495. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  6496. @end smallexample
  6497. @node mt
  6498. @subsection The @command{mt} Utility
  6499. @UNREVISED
  6500. @FIXME{Is it true that this only works on non-block devices?
  6501. should explain the difference, (fixed or variable).}
  6502. @value{xref-blocking-factor}.
  6503. You can use the @command{mt} utility to advance or rewind a tape past a
  6504. specified number of archive files on the tape. This will allow you
  6505. to move to the beginning of an archive before extracting or reading
  6506. it, or to the end of all the archives before writing a new one.
  6507. @FIXME{Why isn't there an "advance 'til you find two tape marks
  6508. together"?}
  6509. The syntax of the @command{mt} command is:
  6510. @smallexample
  6511. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  6512. @end smallexample
  6513. where @var{tapename} is the name of the tape device, @var{number} is
  6514. the number of times an operation is performed (with a default of one),
  6515. and @var{operation} is one of the following:
  6516. @FIXME{is there any use for record operations?}
  6517. @table @kbd
  6518. @item eof
  6519. @itemx weof
  6520. Writes @var{number} tape marks at the current position on the tape.
  6521. @item fsf
  6522. Moves tape position forward @var{number} files.
  6523. @item bsf
  6524. Moves tape position back @var{number} files.
  6525. @item rewind
  6526. Rewinds the tape. (Ignores @var{number}).
  6527. @item offline
  6528. @itemx rewoff1
  6529. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  6530. @item status
  6531. Prints status information about the tape unit.
  6532. @end table
  6533. @FIXME{Is there a better way to frob the spacing on the list?}
  6534. If you don't specify a @var{tapename}, @command{mt} uses the environment
  6535. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  6536. @file{/dev/rmt12}.
  6537. @command{mt} returns a 0 exit status when the operation(s) were
  6538. successful, 1 if the command was unrecognized, and 2 if an operation
  6539. failed.
  6540. @FIXME{New node on how to find an archive?}
  6541. If you use @value{op-extract} with the @value{op-label} option specified,
  6542. @command{tar} will read an archive label (the tape head has to be positioned
  6543. on it) and print an error if the archive label doesn't match the
  6544. @var{archive-name} specified. @var{archive-name} can be any regular
  6545. expression. If the labels match, @command{tar} extracts the archive.
  6546. @value{xref-label}.
  6547. @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
  6548. references}@samp{tar --list --label} will cause @command{tar} to print the
  6549. label.
  6550. @FIXME{Program to list all the labels on a tape?}
  6551. @node Using Multiple Tapes
  6552. @section Using Multiple Tapes
  6553. @UNREVISED
  6554. Often you might want to write a large archive, one larger than will fit
  6555. on the actual tape you are using. In such a case, you can run multiple
  6556. @command{tar} commands, but this can be inconvenient, particularly if you
  6557. are using options like @value{op-exclude} or dumping entire filesystems.
  6558. Therefore, @command{tar} supports multiple tapes automatically.
  6559. Use @value{op-multi-volume} on the command line, and then @command{tar} will,
  6560. when it reaches the end of the tape, prompt for another tape, and
  6561. continue the archive. Each tape will have an independent archive, and
  6562. can be read without needing the other. (As an exception to this, the
  6563. file that @command{tar} was archiving when it ran out of tape will usually
  6564. be split between the two archives; in this case you need to extract from
  6565. the first archive, using @value{op-multi-volume}, and then put in the
  6566. second tape when prompted, so @command{tar} can restore both halves of the
  6567. file.)
  6568. @GNUTAR{} multi-volume archives do not use a truly
  6569. portable format. You need @GNUTAR{} at both end to
  6570. process them properly.
  6571. When prompting for a new tape, @command{tar} accepts any of the following
  6572. responses:
  6573. @table @kbd
  6574. @item ?
  6575. Request @command{tar} to explain possible responses
  6576. @item q
  6577. Request @command{tar} to exit immediately.
  6578. @item n @var{file name}
  6579. Request @command{tar} to write the next volume on the file @var{file name}.
  6580. @item !
  6581. Request @command{tar} to run a subshell.
  6582. @item y
  6583. Request @command{tar} to begin writing the next volume.
  6584. @end table
  6585. (You should only type @samp{y} after you have changed the tape;
  6586. otherwise @command{tar} will write over the volume it just finished.)
  6587. If you want more elaborate behavior than this, give @command{tar} the
  6588. @value{op-info-script} option. The file @var{script-name} is expected
  6589. to be a program (or shell script) to be run instead of the normal
  6590. prompting procedure. If the program fails, @command{tar} exits;
  6591. otherwise, @command{tar} begins writing the next volume. The behavior
  6592. of the
  6593. @samp{n} response to the normal tape-change prompt is not available
  6594. if you use @value{op-info-script}.
  6595. The method @command{tar} uses to detect end of tape is not perfect, and
  6596. fails on some operating systems or on some devices. You can use the
  6597. @value{op-tape-length} option if @command{tar} can't detect the end of the
  6598. tape itself. This option selects @value{op-multi-volume} automatically.
  6599. The @var{size} argument should then be the usable size of the tape.
  6600. But for many devices, and floppy disks in particular, this option is
  6601. never required for real, as far as we know.
  6602. The volume number used by @command{tar} in its tape-change prompt
  6603. can be changed; if you give the @value{op-volno-file} option, then
  6604. @var{file-of-number} should be an unexisting file to be created, or else,
  6605. a file already containing a decimal number. That number will be used
  6606. as the volume number of the first volume written. When @command{tar} is
  6607. finished, it will rewrite the file with the now-current volume number.
  6608. (This does not change the volume number written on a tape label, as
  6609. per @value{ref-label}, it @emph{only} affects the number used in
  6610. the prompt.)
  6611. If you want @command{tar} to cycle through a series of tape drives, then
  6612. you can use the @samp{n} response to the tape-change prompt. This is
  6613. error prone, however, and doesn't work at all with @value{op-info-script}.
  6614. Therefore, if you give @command{tar} multiple @value{op-file} options, then
  6615. the specified files will be used, in sequence, as the successive volumes
  6616. of the archive. Only when the first one in the sequence needs to be
  6617. used again will @command{tar} prompt for a tape change (or run the info
  6618. script).
  6619. Multi-volume archives
  6620. With @value{op-multi-volume}, @command{tar} will not abort when it cannot
  6621. read or write any more data. Instead, it will ask you to prepare a new
  6622. volume. If the archive is on a magnetic tape, you should change tapes
  6623. now; if the archive is on a floppy disk, you should change disks, etc.
  6624. Each volume of a multi-volume archive is an independent @command{tar}
  6625. archive, complete in itself. For example, you can list or extract any
  6626. volume alone; just don't specify @value{op-multi-volume}. However, if one
  6627. file in the archive is split across volumes, the only way to extract
  6628. it successfully is with a multi-volume extract command @samp{--extract
  6629. --multi-volume} (@samp{-xM}) starting on or before the volume where
  6630. the file begins.
  6631. For example, let's presume someone has two tape drives on a system
  6632. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  6633. to switch to the second drive when it needs to write the
  6634. second tape, and then back to the first tape, etc., just do either of:
  6635. @smallexample
  6636. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  6637. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  6638. @end smallexample
  6639. @menu
  6640. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  6641. * Tape Files:: Tape Files
  6642. @end menu
  6643. @node Multi-Volume Archives
  6644. @subsection Archives Longer than One Tape or Disk
  6645. @cindex Multi-volume archives
  6646. @UNREVISED
  6647. To create an archive that is larger than will fit on a single unit of
  6648. the media, use the @value{op-multi-volume} option in conjunction with
  6649. the @value{op-create} option (@pxref{create}). A
  6650. @dfn{multi-volume} archive can be manipulated like any other archive
  6651. (provided the @value{op-multi-volume} option is specified), but is
  6652. stored on more than one tape or disk.
  6653. When you specify @value{op-multi-volume}, @command{tar} does not report an
  6654. error when it comes to the end of an archive volume (when reading), or
  6655. the end of the media (when writing). Instead, it prompts you to load
  6656. a new storage volume. If the archive is on a magnetic tape, you
  6657. should change tapes when you see the prompt; if the archive is on a
  6658. floppy disk, you should change disks; etc.
  6659. You can read each individual volume of a multi-volume archive as if it
  6660. were an archive by itself. For example, to list the contents of one
  6661. volume, use @value{op-list}, without @value{op-multi-volume} specified.
  6662. To extract an archive member from one volume (assuming it is described
  6663. that volume), use @value{op-extract}, again without
  6664. @value{op-multi-volume}.
  6665. If an archive member is split across volumes (ie. its entry begins on
  6666. one volume of the media and ends on another), you need to specify
  6667. @value{op-multi-volume} to extract it successfully. In this case, you
  6668. should load the volume where the archive member starts, and use
  6669. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  6670. volumes as it needs them. @xref{extracting archives}, for more
  6671. information about extracting archives.
  6672. @value{op-info-script} is like @value{op-multi-volume}, except that
  6673. @command{tar} does not prompt you directly to change media volumes when
  6674. a volume is full---instead, @command{tar} runs commands you have stored
  6675. in @var{script-name}. For example, this option can be used to eject
  6676. cassettes, or to broadcast messages such as @samp{Someone please come
  6677. change my tape} when performing unattended backups. When @var{script-name}
  6678. is done, @command{tar} will assume that the media has been changed.
  6679. Multi-volume archives can be modified like any other archive. To add
  6680. files to a multi-volume archive, you need to only mount the last
  6681. volume of the archive media (and new volumes, if needed). For all
  6682. other operations, you need to use the entire archive.
  6683. If a multi-volume archive was labeled using @value{op-label}
  6684. (@value{pxref-label}) when it was created, @command{tar} will not
  6685. automatically label volumes which are added later. To label subsequent
  6686. volumes, specify @value{op-label} again in conjunction with the
  6687. @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
  6688. @cindex Labeling multi-volume archives
  6689. @FIXME{example}
  6690. @FIXME{There should be a sample program here, including an exit
  6691. before end. Is the exit status even checked in tar? :-(}
  6692. @table @kbd
  6693. @item --multi-volume
  6694. @itemx -M
  6695. Creates a multi-volume archive, when used in conjunction with
  6696. @value{op-create}. To perform any other operation on a multi-volume
  6697. archive, specify @value{op-multi-volume} in conjunction with that
  6698. operation.
  6699. @item --info-script=@var{program-file}
  6700. @itemx -F @var{program-file}
  6701. Creates a multi-volume archive via a script. Used in conjunction with
  6702. @value{op-create}.
  6703. @end table
  6704. Beware that there is @emph{no} real standard about the proper way, for
  6705. a @command{tar} archive, to span volume boundaries. If you have a
  6706. multi-volume created by some vendor's @command{tar}, there is almost
  6707. no chance you could read all the volumes with @GNUTAR{}.
  6708. The converse is also true: you may not expect
  6709. multi-volume archives created by @GNUTAR{} to be
  6710. fully recovered by vendor's @command{tar}. Since there is little
  6711. chance that, in mixed system configurations, some vendor's
  6712. @command{tar} will work on another vendor's machine, and there is a
  6713. great chance that @GNUTAR{} will work on most of
  6714. them, your best bet is to install @GNUTAR{} on all
  6715. machines between which you know exchange of files is possible.
  6716. @node Tape Files
  6717. @subsection Tape Files
  6718. @UNREVISED
  6719. To give the archive a name which will be recorded in it, use the
  6720. @value{op-label} option. This will write a special block identifying
  6721. @var{volume-label} as the name of the archive to the front of the archive
  6722. which will be displayed when the archive is listed with @value{op-list}.
  6723. If you are creating a multi-volume archive with
  6724. @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
  6725. volume label will have
  6726. @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
  6727. the number of the volume of the archive. (If you use the @value{op-label}
  6728. option when reading an archive, it checks to make sure the label on the
  6729. tape matches the one you give. @value{xref-label}.
  6730. When @command{tar} writes an archive to tape, it creates a single
  6731. tape file. If multiple archives are written to the same tape, one
  6732. after the other, they each get written as separate tape files. When
  6733. extracting, it is necessary to position the tape at the right place
  6734. before running @command{tar}. To do this, use the @command{mt} command.
  6735. For more information on the @command{mt} command and on the organization
  6736. of tapes into a sequence of tape files, see @ref{mt}.
  6737. People seem to often do:
  6738. @smallexample
  6739. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  6740. @end smallexample
  6741. or such, for pushing a common date in all volumes or an archive set.
  6742. @node label
  6743. @section Including a Label in the Archive
  6744. @cindex Labeling an archive
  6745. @cindex Labels on the archive media
  6746. @UNREVISED
  6747. @table @kbd
  6748. @item -V @var{name}
  6749. @itemx --label=@var{name}
  6750. Create archive with volume name @var{name}.
  6751. @end table
  6752. This option causes @command{tar} to write out a @dfn{volume header} at
  6753. the beginning of the archive. If @value{op-multi-volume} is used, each
  6754. volume of the archive will have a volume header of @samp{@var{name}
  6755. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  6756. next, and so on.
  6757. @FIXME{Should the arg to --label be a quoted string?? No.}
  6758. To avoid problems caused by misplaced paper labels on the archive
  6759. media, you can include a @dfn{label} entry---an archive member which
  6760. contains the name of the archive---in the archive itself. Use the
  6761. @value{op-label} option in conjunction with the @value{op-create} operation
  6762. to include a label entry in the archive as it is being created.
  6763. If you create an archive using both @value{op-label} and
  6764. @value{op-multi-volume}, each volume of the archive will have an
  6765. archive label of the form @samp{@var{archive-label} Volume @var{n}},
  6766. where @var{n} is 1 for the first volume, 2 for the next, and so on.
  6767. @FIXME-xref{Multi-Volume Archives, for information on creating multiple
  6768. volume archives.}
  6769. If you list or extract an archive using @value{op-label}, @command{tar} will
  6770. print an error if the archive label doesn't match the @var{archive-label}
  6771. specified, and will then not list nor extract the archive. In those cases,
  6772. @var{archive-label} argument is interpreted as a globbing-style pattern
  6773. which must match the actual magnetic volume label. @xref{exclude}, for
  6774. a precise description of how match is attempted@footnote{Previous versions
  6775. of @command{tar} used full regular expression matching, or before that, only
  6776. exact string matching, instead of wildcard matchers. We decided for the
  6777. sake of simplicity to use a uniform matching device through @command{tar}.}.
  6778. If the switch @value{op-multi-volume} is being used, the volume label
  6779. matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
  6780. if the initial match fails, before giving up. Since the volume numbering
  6781. is automatically added in labels at creation time, it sounded logical to
  6782. equally help the user taking care of it when the archive is being read.
  6783. The @value{op-label} was once called @samp{--volume}, but is not available
  6784. under that name anymore.
  6785. To find out an archive's label entry (or to find out if an archive has
  6786. a label at all), use @samp{tar --list --verbose}. @command{tar} will
  6787. print the label first, and then print archive member information, as
  6788. in the example below:
  6789. @smallexample
  6790. $ @kbd{tar --verbose --list --file=iamanarchive}
  6791. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  6792. -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
  6793. @end smallexample
  6794. @table @kbd
  6795. @item --label=@var{archive-label}
  6796. @itemx -V @var{archive-label}
  6797. Includes an @dfn{archive-label} at the beginning of the archive when
  6798. the archive is being created, when used in conjunction with the
  6799. @value{op-create} option. Checks to make sure the archive label
  6800. matches the one specified (when used in conjunction with the
  6801. @value{op-extract} option.
  6802. @end table
  6803. To get a common information on all tapes of a series, use the
  6804. @value{op-label} option. For having this information different in each
  6805. series created through a single script used on a regular basis, just
  6806. manage to get some date string as part of the label. For example:
  6807. @smallexample
  6808. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  6809. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  6810. --volume="Daily backup for `date +%Y-%m-%d`"}
  6811. @end smallexample
  6812. Also note that each label has its own date and time, which corresponds
  6813. to when @GNUTAR{} initially attempted to write it,
  6814. often soon after the operator launches @command{tar} or types the
  6815. carriage return telling that the next tape is ready. Comparing date
  6816. labels does give an idea of tape throughput only if the delays for
  6817. rewinding tapes and the operator switching them were negligible, which
  6818. is usually not the case.
  6819. @FIXME{was --volume}
  6820. @node verify
  6821. @section Verifying Data as It is Stored
  6822. @cindex Verifying a write operation
  6823. @cindex Double-checking a write operation
  6824. @table @kbd
  6825. @item -W
  6826. @itemx --verify
  6827. Attempt to verify the archive after writing.
  6828. @end table
  6829. This option causes @command{tar} to verify the archive after writing it.
  6830. Each volume is checked after it is written, and any discrepancies
  6831. are recorded on the standard error output.
  6832. Verification requires that the archive be on a back-space-able medium.
  6833. This means pipes, some cartridge tape drives, and some other devices
  6834. cannot be verified.
  6835. You can insure the accuracy of an archive by comparing files in the
  6836. system with archive members. @command{tar} can compare an archive to the
  6837. file system as the archive is being written, to verify a write
  6838. operation, or can compare a previously written archive, to insure that
  6839. it is up to date.
  6840. To check for discrepancies in an archive immediately after it is
  6841. written, use the @value{op-verify} option in conjunction with
  6842. the @value{op-create} operation. When this option is
  6843. specified, @command{tar} checks archive members against their counterparts
  6844. in the file system, and reports discrepancies on the standard error.
  6845. To verify an archive, you must be able to read it from before the end
  6846. of the last written entry. This option is useful for detecting data
  6847. errors on some tapes. Archives written to pipes, some cartridge tape
  6848. drives, and some other devices cannot be verified.
  6849. One can explicitly compare an already made archive with the file system
  6850. by using the @value{op-compare} option, instead of using the more automatic
  6851. @value{op-verify} option. @value{xref-compare}.
  6852. Note that these two options have a slightly different intent. The
  6853. @value{op-compare} option how identical are the logical contents of some
  6854. archive with what is on your disks, while the @value{op-verify} option is
  6855. really for checking if the physical contents agree and if the recording
  6856. media itself is of dependable quality. So, for the @value{op-verify}
  6857. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  6858. the archive, while it lets the speed optimization undisturbed for the
  6859. @value{op-compare} option. If you nevertheless use @value{op-compare} for
  6860. media verification, you may have to defeat the in-memory cache yourself,
  6861. maybe by opening and reclosing the door latch of your recording unit,
  6862. forcing some doubt in your operating system about the fact this is really
  6863. the same volume as the one just written or read.
  6864. The @value{op-verify} option would not be necessary if drivers were indeed
  6865. able to detect dependably all write failures. This sometimes require many
  6866. magnetic heads, some able to read after the writes occurred. One would
  6867. not say that drivers unable to detect all cases are necessarily flawed,
  6868. as long as programming is concerned.
  6869. The @value{op-verify} option will not work in conjunction with the
  6870. @value{op-multi-volume} option or the @value{op-append},
  6871. @value{op-update} and @value{op-delete} operations. @xref{Operations},
  6872. for more information on these operations.
  6873. Also, since @command{tar} normally strips leading @samp{/} from file
  6874. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  6875. /tmp/foo.tar /etc} will work as desired only if the working directory is
  6876. @file{/}, as @command{tar} uses the archive's relative member names
  6877. (e.g., @file{etc/motd}) when verifying the archive.
  6878. @node Write Protection
  6879. @section Write Protection
  6880. Almost all tapes and diskettes, and in a few rare cases, even disks can
  6881. be @dfn{write protected}, to protect data on them from being changed.
  6882. Once an archive is written, you should write protect the media to prevent
  6883. the archive from being accidentally overwritten or deleted. (This will
  6884. protect the archive from being changed with a tape or floppy drive---it
  6885. will not protect it from magnet fields or other physical hazards).
  6886. The write protection device itself is usually an integral part of the
  6887. physical media, and can be a two position (write enabled/write
  6888. disabled) switch, a notch which can be popped out or covered, a ring
  6889. which can be removed from the center of a tape reel, or some other
  6890. changeable feature.
  6891. @node Free Software Needs Free Documentation
  6892. @appendix Free Software Needs Free Documentation
  6893. @include freemanuals.texi
  6894. @node Copying This Manual
  6895. @appendix Copying This Manual
  6896. @menu
  6897. * GNU Free Documentation License:: License for copying this manual
  6898. @end menu
  6899. @include fdl.texi
  6900. @node Index
  6901. @appendix Index
  6902. @printindex cp
  6903. @summarycontents
  6904. @contents
  6905. @bye
  6906. @c Local variables:
  6907. @c texinfo-column-for-description: 32
  6908. @c End: