tar.texi 351 KB

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