tar.texi 378 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934
  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. @copying
  19. This manual is for @acronym{GNU} @command{tar} (version
  20. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  21. from archives.
  22. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  23. 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  24. @quotation
  25. Permission is granted to copy, distribute and/or modify this document
  26. under the terms of the GNU Free Documentation License, Version 1.1 or
  27. any later version published by the Free Software Foundation; with no
  28. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
  29. and with the Back-Cover Texts as in (a) below. A copy of the license
  30. is included in the section entitled "GNU Free Documentation License".
  31. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  32. this GNU Manual. Buying copies from GNU Press supports the FSF in
  33. developing GNU and promoting software freedom.''
  34. @end quotation
  35. @end copying
  36. @dircategory Archiving
  37. @direntry
  38. * Tar: (tar). Making tape (or disk) archives.
  39. @end direntry
  40. @dircategory Individual utilities
  41. @direntry
  42. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  43. @end direntry
  44. @shorttitlepage @acronym{GNU} @command{tar}
  45. @titlepage
  46. @title @acronym{GNU} tar: an archiver tool
  47. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  48. @author John Gilmore, Jay Fenlason et al.
  49. @page
  50. @vskip 0pt plus 1filll
  51. @insertcopying
  52. @end titlepage
  53. @ifnottex
  54. @node Top
  55. @top @acronym{GNU} tar: an archiver tool
  56. @insertcopying
  57. @cindex file archival
  58. @cindex archiving files
  59. The first part of this master menu lists the major nodes in this Info
  60. document. The rest of the menu lists all the lower level nodes.
  61. @end ifnottex
  62. @c The master menu, created with texinfo-master-menu, goes here.
  63. @c (However, getdate.texi's menu is interpolated by hand.)
  64. @menu
  65. * Introduction::
  66. * Tutorial::
  67. * tar invocation::
  68. * operations::
  69. * Backups::
  70. * Choosing::
  71. * Date input formats::
  72. * Formats::
  73. * Media::
  74. Appendices
  75. * Changes::
  76. * Configuring Help Summary::
  77. * Genfile::
  78. * Snapshot Files::
  79. * Free Software Needs Free Documentation::
  80. * Copying This Manual::
  81. * Index of Command Line Options::
  82. * Index::
  83. @detailmenu
  84. --- The Detailed Node Listing ---
  85. Introduction
  86. * Book Contents:: What this Book Contains
  87. * Definitions:: Some Definitions
  88. * What tar Does:: What @command{tar} Does
  89. * Naming tar Archives:: How @command{tar} Archives are Named
  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. * defaults::
  126. * verbose::
  127. * interactive::
  128. The Three Option Styles
  129. * Mnemonic Options:: Mnemonic Option Style
  130. * Short Options:: Short Option Style
  131. * Old Options:: Old Option Style
  132. * Mixing:: Mixing Option Styles
  133. All @command{tar} Options
  134. * Operation Summary::
  135. * Option Summary::
  136. * Short Option Summary::
  137. @GNUTAR{} Operations
  138. * Basic tar::
  139. * Advanced tar::
  140. * create options::
  141. * extract options::
  142. * backup::
  143. * Applications::
  144. * looking ahead::
  145. Advanced @GNUTAR{} Operations
  146. * Operations::
  147. * append::
  148. * update::
  149. * concatenate::
  150. * delete::
  151. * compare::
  152. How to Add Files to Existing Archives: @option{--append}
  153. * appending files:: Appending Files to an Archive
  154. * multiple::
  155. Updating an Archive
  156. * how to update::
  157. Options Used by @option{--create}
  158. * Ignore Failed Read::
  159. Options Used by @option{--extract}
  160. * Reading:: Options to Help Read Archives
  161. * Writing:: Changing How @command{tar} Writes Files
  162. * Scarce:: Coping with Scarce Resources
  163. Options to Help Read Archives
  164. * read full records::
  165. * Ignore Zeros::
  166. Changing How @command{tar} Writes Files
  167. * Dealing with Old Files::
  168. * Overwrite Old Files::
  169. * Keep Old Files::
  170. * Keep Newer Files::
  171. * Unlink First::
  172. * Recursive Unlink::
  173. * Data Modification Times::
  174. * Setting Access Permissions::
  175. * Writing to Standard Output::
  176. * remove files::
  177. Coping with Scarce Resources
  178. * Starting File::
  179. * Same Order::
  180. Performing Backups and Restoring Files
  181. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  182. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  183. * Backup Levels:: Levels of Backups
  184. * Backup Parameters:: Setting Parameters for Backups and Restoration
  185. * Scripted Backups:: Using the Backup Scripts
  186. * Scripted Restoration:: Using the Restore Script
  187. Setting Parameters for Backups and Restoration
  188. * General-Purpose Variables::
  189. * Magnetic Tape Control::
  190. * User Hooks::
  191. * backup-specs example:: An Example Text of @file{Backup-specs}
  192. Choosing Files and Names for @command{tar}
  193. * file:: Choosing the Archive's Name
  194. * Selecting Archive Members::
  195. * files:: Reading Names from a File
  196. * exclude:: Excluding Some Files
  197. * Wildcards:: Wildcards Patterns and Matching
  198. * after:: Operating Only on New Files
  199. * recurse:: Descending into Directories
  200. * one:: Crossing File System Boundaries
  201. Reading Names from a File
  202. * nul::
  203. Excluding Some Files
  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. * Free Software Needs Free Documentation::
  260. * GNU Free Documentation License:: License for copying this manual
  261. @end detailmenu
  262. @end menu
  263. @node Introduction
  264. @chapter Introduction
  265. @GNUTAR{} creates
  266. and manipulates @dfn{archives} which are actually collections of
  267. many other files; the program provides users with an organized and
  268. systematic method for controlling a large amount of data.
  269. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  270. archives need not (and these days, typically do not) reside on tapes.
  271. @menu
  272. * Book Contents:: What this Book Contains
  273. * Definitions:: Some Definitions
  274. * What tar Does:: What @command{tar} Does
  275. * Naming tar Archives:: How @command{tar} Archives are Named
  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 Authors
  418. @section @GNUTAR{} Authors
  419. @GNUTAR{} was originally written by John Gilmore,
  420. and modified by many people. The @acronym{GNU} enhancements were
  421. written by Jay Fenlason, then Joy Kendall, and the whole package has
  422. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  423. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  424. numerous and kind users.
  425. We wish to stress that @command{tar} is a collective work, and owes much to
  426. all those people who reported problems, offered solutions and other
  427. insights, or shared their thoughts and suggestions. An impressive, yet
  428. partial list of those contributors can be found in the @file{THANKS}
  429. file from the @GNUTAR{} distribution.
  430. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  431. sure i want to spell out the history in this detail, at least not for
  432. the printed book. i'm just not sure it needs to be said this way.
  433. i'll think about it.}
  434. @FIXME{History is more important, and surely more interesting, than
  435. actual names. Quoting names without history would be meaningless. FP}
  436. Jay Fenlason put together a draft of a @GNUTAR{}
  437. manual, borrowing notes from the original man page from John Gilmore.
  438. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  439. Gorin worked on a tutorial and manual for @GNUTAR{}.
  440. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  441. taking information from all these sources and merging them. Melissa
  442. Weisshaus finally edited and redesigned the book to create version
  443. 1.12. @FIXME{update version number as necessary; i'm being
  444. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  445. maybe melissa? maybe julie sussman?] needs to properly index the
  446. thing.}
  447. For version 1.12, Daniel Hagerty contributed a great deal of technical
  448. consulting. In particular, he is the primary author of @ref{Backups}.
  449. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  450. (see @url{http://savannah.gnu.org/projects/tar}), and
  451. active development and maintenance work has started
  452. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  453. Poznyakoff and Jeff Bailey.
  454. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  455. @node Reports
  456. @section Reporting bugs or suggestions
  457. @cindex bug reports
  458. @cindex reporting bugs
  459. If you find problems or have suggestions about this program or manual,
  460. please report them to @file{bug-tar@@gnu.org}.
  461. When reporting a bug, please be sure to include as much detail as
  462. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  463. like to make this node as detailed as 'Bug reporting' node in Emacs
  464. manual}.
  465. @node Tutorial
  466. @chapter Tutorial Introduction to @command{tar}
  467. This chapter guides you through some basic examples of three @command{tar}
  468. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  469. you already know how to use some other version of @command{tar}, then you
  470. may not need to read this chapter. This chapter omits most complicated
  471. details about how @command{tar} works.
  472. @menu
  473. * assumptions::
  474. * stylistic conventions::
  475. * basic tar options:: Basic @command{tar} Operations and Options
  476. * frequent operations::
  477. * Two Frequent Options::
  478. * create:: How to Create Archives
  479. * list:: How to List Archives
  480. * extract:: How to Extract Members from an Archive
  481. * going further::
  482. @end menu
  483. @node assumptions
  484. @section Assumptions this Tutorial Makes
  485. This chapter is paced to allow beginners to learn about @command{tar}
  486. slowly. At the same time, we will try to cover all the basic aspects of
  487. these three operations. In order to accomplish both of these tasks, we
  488. have made certain assumptions about your knowledge before reading this
  489. manual, and the hardware you will be using:
  490. @itemize @bullet
  491. @item
  492. Before you start to work through this tutorial, you should understand
  493. what the terms ``archive'' and ``archive member'' mean
  494. (@pxref{Definitions}). In addition, you should understand something
  495. about how Unix-type operating systems work, and you should know how to
  496. use some basic utilities. For example, you should know how to create,
  497. list, copy, rename, edit, and delete files and directories; how to
  498. change between directories; and how to figure out where you are in the
  499. file system. You should have some basic understanding of directory
  500. structure and how files are named according to which directory they are
  501. in. You should understand concepts such as standard output and standard
  502. input, what various definitions of the term ``argument'' mean, and the
  503. differences between relative and absolute path names. @FIXME{and what
  504. else?}
  505. @item
  506. This manual assumes that you are working from your own home directory
  507. (unless we state otherwise). In this tutorial, you will create a
  508. directory to practice @command{tar} commands in. When we show path names,
  509. we will assume that those paths are relative to your home directory.
  510. For example, my home directory path is @file{/home/fsf/melissa}. All of
  511. my examples are in a subdirectory of the directory named by that path
  512. name; the subdirectory is called @file{practice}.
  513. @item
  514. In general, we show examples of archives which exist on (or can be
  515. written to, or worked with from) a directory on a hard disk. In most
  516. cases, you could write those archives to, or work with them on any other
  517. device, such as a tape drive. However, some of the later examples in
  518. the tutorial and next chapter will not work on tape drives.
  519. Additionally, working with tapes is much more complicated than working
  520. with hard disks. For these reasons, the tutorial does not cover working
  521. with tape drives. @xref{Media}, for complete information on using
  522. @command{tar} archives with tape drives.
  523. @FIXME{this is a cop out. need to add some simple tape drive info.}
  524. @end itemize
  525. @node stylistic conventions
  526. @section Stylistic Conventions
  527. In the examples, @samp{$} represents a typical shell prompt. It
  528. precedes lines you should type; to make this more clear, those lines are
  529. shown in @kbd{this font}, as opposed to lines which represent the
  530. computer's response; those lines are shown in @code{this font}, or
  531. sometimes @samp{like this}.
  532. @c When we have lines which are too long to be
  533. @c displayed in any other way, we will show them like this:
  534. @node basic tar options
  535. @section Basic @command{tar} Operations and Options
  536. @command{tar} can take a wide variety of arguments which specify and define
  537. the actions it will have on the particular set of files or the archive.
  538. The main types of arguments to @command{tar} fall into one of two classes:
  539. operations, and options.
  540. Some arguments fall into a class called @dfn{operations}; exactly one of
  541. these is both allowed and required for any instance of using @command{tar};
  542. you may @emph{not} specify more than one. People sometimes speak of
  543. @dfn{operating modes}. You are in a particular operating mode when you
  544. have specified the operation which specifies it; there are eight
  545. operations in total, and thus there are eight operating modes.
  546. The other arguments fall into the class known as @dfn{options}. You are
  547. not required to specify any options, and you are allowed to specify more
  548. than one at a time (depending on the way you are using @command{tar} at
  549. that time). Some options are used so frequently, and are so useful for
  550. helping you type commands more carefully that they are effectively
  551. ``required''. We will discuss them in this chapter.
  552. You can write most of the @command{tar} operations and options in any
  553. of three forms: long (mnemonic) form, short form, and old style. Some
  554. of the operations and options have no short or ``old'' forms; however,
  555. the operations and options which we will cover in this tutorial have
  556. corresponding abbreviations. @FIXME{make sure this is still the case,
  557. at the end}We will indicate those abbreviations appropriately to get
  558. you used to seeing them. (Note that the ``old style'' option forms
  559. exist in @GNUTAR{} for compatibility with Unix
  560. @command{tar}. In this book we present a full discussion of this way
  561. of writing options and operations (@pxref{Old Options}), and we discuss
  562. the other two styles of writing options (@xref{Mnemonic Options}, and
  563. @pxref{Short Options}).
  564. In the examples and in the text of this tutorial, we usually use the
  565. long forms of operations and options; but the ``short'' forms produce
  566. the same result and can make typing long @command{tar} commands easier.
  567. For example, instead of typing
  568. @smallexample
  569. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  570. @end smallexample
  571. @noindent
  572. you can type
  573. @smallexample
  574. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  575. @end smallexample
  576. @noindent
  577. or even
  578. @smallexample
  579. @kbd{tar -cvf afiles.tar apple angst aspic}
  580. @end smallexample
  581. @noindent
  582. For more information on option syntax, see @ref{Advanced tar}. In
  583. discussions in the text, when we name an option by its long form, we
  584. also give the corresponding short option in parentheses.
  585. The term, ``option'', can be confusing at times, since ``operations''
  586. are often lumped in with the actual, @emph{optional} ``options'' in certain
  587. general class statements. For example, we just talked about ``short and
  588. long forms of options and operations''. However, experienced @command{tar}
  589. users often refer to these by shorthand terms such as, ``short and long
  590. options''. This term assumes that the ``operations'' are included, also.
  591. Context will help you determine which definition of ``options'' to use.
  592. Similarly, the term ``command'' can be confusing, as it is often used in
  593. two different ways. People sometimes refer to @command{tar} ``commands''.
  594. A @command{tar} @dfn{command} is the entire command line of user input
  595. which tells @command{tar} what to do --- including the operation, options,
  596. and any arguments (file names, pipes, other commands, etc). However,
  597. you will also sometimes hear the term ``the @command{tar} command''. When
  598. the word ``command'' is used specifically like this, a person is usually
  599. referring to the @command{tar} @emph{operation}, not the whole line.
  600. Again, use context to figure out which of the meanings the speaker
  601. intends.
  602. @node frequent operations
  603. @section The Three Most Frequently Used Operations
  604. Here are the three most frequently used operations (both short and long
  605. forms), as well as a brief description of their meanings. The rest of
  606. this chapter will cover how to use these operations in detail. We will
  607. present the rest of the operations in the next chapter.
  608. @table @option
  609. @item --create
  610. @itemx -c
  611. Create a new @command{tar} archive.
  612. @item --list
  613. @itemx -t
  614. List the contents of an archive.
  615. @item --extract
  616. @itemx -x
  617. Extract one or more members from an archive.
  618. @end table
  619. @node Two Frequent Options
  620. @section Two Frequently Used Options
  621. To understand how to run @command{tar} in the three operating modes listed
  622. previously, you also need to understand how to use two of the options to
  623. @command{tar}: @option{--file} (which takes an archive file as an argument)
  624. and @option{--verbose}. (You are usually not @emph{required} to specify
  625. either of these options when you run @command{tar}, but they can be very
  626. useful in making things more clear and helping you avoid errors.)
  627. @menu
  628. * file tutorial::
  629. * verbose tutorial::
  630. * help tutorial::
  631. @end menu
  632. @node file tutorial
  633. @unnumberedsubsec The @option{--file} Option
  634. @table @option
  635. @opindex file, tutorial
  636. @item --file=@var{archive-name}
  637. @itemx -f @var{archive-name}
  638. Specify the name of an archive file.
  639. @end table
  640. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  641. use @command{tar}; this option determines the name of the archive file
  642. that @command{tar} will work on.
  643. @vrindex TAPE
  644. If you don't specify this argument, then @command{tar} will examine
  645. the environment variable @env{TAPE}. If it is set, its value will be
  646. used as the archive name. Otherwise, @command{tar} will use the
  647. default archive, determined at the compile time. Usually it is
  648. standard output or some physical tape drive attached to your machine
  649. (you can verify what the default is by running @kbd{tar
  650. --show-defaults}, @pxref{defaults}). If there is no tape drive
  651. attached, or the default is not meaningful, then @command{tar} will
  652. print an error message. The error message might look roughly like one
  653. of the following:
  654. @smallexample
  655. tar: can't open /dev/rmt8 : No such device or address
  656. tar: can't open /dev/rsmt0 : I/O error
  657. @end smallexample
  658. @noindent
  659. To avoid confusion, we recommend that you always specify an archive file
  660. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  661. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  662. @ref{file}.
  663. @node verbose tutorial
  664. @unnumberedsubsec The @option{--verbose} Option
  665. @table @option
  666. @opindex verbose, introduced
  667. @item --verbose
  668. @itemx -v
  669. Show the files being worked on as @command{tar} is running.
  670. @end table
  671. @option{--verbose} (@option{-v}) shows details about the results of running
  672. @command{tar}. This can be especially useful when the results might not be
  673. obvious. For example, if you want to see the progress of @command{tar} as
  674. it writes files into the archive, you can use the @option{--verbose}
  675. option. In the beginning, you may find it useful to use
  676. @option{--verbose} at all times; when you are more accustomed to
  677. @command{tar}, you will likely want to use it at certain times but not at
  678. others. We will use @option{--verbose} at times to help make something
  679. clear, and we will give many examples both using and not using
  680. @option{--verbose} to show the differences.
  681. Sometimes, a single instance of @option{--verbose} on the command line
  682. will show a full, @samp{ls} style listing of an archive or files,
  683. giving sizes, owners, and similar information. @FIXME{Describe the
  684. exact output format, e.g., how hard links are displayed.}
  685. Other times, @option{--verbose} will only show files or members that the particular
  686. operation is operating on at the time. In the latter case, you can
  687. use @option{--verbose} twice in a command to get a listing such as that
  688. in the former case. For example, instead of saying
  689. @smallexample
  690. @kbd{tar -cvf afiles.tar apple angst aspic}
  691. @end smallexample
  692. @noindent
  693. above, you might say
  694. @smallexample
  695. @kbd{tar -cvvf afiles.tar apple angst aspic}
  696. @end smallexample
  697. @noindent
  698. This works equally well using short or long forms of options. Using
  699. long forms, you would simply write out the mnemonic form of the option
  700. twice, like this:
  701. @smallexample
  702. $ @kbd{tar --create --verbose --verbose @dots{}}
  703. @end smallexample
  704. @noindent
  705. Note that you must double the hyphens properly each time.
  706. Later in the tutorial, we will give examples using @w{@option{--verbose
  707. --verbose}}.
  708. @node help tutorial
  709. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  710. @table @option
  711. @opindex help
  712. @item --help
  713. The @option{--help} option to @command{tar} prints out a very brief list of
  714. all operations and option available for the current version of
  715. @command{tar} available on your system.
  716. @end table
  717. @node create
  718. @section How to Create Archives
  719. @UNREVISED
  720. @cindex Creation of the archive
  721. @cindex Archive, creation of
  722. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  723. you use to create a @command{tar} archive. We will explain
  724. @option{--create} first because, in order to learn about the other
  725. operations, you will find it useful to have an archive available to
  726. practice on.
  727. To make this easier, in this section you will first create a directory
  728. containing three files. Then, we will show you how to create an
  729. @emph{archive} (inside the new directory). Both the directory, and
  730. the archive are specifically for you to practice on. The rest of this
  731. chapter and the next chapter will show many examples using this
  732. directory and the files you will create: some of those files may be
  733. other directories and other archives.
  734. The three files you will archive in this example are called
  735. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  736. @file{collection.tar}.
  737. This section will proceed slowly, detailing how to use @option{--create}
  738. in @code{verbose} mode, and showing examples using both short and long
  739. forms. In the rest of the tutorial, and in the examples in the next
  740. chapter, we will proceed at a slightly quicker pace. This section
  741. moves more slowly to allow beginning users to understand how
  742. @command{tar} works.
  743. @menu
  744. * prepare for examples::
  745. * Creating the archive::
  746. * create verbose::
  747. * short create::
  748. * create dir::
  749. @end menu
  750. @node prepare for examples
  751. @subsection Preparing a Practice Directory for Examples
  752. To follow along with this and future examples, create a new directory
  753. called @file{practice} containing files called @file{blues}, @file{folk}
  754. and @file{jazz}. The files can contain any information you like:
  755. ideally, they should contain information which relates to their names,
  756. and be of different lengths. Our examples assume that @file{practice}
  757. is a subdirectory of your home directory.
  758. Now @command{cd} to the directory named @file{practice}; @file{practice}
  759. is now your @dfn{working directory}. (@emph{Please note}: Although
  760. the full path name of this directory is
  761. @file{/@var{homedir}/practice}, in our examples we will refer to
  762. this directory as @file{practice}; the @var{homedir} is presumed.
  763. In general, you should check that the files to be archived exist where
  764. you think they do (in the working directory) by running @command{ls}.
  765. Because you just created the directory and the files and have changed to
  766. that directory, you probably don't need to do that this time.
  767. It is very important to make sure there isn't already a file in the
  768. working directory with the archive name you intend to use (in this case,
  769. @samp{collection.tar}), or that you don't care about its contents.
  770. Whenever you use @samp{create}, @command{tar} will erase the current
  771. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  772. will not tell you if you are about to overwrite an archive unless you
  773. specify an option which does this (@pxref{backup}, for the
  774. information on how to do so). To add files to an existing archive,
  775. you need to use a different option, such as @option{--append} (@option{-r}); see
  776. @ref{append} for information on how to do this.
  777. @node Creating the archive
  778. @subsection Creating the Archive
  779. @opindex create, introduced
  780. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  781. archive named @file{collection.tar}, use the following command:
  782. @smallexample
  783. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  784. @end smallexample
  785. The order of the arguments is not very important, @emph{when using long
  786. option forms}. You could also say:
  787. @smallexample
  788. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  789. @end smallexample
  790. @noindent
  791. However, you can see that this order is harder to understand; this is
  792. why we will list the arguments in the order that makes the commands
  793. easiest to understand (and we encourage you to do the same when you use
  794. @command{tar}, to avoid errors).
  795. Note that the part of the command which says,
  796. @w{@option{--file=collection.tar}} is considered to be @emph{one} argument.
  797. If you substituted any other string of characters for
  798. @kbd{collection.tar}, then that string would become the name of the
  799. archive file you create.
  800. The order of the options becomes more important when you begin to use
  801. short forms. With short forms, if you type commands in the wrong order
  802. (even if you type them correctly in all other ways), you may end up with
  803. results you don't expect. For this reason, it is a good idea to get
  804. into the habit of typing options in the order that makes inherent sense.
  805. @xref{short create}, for more information on this.
  806. In this example, you type the command as shown above: @option{--create}
  807. is the operation which creates the new archive
  808. (@file{collection.tar}), and @option{--file} is the option which lets
  809. you give it the name you chose. The files, @file{blues}, @file{folk},
  810. and @file{jazz}, are now members of the archive, @file{collection.tar}
  811. (they are @dfn{file name arguments} to the @option{--create} operation).
  812. @FIXME{xref here to the discussion of file name args?}Now that they are
  813. in the archive, they are called @emph{archive members}, not files.
  814. (@pxref{Definitions,members}).
  815. When you create an archive, you @emph{must} specify which files you
  816. want placed in the archive. If you do not specify any archive
  817. members, @GNUTAR{} will complain.
  818. If you now list the contents of the working directory (@command{ls}), you will
  819. find the archive file listed as well as the files you saw previously:
  820. @smallexample
  821. blues folk jazz collection.tar
  822. @end smallexample
  823. @noindent
  824. Creating the archive @samp{collection.tar} did not destroy the copies of
  825. the files in the directory.
  826. Keep in mind that if you don't indicate an operation, @command{tar} will not
  827. run and will prompt you for one. If you don't name any files, @command{tar}
  828. will complain. You must have write access to the working directory,
  829. or else you will not be able to create an archive in that directory.
  830. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  831. an existing archive; it will delete the archive and write a new one.
  832. Use @option{--append} (@option{-r}) instead. @xref{append}.
  833. @node create verbose
  834. @subsection Running @option{--create} with @option{--verbose}
  835. @opindex create, using with @option{--verbose}
  836. @opindex verbose, using with @option{--create}
  837. If you include the @option{--verbose} (@option{-v}) option on the command line,
  838. @command{tar} will list the files it is acting on as it is working. In
  839. verbose mode, the @code{create} example above would appear as:
  840. @smallexample
  841. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  842. blues
  843. folk
  844. jazz
  845. @end smallexample
  846. This example is just like the example we showed which did not use
  847. @option{--verbose}, except that @command{tar} generated the remaining lines
  848. @iftex
  849. (note the different font styles).
  850. @end iftex
  851. @ifinfo
  852. .
  853. @end ifinfo
  854. In the rest of the examples in this chapter, we will frequently use
  855. @code{verbose} mode so we can show actions or @command{tar} responses that
  856. you would otherwise not see, and which are important for you to
  857. understand.
  858. @node short create
  859. @subsection Short Forms with @samp{create}
  860. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  861. basic uses of @command{tar}, and you will use it countless times.
  862. Eventually, you will probably want to use abbreviated (or ``short'')
  863. forms of options. A full discussion of the three different forms that
  864. options can take appears in @ref{Styles}; for now, here is what the
  865. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  866. using short option forms:
  867. @smallexample
  868. $ @kbd{tar -cvf collection.tar blues folk jazz}
  869. blues
  870. folk
  871. jazz
  872. @end smallexample
  873. @noindent
  874. As you can see, the system responds the same no matter whether you use
  875. long or short option forms.
  876. @FIXME{i don't like how this is worded:} One difference between using
  877. short and long option forms is that, although the exact placement of
  878. arguments following options is no more specific when using short forms,
  879. it is easier to become confused and make a mistake when using short
  880. forms. For example, suppose you attempted the above example in the
  881. following way:
  882. @smallexample
  883. $ @kbd{tar -cfv collection.tar blues folk jazz}
  884. @end smallexample
  885. @noindent
  886. In this case, @command{tar} will make an archive file called @file{v},
  887. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  888. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  889. is thus taken to be the chosen archive file name. @command{tar} will try
  890. to add a file called @file{collection.tar} to the @file{v} archive file;
  891. if the file @file{collection.tar} did not already exist, @command{tar} will
  892. report an error indicating that this file does not exist. If the file
  893. @file{collection.tar} does already exist (e.g., from a previous command
  894. you may have run), then @command{tar} will add this file to the archive.
  895. Because the @option{-v} option did not get registered, @command{tar} will not
  896. run under @samp{verbose} mode, and will not report its progress.
  897. The end result is that you may be quite confused about what happened,
  898. and possibly overwrite a file. To illustrate this further, we will show
  899. you how an example we showed previously would look using short forms.
  900. This example,
  901. @smallexample
  902. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  903. @end smallexample
  904. @noindent
  905. is confusing as it is. When shown using short forms, however, it
  906. becomes much more so:
  907. @smallexample
  908. $ @kbd{tar blues -c folk -f collection.tar jazz}
  909. @end smallexample
  910. @noindent
  911. It would be very easy to put the wrong string of characters
  912. immediately following the @option{-f}, but doing that could sacrifice
  913. valuable data.
  914. For this reason, we recommend that you pay very careful attention to
  915. the order of options and placement of file and archive names,
  916. especially when using short option forms. Not having the option name
  917. written out mnemonically can affect how well you remember which option
  918. does what, and therefore where different names have to be placed.
  919. @node create dir
  920. @subsection Archiving Directories
  921. @cindex Archiving Directories
  922. @cindex Directories, Archiving
  923. You can archive a directory by specifying its directory name as a
  924. file name argument to @command{tar}. The files in the directory will be
  925. archived relative to the working directory, and the directory will be
  926. re-created along with its contents when the archive is extracted.
  927. To archive a directory, first move to its superior directory. If you
  928. have followed the previous instructions in this tutorial, you should
  929. type:
  930. @smallexample
  931. $ @kbd{cd ..}
  932. $
  933. @end smallexample
  934. @noindent
  935. This will put you into the directory which contains @file{practice},
  936. i.e., your home directory. Once in the superior directory, you can
  937. specify the subdirectory, @file{practice}, as a file name argument. To
  938. store @file{practice} in the new archive file @file{music.tar}, type:
  939. @smallexample
  940. $ @kbd{tar --create --verbose --file=music.tar practice}
  941. @end smallexample
  942. @noindent
  943. @command{tar} should output:
  944. @smallexample
  945. practice/
  946. practice/blues
  947. practice/folk
  948. practice/jazz
  949. practice/collection.tar
  950. @end smallexample
  951. Note that the archive thus created is not in the subdirectory
  952. @file{practice}, but rather in the current working directory---the
  953. directory from which @command{tar} was invoked. Before trying to archive a
  954. directory from its superior directory, you should make sure you have
  955. write access to the superior directory itself, not only the directory
  956. you are trying archive with @command{tar}. For example, you will probably
  957. not be able to store your home directory in an archive by invoking
  958. @command{tar} from the root directory; @xref{absolute}. (Note
  959. also that @file{collection.tar}, the original archive file, has itself
  960. been archived. @command{tar} will accept any file as a file to be
  961. archived, regardless of its content. When @file{music.tar} is
  962. extracted, the archive file @file{collection.tar} will be re-written
  963. into the file system).
  964. If you give @command{tar} a command such as
  965. @smallexample
  966. $ @kbd{tar --create --file=foo.tar .}
  967. @end smallexample
  968. @noindent
  969. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  970. dumped}. This happens because @command{tar} creates the archive
  971. @file{foo.tar} in the current directory before putting any files into
  972. it. Then, when @command{tar} attempts to add all the files in the
  973. directory @file{.} to the archive, it notices that the file
  974. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  975. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  976. will continue in this case, and create the archive
  977. normally, except for the exclusion of that one file. (@emph{Please
  978. note:} Other versions of @command{tar} are not so clever; they will
  979. enter an infinite loop when this happens, so you should not depend on
  980. this behavior unless you are certain you are running @GNUTAR{}.)
  981. @FIXME{bob doesn't like this sentence, since he does
  982. it all the time, and we've been doing it in the editing passes for
  983. this manual: In general, make sure that the archive is not inside a
  984. directory being dumped.}
  985. @node list
  986. @section How to List Archives
  987. @opindex list
  988. Frequently, you will find yourself wanting to determine exactly what a
  989. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  990. to get the member names as they currently appear in the archive, as well
  991. as various attributes of the files at the time they were archived. For
  992. example, you can examine the archive @file{collection.tar} that you
  993. created in the last section with the command,
  994. @smallexample
  995. $ @kbd{tar --list --file=collection.tar}
  996. @end smallexample
  997. @noindent
  998. The output of @command{tar} would then be:
  999. @smallexample
  1000. blues
  1001. folk
  1002. jazz
  1003. @end smallexample
  1004. @FIXME{we hope this will change. if it doesn't, need to show the
  1005. creation of bfiles somewhere above!!! : }
  1006. @noindent
  1007. The archive @file{bfiles.tar} would list as follows:
  1008. @smallexample
  1009. ./birds
  1010. baboon
  1011. ./box
  1012. @end smallexample
  1013. @noindent
  1014. Be sure to use a @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option just as with @option{--create} (@option{-c})
  1015. to specify the name of the archive.
  1016. @opindex list, using with @option{--verbose}
  1017. @opindex verbose, using with @option{--list}
  1018. If you use the @option{--verbose} (@option{-v}) option with @option{--list}, then
  1019. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1020. showing owner, file size, and so forth.
  1021. If you had used @option{--verbose} (@option{-v}) mode, the example above would look
  1022. like:
  1023. @smallexample
  1024. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1025. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1026. @end smallexample
  1027. @cindex listing member and file names
  1028. @anchor{listing member and file names}
  1029. It is important to notice that the output of @kbd{tar --list
  1030. --verbose} does not necessarily match that produced by @kbd{tar
  1031. --create --verbose} while creating the archive. It is because
  1032. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1033. prefixes from file names before storing them in the archive
  1034. (@xref{absolute}, for more information). In other
  1035. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1036. an archive and @dfn{member names} when listing it. Consider this
  1037. example:
  1038. @smallexample
  1039. @group
  1040. $ @kbd{tar cfv archive /etc/mail}
  1041. tar: Removing leading `/' from member names
  1042. /etc/mail/
  1043. /etc/mail/sendmail.cf
  1044. /etc/mail/aliases
  1045. $ @kbd{tar tf archive}
  1046. etc/mail/
  1047. etc/mail/sendmail.cf
  1048. etc/mail/aliases
  1049. @end group
  1050. @end smallexample
  1051. @opindex show-stored-names
  1052. This default behavior can sometimes be inconvenient. You can force
  1053. @GNUTAR{} show member names when creating archive by supplying
  1054. @option{--show-stored-names} option.
  1055. @table @option
  1056. @item --show-stored-names
  1057. Print member (as opposed to @emph{file}) names when creating the archive.
  1058. @end table
  1059. @cindex File name arguments, using @option{--list} with
  1060. @opindex list, using with file name arguments
  1061. You can specify one or more individual member names as arguments when
  1062. using @samp{list}. In this case, @command{tar} will only list the
  1063. names of members you identify. For example, @w{@kbd{tar --list
  1064. --file=afiles.tar apple}} would only print @file{apple}.
  1065. Because @command{tar} preserves paths, file names must be specified as
  1066. they appear in the archive (ie., relative to the directory from which
  1067. the archive was created). Therefore, it is essential when specifying
  1068. member names to @command{tar} that you give the exact member names.
  1069. For example, @w{@kbd{tar --list --file=bfiles.tar birds}} would produce an
  1070. error message something like @samp{tar: birds: Not found in archive},
  1071. because there is no member named @file{birds}, only one named
  1072. @file{./birds}. While the names @file{birds} and @file{./birds} name
  1073. the same file, @emph{member} names by default are compared verbatim.
  1074. However, @w{@kbd{tar --list --file=bfiles.tar baboon}} would respond
  1075. with @file{baboon}, because this exact member name is in the archive file
  1076. @file{bfiles.tar}. If you are not sure of the exact file name,
  1077. use @dfn{globbing patterns}, for example:
  1078. @smallexample
  1079. $ @kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
  1080. @end smallexample
  1081. @noindent
  1082. will list all members whose name contains @samp{b}. @xref{Wildcards},
  1083. for a detailed discussion of globbing patterns and related
  1084. @command{tar} command line options.
  1085. @menu
  1086. * list dir::
  1087. @end menu
  1088. @node list dir
  1089. @unnumberedsubsec Listing the Contents of a Stored Directory
  1090. To get information about the contents of an archived directory,
  1091. use the directory name as a file name argument in conjunction with
  1092. @option{--list} (@option{-t}). To find out file attributes, include the
  1093. @option{--verbose} (@option{-v}) option.
  1094. For example, to find out about files in the directory @file{practice}, in
  1095. the archive file @file{music.tar}, type:
  1096. @smallexample
  1097. $ @kbd{tar --list --verbose --file=music.tar practice}
  1098. @end smallexample
  1099. @command{tar} responds:
  1100. @smallexample
  1101. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1102. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1103. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1104. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1105. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1106. @end smallexample
  1107. When you use a directory name as a file name argument, @command{tar} acts on
  1108. all the files (including sub-directories) in that directory.
  1109. @node extract
  1110. @section How to Extract Members from an Archive
  1111. @UNREVISED
  1112. @cindex Extraction
  1113. @cindex Retrieving files from an archive
  1114. @cindex Resurrecting files from an archive
  1115. @opindex extract
  1116. Creating an archive is only half the job---there is no point in storing
  1117. files in an archive if you can't retrieve them. The act of retrieving
  1118. members from an archive so they can be used and manipulated as
  1119. unarchived files again is called @dfn{extraction}. To extract files
  1120. from an archive, use the @option{--extract} (@option{--get} or
  1121. @option{-x}) operation. As with @option{--create}, specify the name
  1122. of the archive with @option{--file} (@option{-f}) option. Extracting
  1123. an archive does not modify the archive in any way; you can extract it
  1124. multiple times if you want or need to.
  1125. Using @option{--extract}, you can extract an entire archive, or specific
  1126. files. The files can be directories containing other files, or not. As
  1127. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1128. long form of the operation without affecting the performance.
  1129. @menu
  1130. * extracting archives::
  1131. * extracting files::
  1132. * extract dir::
  1133. * extracting untrusted archives::
  1134. * failing commands::
  1135. @end menu
  1136. @node extracting archives
  1137. @subsection Extracting an Entire Archive
  1138. To extract an entire archive, specify the archive file name only, with
  1139. no individual file names as arguments. For example,
  1140. @smallexample
  1141. $ @kbd{tar -xvf collection.tar}
  1142. @end smallexample
  1143. @noindent
  1144. produces this:
  1145. @smallexample
  1146. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1147. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1148. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1149. @end smallexample
  1150. @node extracting files
  1151. @subsection Extracting Specific Files
  1152. To extract specific archive members, give their exact member names as
  1153. arguments, as printed by @option{--list} (@option{-t}). If you had
  1154. mistakenly deleted one of the files you had placed in the archive
  1155. @file{collection.tar} earlier (say, @file{blues}), you can extract it
  1156. from the archive without changing the archive's structure. Its
  1157. contents will be identical to the original file @file{blues} that you
  1158. deleted.
  1159. First, make sure you are in the @file{practice} directory, and list the
  1160. files in the directory. Now, delete the file, @samp{blues}, and list
  1161. the files in the directory again.
  1162. You can now extract the member @file{blues} from the archive file
  1163. @file{collection.tar} like this:
  1164. @smallexample
  1165. $ @kbd{tar --extract --file=collection.tar blues}
  1166. @end smallexample
  1167. @noindent
  1168. If you list the files in the directory again, you will see that the file
  1169. @file{blues} has been restored, with its original permissions, data
  1170. modification times, and owner.@FIXME{This is only accidentally true, but not in
  1171. general. In most cases, one has to be root for restoring the owner, and
  1172. use a special option for restoring permissions. Here, it just happens
  1173. that the restoring user is also the owner of the archived members, and
  1174. that the current @code{umask} is compatible with original permissions.}
  1175. (These parameters will be identical to those which
  1176. the file had when you originally placed it in the archive; any changes
  1177. you may have made before deleting the file from the file system,
  1178. however, will @emph{not} have been made to the archive member.) The
  1179. archive file, @samp{collection.tar}, is the same as it was before you
  1180. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1181. @option{--list} (@option{-t}).
  1182. Remember that as with other operations, specifying the exact member
  1183. name is important. @w{@kbd{tar --extract --file=bfiles.tar birds}}
  1184. will fail, because there is no member named @file{birds}. To extract
  1185. the member named @file{./birds}, you must specify @w{@kbd{tar
  1186. --extract --file=bfiles.tar ./birds}}. If you don't remember the
  1187. exact member names, use @option{--list} (@option{-t}) option
  1188. (@pxref{list}). You can also extract those members that match a
  1189. specific @dfn{globbing pattern}. For example, to extract from
  1190. @file{bfiles.tar} all files that begin with @samp{b}, no matter their
  1191. directory prefix, you could type:
  1192. @smallexample
  1193. $ @kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
  1194. @end smallexample
  1195. @noindent
  1196. Here, @option{--wildcards} instructs @command{tar} to treat
  1197. command line arguments as globbing patterns and @option{--no-anchored}
  1198. informs it that the patterns apply to member names after any @samp{/}
  1199. delimiter. The use of globbing patterns is discussed in detail in
  1200. @xref{Wildcards}.
  1201. You can extract a file to standard output by combining the above options
  1202. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1203. Output}).
  1204. If you give the @option{--verbose} option, then @option{--extract}
  1205. will print the names of the archive members as it extracts them.
  1206. @node extract dir
  1207. @subsection Extracting Files that are Directories
  1208. Extracting directories which are members of an archive is similar to
  1209. extracting other files. The main difference to be aware of is that if
  1210. the extracted directory has the same name as any directory already in
  1211. the working directory, then files in the extracted directory will be
  1212. placed into the directory of the same name. Likewise, if there are
  1213. files in the pre-existing directory with the same names as the members
  1214. which you extract, the files from the extracted archive will replace
  1215. the files already in the working directory (and possible
  1216. subdirectories). This will happen regardless of whether or not the
  1217. files in the working directory were more recent than those extracted
  1218. (there exist, however, special options that alter this behavior
  1219. @pxref{Writing}).
  1220. However, if a file was stored with a directory name as part of its file
  1221. name, and that directory does not exist under the working directory when
  1222. the file is extracted, @command{tar} will create the directory.
  1223. We can demonstrate how to use @option{--extract} to extract a directory
  1224. file with an example. Change to the @file{practice} directory if you
  1225. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1226. go back to the parent directory and extract the archive
  1227. @file{music.tar}. You may either extract the entire archive, or you may
  1228. extract only the files you just deleted. To extract the entire archive,
  1229. don't give any file names as arguments after the archive name
  1230. @file{music.tar}. To extract only the files you deleted, use the
  1231. following command:
  1232. @smallexample
  1233. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1234. practice/folk
  1235. practice/jazz
  1236. @end smallexample
  1237. @noindent
  1238. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1239. would have displayed more detail about the extracted files, as shown
  1240. in the example below:
  1241. @smallexample
  1242. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1243. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1244. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1245. @end smallexample
  1246. @noindent
  1247. Because you created the directory with @file{practice} as part of the
  1248. file names of each of the files by archiving the @file{practice}
  1249. directory as @file{practice}, you must give @file{practice} as part
  1250. of the file names when you extract those files from the archive.
  1251. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1252. will be.}
  1253. @node extracting untrusted archives
  1254. @subsection Extracting Archives from Untrusted Sources
  1255. Extracting files from archives can overwrite files that already exist.
  1256. If you receive an archive from an untrusted source, you should make a
  1257. new directory and extract into that directory, so that you don't have
  1258. to worry about the extraction overwriting one of your existing files.
  1259. For example, if @file{untrusted.tar} came from somewhere else on the
  1260. Internet, and you don't necessarily trust its contents, you can
  1261. extract it as follows:
  1262. @smallexample
  1263. $ @kbd{mkdir newdir}
  1264. $ @kbd{cd newdir}
  1265. $ @kbd{tar -xvf ../untrusted.tar}
  1266. @end smallexample
  1267. It is also a good practice to examine contents of the archive
  1268. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1269. with @option{--verbose} (@option{-v}).
  1270. @node failing commands
  1271. @subsection Commands That Will Fail
  1272. Here are some sample commands you might try which will not work, and why
  1273. they won't work.
  1274. If you try to use this command,
  1275. @smallexample
  1276. $ @kbd{tar -xvf music.tar folk jazz}
  1277. @end smallexample
  1278. @noindent
  1279. you will get the following response:
  1280. @smallexample
  1281. tar: folk: Not found in archive
  1282. tar: jazz: Not found in archive
  1283. $
  1284. @end smallexample
  1285. @noindent
  1286. This is because these files were not originally @emph{in} the parent
  1287. directory @file{..}, where the archive is located; they were in the
  1288. @file{practice} directory, and their file names reflect this:
  1289. @smallexample
  1290. $ @kbd{tar -tvf music.tar}
  1291. practice/folk
  1292. practice/jazz
  1293. practice/rock
  1294. @end smallexample
  1295. @FIXME{make sure the above works when going through the examples in
  1296. order...}
  1297. @noindent
  1298. Likewise, if you try to use this command,
  1299. @smallexample
  1300. $ @kbd{tar -tvf music.tar folk jazz}
  1301. @end smallexample
  1302. @noindent
  1303. you would get a similar response. Members with those names are not in the
  1304. archive. You must use the correct member names, or wildcards, in order
  1305. to extract the files from the archive.
  1306. If you have forgotten the correct names of the files in the archive,
  1307. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1308. @FIXME{more examples, here? hag thinks it's a good idea.}
  1309. @node going further
  1310. @section Going Further Ahead in this Manual
  1311. @FIXME{need to write up a node here about the things that are going to
  1312. be in the rest of the manual.}
  1313. @node tar invocation
  1314. @chapter Invoking @GNUTAR{}
  1315. @UNREVISED
  1316. This chapter is about how one invokes the @GNUTAR{}
  1317. command, from the command synopsis (@pxref{Synopsis}). There are
  1318. numerous options, and many styles for writing them. One mandatory
  1319. option specifies the operation @command{tar} should perform
  1320. (@pxref{Operation Summary}), other options are meant to detail how
  1321. this operation should be performed (@pxref{Option Summary}).
  1322. Non-option arguments are not always interpreted the same way,
  1323. depending on what the operation is.
  1324. You will find in this chapter everything about option styles and rules for
  1325. writing them (@pxref{Styles}). On the other hand, operations and options
  1326. are fully described elsewhere, in other chapters. Here, you will find
  1327. only synthetic descriptions for operations and options, together with
  1328. pointers to other parts of the @command{tar} manual.
  1329. Some options are so special they are fully described right in this
  1330. chapter. They have the effect of inhibiting the normal operation of
  1331. @command{tar} or else, they globally alter the amount of feedback the user
  1332. receives about what is going on. These are the @option{--help} and
  1333. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1334. and @option{--interactive} options (@pxref{interactive}).
  1335. @menu
  1336. * Synopsis::
  1337. * using tar options::
  1338. * Styles::
  1339. * All Options::
  1340. * help::
  1341. * defaults::
  1342. * verbose::
  1343. * interactive::
  1344. @end menu
  1345. @node Synopsis
  1346. @section General Synopsis of @command{tar}
  1347. The @GNUTAR{} program is invoked as either one of:
  1348. @smallexample
  1349. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1350. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1351. @end smallexample
  1352. The second form is for when old options are being used.
  1353. You can use @command{tar} to store files in an archive, to extract them from
  1354. an archive, and to do other types of archive manipulation. The primary
  1355. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1356. which action to take. The other arguments to @command{tar} are either
  1357. @dfn{options}, which change the way @command{tar} performs an operation,
  1358. or file names or archive members, which specify the files or members
  1359. @command{tar} is to act on.
  1360. You can actually type in arguments in any order, even if in this manual
  1361. the options always precede the other arguments, to make examples easier
  1362. to understand. Further, the option stating the main operation mode
  1363. (the @command{tar} main command) is usually given first.
  1364. Each @var{name} in the synopsis above is interpreted as an archive member
  1365. name when the main command is one of @option{--compare}
  1366. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1367. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1368. @option{--update} (@option{-u}). When naming archive members, you
  1369. must give the exact name of the member in the archive, as it is
  1370. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1371. @option{--create} (@option{-c}), these @var{name} arguments specify
  1372. the names of either files or directory hierarchies to place in the archive.
  1373. These files or hierarchies should already exist in the file system,
  1374. prior to the execution of the @command{tar} command.
  1375. @command{tar} interprets relative file names as being relative to the
  1376. working directory. @command{tar} will make all file names relative
  1377. (by removing leading slashes when archiving or restoring files),
  1378. unless you specify otherwise (using the @option{--absolute-names}
  1379. option). @xref{absolute}, for more information about
  1380. @option{--absolute-names}.
  1381. If you give the name of a directory as either a file name or a member
  1382. name, then @command{tar} acts recursively on all the files and directories
  1383. beneath that directory. For example, the name @file{/} identifies all
  1384. the files in the file system to @command{tar}.
  1385. The distinction between file names and archive member names is especially
  1386. important when shell globbing is used, and sometimes a source of confusion
  1387. for newcomers. @xref{Wildcards}, for more information about globbing.
  1388. The problem is that shells may only glob using existing files in the
  1389. file system. Only @command{tar} itself may glob on archive members, so when
  1390. needed, you must ensure that wildcard characters reach @command{tar} without
  1391. being interpreted by the shell first. Using a backslash before @samp{*}
  1392. or @samp{?}, or putting the whole argument between quotes, is usually
  1393. sufficient for this.
  1394. Even if @var{name}s are often specified on the command line, they
  1395. can also be read from a text file in the file system, using the
  1396. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1397. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1398. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1399. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1400. will usually yield a diagnostic and inhibit @command{tar} execution.
  1401. The other operations of @command{tar} (@option{--list},
  1402. @option{--extract}, @option{--compare}, and @option{--update})
  1403. will act on the entire contents of the archive.
  1404. @cindex exit status
  1405. @cindex return status
  1406. Besides successful exits, @GNUTAR{} may fail for
  1407. many reasons. Some reasons correspond to bad usage, that is, when the
  1408. @command{tar} command is improperly written. Errors may be
  1409. encountered later, while encountering an error processing the archive
  1410. or the files. Some errors are recoverable, in which case the failure
  1411. is delayed until @command{tar} has completed all its work. Some
  1412. errors are such that it would not meaningful, or at least risky, to
  1413. continue processing: @command{tar} then aborts processing immediately.
  1414. All abnormal exits, whether immediate or delayed, should always be
  1415. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1416. the error.
  1417. @GNUTAR{} returns only a few exit statuses. I'm really
  1418. aiming simplicity in that area, for now. If you are not using the
  1419. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1420. that everything went well, besides maybe innocuous warnings. Nonzero
  1421. means that something went wrong. Right now, as of today, ``nonzero''
  1422. is almost always 2, except for remote operations, where it may be
  1423. 128.
  1424. @node using tar options
  1425. @section Using @command{tar} Options
  1426. @GNUTAR{} has a total of eight operating modes which
  1427. allow you to perform a variety of tasks. You are required to choose
  1428. one operating mode each time you employ the @command{tar} program by
  1429. specifying one, and only one operation as an argument to the
  1430. @command{tar} command (two lists of four operations each may be found
  1431. at @ref{frequent operations} and @ref{Operations}). Depending on
  1432. circumstances, you may also wish to customize how the chosen operating
  1433. mode behaves. For example, you may wish to change the way the output
  1434. looks, or the format of the files that you wish to archive may require
  1435. you to do something special in order to make the archive look right.
  1436. You can customize and control @command{tar}'s performance by running
  1437. @command{tar} with one or more options (such as @option{--verbose}
  1438. (@option{-v}), which we used in the tutorial). As we said in the
  1439. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1440. their name suggests) optional. Depending on the operating mode, you
  1441. may specify one or more options. Different options will have different
  1442. effects, but in general they all change details of the operation, such
  1443. as archive format, archive name, or level of user interaction. Some
  1444. options make sense with all operating modes, while others are
  1445. meaningful only with particular modes. You will likely use some
  1446. options frequently, while you will only use others infrequently, or
  1447. not at all. (A full list of options is available in @pxref{All Options}.)
  1448. @vrindex TAR_OPTIONS, environment variable
  1449. @anchor{TAR_OPTIONS}
  1450. The @env{TAR_OPTIONS} environment variable specifies default options to
  1451. be placed in front of any explicit options. For example, if
  1452. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1453. if the two options @option{-v} and @option{--unlink-first} had been
  1454. specified before any explicit options. Option specifications are
  1455. separated by whitespace. A backslash escapes the next character, so it
  1456. can be used to specify an option containing whitespace or a backslash.
  1457. Note that @command{tar} options are case sensitive. For example, the
  1458. options @option{-T} and @option{-t} are different; the first requires an
  1459. argument for stating the name of a file providing a list of @var{name}s,
  1460. while the second does not require an argument and is another way to
  1461. write @option{--list} (@option{-t}).
  1462. In addition to the eight operations, there are many options to
  1463. @command{tar}, and three different styles for writing both: long (mnemonic)
  1464. form, short form, and old style. These styles are discussed below.
  1465. Both the options and the operations can be written in any of these three
  1466. styles.
  1467. @FIXME{menu at end of this node. need to think of an actual outline
  1468. for this chapter; probably do that after stuff from chapter 4 is
  1469. incorporated.}
  1470. @node Styles
  1471. @section The Three Option Styles
  1472. There are three styles for writing operations and options to the command
  1473. line invoking @command{tar}. The different styles were developed at
  1474. different times during the history of @command{tar}. These styles will be
  1475. presented below, from the most recent to the oldest.
  1476. Some options must take an argument. (For example, @option{--file}
  1477. (@option{-f})) takes the name of an archive file as an argument. If
  1478. you do not supply an archive file name, @command{tar} will use a
  1479. default, but this can be confusing; thus, we recommend that you always
  1480. supply a specific archive file name.) Where you @emph{place} the
  1481. arguments generally depends on which style of options you choose. We
  1482. will detail specific information relevant to each option style in the
  1483. sections on the different option styles, below. The differences are
  1484. subtle, yet can often be very important; incorrect option placement
  1485. can cause you to overwrite a number of important files. We urge you
  1486. to note these differences, and only use the option style(s) which
  1487. makes the most sense to you until you feel comfortable with the others.
  1488. Some options @emph{may} take an argument (currently, there are
  1489. two such options: @option{--backup} and @option{--occurrence}). Such
  1490. options may have at most long and short forms, they do not have old style
  1491. equivalent. The rules for specifying an argument for such options
  1492. are stricter than those for specifying mandatory arguments. Please,
  1493. pay special attention to them.
  1494. @menu
  1495. * Mnemonic Options:: Mnemonic Option Style
  1496. * Short Options:: Short Option Style
  1497. * Old Options:: Old Option Style
  1498. * Mixing:: Mixing Option Styles
  1499. @end menu
  1500. @node Mnemonic Options
  1501. @subsection Mnemonic Option Style
  1502. @FIXME{have to decide whether or not to replace other occurrences of
  1503. "mnemonic" with "long", or *ugh* vice versa.}
  1504. Each option has at least one long (or mnemonic) name starting with two
  1505. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1506. their corresponding short or old names. It sometimes happens that a
  1507. single mnemonic option has many different different names which are
  1508. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1509. long option names can be given unique abbreviations. For example,
  1510. @option{--cre} can be used in place of @option{--create} because there is no
  1511. other mnemonic option which begins with @samp{cre}. (One way to find
  1512. this out is by trying it and seeing what happens; if a particular
  1513. abbreviation could represent more than one option, @command{tar} will tell
  1514. you that that abbreviation is ambiguous and you'll know that that
  1515. abbreviation won't work. You may also choose to run @samp{tar --help}
  1516. to see a list of options. Be aware that if you run @command{tar} with a
  1517. unique abbreviation for the long name of an option you didn't want to
  1518. use, you are stuck; @command{tar} will perform the command as ordered.)
  1519. Mnemonic options are meant to be obvious and easy to remember, and their
  1520. meanings are generally easier to discern than those of their
  1521. corresponding short options (see below). For example:
  1522. @smallexample
  1523. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1524. @end smallexample
  1525. @noindent
  1526. gives a fairly good set of hints about what the command does, even
  1527. for those not fully acquainted with @command{tar}.
  1528. Mnemonic options which require arguments take those arguments
  1529. immediately following the option name. There are two ways of
  1530. specifying a mandatory argument. It can be separated from the
  1531. option name either by an equal sign, or by any amount of
  1532. white space characters. For example, the @option{--file} option (which
  1533. tells the name of the @command{tar} archive) is given a file such as
  1534. @file{archive.tar} as argument by using any of the following notations:
  1535. @option{--file=archive.tar} or @option{--file archive.tar}.
  1536. In contrast, optional arguments must always be introduced using
  1537. an equal sign. For example, the @option{--backup} option takes
  1538. an optional argument specifying backup type. It must be used
  1539. as @option{--backup=@var{backup-type}}.
  1540. @node Short Options
  1541. @subsection Short Option Style
  1542. Most options also have a short option name. Short options start with
  1543. a single dash, and are followed by a single character, e.g., @option{-t}
  1544. (which is equivalent to @option{--list}). The forms are absolutely
  1545. identical in function; they are interchangeable.
  1546. The short option names are faster to type than long option names.
  1547. Short options which require arguments take their arguments immediately
  1548. following the option, usually separated by white space. It is also
  1549. possible to stick the argument right after the short option name, using
  1550. no intervening space. For example, you might write @w{@option{-f
  1551. archive.tar}} or @option{-farchive.tar} instead of using
  1552. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1553. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1554. specific archive, here named @file{archive.tar}.
  1555. Short options which take optional arguments take their arguments
  1556. immediately following the option letter, @emph{without any intervening
  1557. white space characters}.
  1558. Short options' letters may be clumped together, but you are not
  1559. required to do this (as compared to old options; see below). When
  1560. short options are clumped as a set, use one (single) dash for them
  1561. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1562. such a set is allowed to have an argument@footnote{Clustering many
  1563. options, the last of which has an argument, is a rather opaque way to
  1564. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1565. even be made helpful enough for considering such usages as invalid.}.
  1566. When the options are separated, the argument for each option which requires
  1567. an argument directly follows that option, as is usual for Unix programs.
  1568. For example:
  1569. @smallexample
  1570. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1571. @end smallexample
  1572. If you reorder short options' locations, be sure to move any arguments
  1573. that belong to them. If you do not move the arguments properly, you may
  1574. end up overwriting files.
  1575. @node Old Options
  1576. @subsection Old Option Style
  1577. @UNREVISED
  1578. Like short options, old options are single letters. However, old options
  1579. must be written together as a single clumped set, without spaces separating
  1580. them or dashes preceding them@footnote{Beware that if you precede options
  1581. with a dash, you are announcing the short option style instead of the
  1582. old option style; short options are decoded differently.}. This set
  1583. of letters must be the first to appear on the command line, after the
  1584. @command{tar} program name and some white space; old options cannot appear
  1585. anywhere else. The letter of an old option is exactly the same letter as
  1586. the corresponding short option. For example, the old option @samp{t} is
  1587. the same as the short option @option{-t}, and consequently, the same as the
  1588. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1589. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1590. @FIXME{bob suggests having an uglier example. :-) }
  1591. When options that need arguments are given together with the command,
  1592. all the associated arguments follow, in the same order as the options.
  1593. Thus, the example given previously could also be written in the old
  1594. style as follows:
  1595. @smallexample
  1596. $ @kbd{tar cvbf 20 /dev/rmt0}
  1597. @end smallexample
  1598. @noindent
  1599. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1600. the argument of @option{-f}.
  1601. On the other hand, this old style syntax makes it difficult to match
  1602. option letters with their corresponding arguments, and is often
  1603. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1604. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1605. argument for @option{-f}, and @option{-v} does not have a corresponding
  1606. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1607. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1608. pertain to.
  1609. If you want to reorder the letters in the old option argument, be
  1610. sure to reorder any corresponding argument appropriately.
  1611. This old way of writing @command{tar} options can surprise even experienced
  1612. users. For example, the two commands:
  1613. @smallexample
  1614. @kbd{tar cfz archive.tar.gz file}
  1615. @kbd{tar -cfz archive.tar.gz file}
  1616. @end smallexample
  1617. @noindent
  1618. are quite different. The first example uses @file{archive.tar.gz} as
  1619. the value for option @samp{f} and recognizes the option @samp{z}. The
  1620. second example, however, uses @file{z} as the value for option
  1621. @samp{f} --- probably not what was intended.
  1622. Old options are kept for compatibility with old versions of @command{tar}.
  1623. This second example could be corrected in many ways, among which the
  1624. following are equivalent:
  1625. @smallexample
  1626. @kbd{tar -czf archive.tar.gz file}
  1627. @kbd{tar -cf archive.tar.gz -z file}
  1628. @kbd{tar cf archive.tar.gz -z file}
  1629. @end smallexample
  1630. @FIXME{still could explain this better; it's redundant:}
  1631. @cindex option syntax, traditional
  1632. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1633. non-@acronym{GNU}, support old options. @GNUTAR{}
  1634. supports them not only for historical reasons, but also because many
  1635. people are used to them. For compatibility with Unix @command{tar},
  1636. the first argument is always treated as containing command and option
  1637. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1638. equivalent to @w{@samp{tar -c}:} both of them specify the
  1639. @option{--create} (@option{-c}) command to create an archive.
  1640. @node Mixing
  1641. @subsection Mixing Option Styles
  1642. All three styles may be intermixed in a single @command{tar} command,
  1643. so long as the rules for each style are fully
  1644. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1645. a bug prevented intermixing old style options with mnemonic options in
  1646. some cases.}. Old style options and either of the modern styles of
  1647. options may be mixed within a single @command{tar} command. However,
  1648. old style options must be introduced as the first arguments only,
  1649. following the rule for old options (old options must appear directly
  1650. after the @command{tar} command and some white space). Modern options
  1651. may be given only after all arguments to the old options have been
  1652. collected. If this rule is not respected, a modern option might be
  1653. falsely interpreted as the value of the argument to one of the old
  1654. style options.
  1655. For example, all the following commands are wholly equivalent, and
  1656. illustrate the many combinations and orderings of option styles.
  1657. @smallexample
  1658. @kbd{tar --create --file=archive.tar}
  1659. @kbd{tar --create -f archive.tar}
  1660. @kbd{tar --create -farchive.tar}
  1661. @kbd{tar --file=archive.tar --create}
  1662. @kbd{tar --file=archive.tar -c}
  1663. @kbd{tar -c --file=archive.tar}
  1664. @kbd{tar -c -f archive.tar}
  1665. @kbd{tar -c -farchive.tar}
  1666. @kbd{tar -cf archive.tar}
  1667. @kbd{tar -cfarchive.tar}
  1668. @kbd{tar -f archive.tar --create}
  1669. @kbd{tar -f archive.tar -c}
  1670. @kbd{tar -farchive.tar --create}
  1671. @kbd{tar -farchive.tar -c}
  1672. @kbd{tar c --file=archive.tar}
  1673. @kbd{tar c -f archive.tar}
  1674. @kbd{tar c -farchive.tar}
  1675. @kbd{tar cf archive.tar}
  1676. @kbd{tar f archive.tar --create}
  1677. @kbd{tar f archive.tar -c}
  1678. @kbd{tar fc archive.tar}
  1679. @end smallexample
  1680. On the other hand, the following commands are @emph{not} equivalent to
  1681. the previous set:
  1682. @smallexample
  1683. @kbd{tar -f -c archive.tar}
  1684. @kbd{tar -fc archive.tar}
  1685. @kbd{tar -fcarchive.tar}
  1686. @kbd{tar -farchive.tarc}
  1687. @kbd{tar cfarchive.tar}
  1688. @end smallexample
  1689. @noindent
  1690. These last examples mean something completely different from what the
  1691. user intended (judging based on the example in the previous set which
  1692. uses long options, whose intent is therefore very clear). The first
  1693. four specify that the @command{tar} archive would be a file named
  1694. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1695. respectively. The first two examples also specify a single non-option,
  1696. @var{name} argument having the value @samp{archive.tar}. The last
  1697. example contains only old style option letters (repeating option
  1698. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1699. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1700. the first sentence of this paragraph..}
  1701. @node All Options
  1702. @section All @command{tar} Options
  1703. The coming manual sections contain an alphabetical listing of all
  1704. @command{tar} operations and options, with brief descriptions and cross
  1705. references to more in-depth explanations in the body of the manual.
  1706. They also contain an alphabetically arranged table of the short option
  1707. forms with their corresponding long option. You can use this table as
  1708. a reference for deciphering @command{tar} commands in scripts.
  1709. @menu
  1710. * Operation Summary::
  1711. * Option Summary::
  1712. * Short Option Summary::
  1713. @end menu
  1714. @node Operation Summary
  1715. @subsection Operations
  1716. @table @option
  1717. @opindex append, summary
  1718. @item --append
  1719. @itemx -r
  1720. Appends files to the end of the archive. @xref{append}.
  1721. @opindex catenate, summary
  1722. @item --catenate
  1723. @itemx -A
  1724. Same as @option{--concatenate}. @xref{concatenate}.
  1725. @opindex compare, summary
  1726. @item --compare
  1727. @itemx -d
  1728. Compares archive members with their counterparts in the file
  1729. system, and reports differences in file size, mode, owner,
  1730. modification date and contents. @xref{compare}.
  1731. @opindex concatenate, summary
  1732. @item --concatenate
  1733. @itemx -A
  1734. Appends other @command{tar} archives to the end of the archive.
  1735. @xref{concatenate}.
  1736. @opindex create, summary
  1737. @item --create
  1738. @itemx -c
  1739. Creates a new @command{tar} archive. @xref{create}.
  1740. @opindex delete, summary
  1741. @item --delete
  1742. Deletes members from the archive. Don't try this on a archive on a
  1743. tape! @xref{delete}.
  1744. @opindex diff, summary
  1745. @item --diff
  1746. @itemx -d
  1747. Same @option{--compare}. @xref{compare}.
  1748. @opindex extract, summary
  1749. @item --extract
  1750. @itemx -x
  1751. Extracts members from the archive into the file system. @xref{extract}.
  1752. @opindex get, summary
  1753. @item --get
  1754. @itemx -x
  1755. Same as @option{--extract}. @xref{extract}.
  1756. @opindex list, summary
  1757. @item --list
  1758. @itemx -t
  1759. Lists the members in an archive. @xref{list}.
  1760. @opindex update, summary
  1761. @item --update
  1762. @itemx -u
  1763. @FIXME{It was: A combination of the @option{--compare} and
  1764. @option{--append} operations. This is not true and rather misleading,
  1765. as @option{--compare} does a lot more than @option{--update} for
  1766. ensuring files are identical.} Adds files to the end of the archive,
  1767. but only if they are newer than their counterparts already in the
  1768. archive, or if they do not already exist in the archive.
  1769. @xref{update}.
  1770. @end table
  1771. @node Option Summary
  1772. @subsection @command{tar} Options
  1773. @table @option
  1774. @opindex absolute-names, summary
  1775. @item --absolute-names
  1776. @itemx -P
  1777. Normally when creating an archive, @command{tar} strips an initial
  1778. @samp{/} from member names. This option disables that behavior.
  1779. @xref{absolute}.
  1780. @opindex after-date, summary
  1781. @item --after-date
  1782. (See @option{--newer}, @pxref{after})
  1783. @opindex anchored, summary
  1784. @item --anchored
  1785. A pattern must match an initial subsequence of the name's components.
  1786. @xref{controlling pattern-matching}.
  1787. @opindex atime-preserve, summary
  1788. @item --atime-preserve
  1789. @itemx --atime-preserve=replace
  1790. @itemx --atime-preserve=system
  1791. Attempt to preserve the access time of files when reading them. This
  1792. option currently is effective only on files that you own, unless you
  1793. have superuser privileges.
  1794. @option{--atime-preserve=replace} remembers the access time of a file
  1795. before reading it, and then restores the access time afterwards. This
  1796. may cause problems if other programs are reading the file at the same
  1797. time, as the times of their accesses will be lost. On most platforms
  1798. restoring the access time also requires @command{tar} to restore the
  1799. data modification time too, so this option may also cause problems if
  1800. other programs are writing the file at the same time. (Tar attempts
  1801. to detect this situation, but cannot do so reliably due to race
  1802. conditions.) Worse, on most platforms restoring the access time also
  1803. updates the status change time, which means that this option is
  1804. incompatible with incremental backups.
  1805. @option{--atime-preserve=system} avoids changing time stamps on files,
  1806. without interfering with time stamp updates
  1807. caused by other programs, so it works better with incremental backups.
  1808. However, it requires a special @code{O_NOATIME} option from the
  1809. underlying operating and file system implementation, and it also requires
  1810. that searching directories does not update their access times. As of
  1811. this writing (November 2005) this works only with Linux, and only with
  1812. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1813. way to know whether this feature actually works. Sometimes
  1814. @command{tar} knows that it does not work, and if you use
  1815. @option{--atime-preserve=system} then @command{tar} complains and
  1816. exits right away. But other times @command{tar} might think that the
  1817. option works when it actually does not.
  1818. Currently @option{--atime-preserve} with no operand defaults to
  1819. @option{--atime-preserve=replace}, but this may change in the future
  1820. as support for @option{--atime-preserve=system} improves.
  1821. If your operating system does not support
  1822. @option{--atime-preserve=system}, you might be able to preserve access
  1823. times reliably by by using the @command{mount} command. For example,
  1824. you can mount the file system read-only, or access the file system via
  1825. a read-only loopback mount, or use the @samp{noatime} mount option
  1826. available on some systems. However, mounting typically requires
  1827. superuser privileges and can be a pain to manage.
  1828. @opindex backup, summary
  1829. @item --backup=@var{backup-type}
  1830. Rather than deleting files from the file system, @command{tar} will
  1831. back them up using simple or numbered backups, depending upon
  1832. @var{backup-type}. @xref{backup}.
  1833. @opindex block-number, summary
  1834. @item --block-number
  1835. @itemx -R
  1836. With this option present, @command{tar} prints error messages for read errors
  1837. with the block number in the archive file. @xref{block-number}.
  1838. @opindex blocking-factor, summary
  1839. @item --blocking-factor=@var{blocking}
  1840. @itemx -b @var{blocking}
  1841. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1842. record. @xref{Blocking Factor}.
  1843. @opindex bzip2, summary
  1844. @item --bzip2
  1845. @itemx -j
  1846. This option tells @command{tar} to read or write archives through
  1847. @code{bzip2}. @xref{gzip}.
  1848. @opindex checkpoint, summary
  1849. @item --checkpoint
  1850. This option directs @command{tar} to print periodic checkpoint messages as it
  1851. reads through the archive. It is intended for when you want a visual
  1852. indication that @command{tar} is still running, but don't want to see
  1853. @option{--verbose} output. @FIXME-xref{}
  1854. @opindex check-links, summary
  1855. @item --check-links
  1856. @itemx -l
  1857. If this option was given, @command{tar} will check the number of links
  1858. dumped for each processed file. If this number does not match the
  1859. total number of hard links for the file, a warning message will be
  1860. output @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  1861. synonym for @option{--one-file-system}. The current semantics, wich
  1862. complies to UNIX98, was introduced with version
  1863. 1.15.91. @xref{Changes}, for more information.}.
  1864. @opindex compress, summary
  1865. @opindex uncompress, summary
  1866. @item --compress
  1867. @itemx --uncompress
  1868. @itemx -Z
  1869. @command{tar} will use the @command{compress} program when reading or
  1870. writing the archive. This allows you to directly act on archives
  1871. while saving space. @xref{gzip}.
  1872. @opindex confirmation, summary
  1873. @item --confirmation
  1874. (See @option{--interactive}.) @xref{interactive}.
  1875. @opindex delay-directory-restore, summary
  1876. @item --delay-directory-restore
  1877. Delay setting modification times and permissions of extracted
  1878. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  1879. @opindex dereference, summary
  1880. @item --dereference
  1881. @itemx -h
  1882. When creating a @command{tar} archive, @command{tar} will archive the
  1883. file that a symbolic link points to, rather than archiving the
  1884. symlink. @xref{dereference}.
  1885. @opindex directory, summary
  1886. @item --directory=@var{dir}
  1887. @itemx -C @var{dir}
  1888. When this option is specified, @command{tar} will change its current directory
  1889. to @var{dir} before performing any operations. When this option is used
  1890. during archive creation, it is order sensitive. @xref{directory}.
  1891. @opindex exclude, summary
  1892. @item --exclude=@var{pattern}
  1893. When performing operations, @command{tar} will skip files that match
  1894. @var{pattern}. @xref{exclude}.
  1895. @opindex exclude-from, summary
  1896. @item --exclude-from=@var{file}
  1897. @itemx -X @var{file}
  1898. Similar to @option{--exclude}, except @command{tar} will use the list of
  1899. patterns in the file @var{file}. @xref{exclude}.
  1900. @opindex exclude-caches, summary
  1901. @item --exclude-caches
  1902. Automatically excludes all directories
  1903. containing a cache directory tag. @xref{exclude}.
  1904. @opindex file, summary
  1905. @item --file=@var{archive}
  1906. @itemx -f @var{archive}
  1907. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1908. performs operations on, rather than @command{tar}'s compilation dependent
  1909. default. @xref{file tutorial}.
  1910. @opindex files-from, summary
  1911. @item --files-from=@var{file}
  1912. @itemx -T @var{file}
  1913. @command{tar} will use the contents of @var{file} as a list of archive members
  1914. or files to operate on, in addition to those specified on the
  1915. command-line. @xref{files}.
  1916. @opindex force-local, summary
  1917. @item --force-local
  1918. Forces @command{tar} to interpret the filename given to @option{--file}
  1919. as a local file, even if it looks like a remote tape drive name.
  1920. @xref{local and remote archives}.
  1921. @opindex format, summary
  1922. @item --format=@var{format}
  1923. Selects output archive format. @var{Format} may be one of the
  1924. following:
  1925. @table @samp
  1926. @item v7
  1927. Creates an archive that is compatible with Unix V7 @command{tar}.
  1928. @item oldgnu
  1929. Creates an archive that is compatible with GNU @command{tar} version
  1930. 1.12 or earlier.
  1931. @item gnu
  1932. Creates archive in GNU tar 1.13 format. Basically it is the same as
  1933. @samp{oldgnu} with the only difference in the way it handles long
  1934. numeric fields.
  1935. @item ustar
  1936. Creates a @acronym{POSIX.1-1988} compatible archive.
  1937. @item posix
  1938. Creates a @acronym{POSIX.1-2001 archive}.
  1939. @end table
  1940. @xref{Formats}, for a detailed discussion of these formats.
  1941. @opindex group, summary
  1942. @item --group=@var{group}
  1943. Files added to the @command{tar} archive will have a group id of @var{group},
  1944. rather than the group from the source file. @var{group} is first decoded
  1945. as a group symbolic name, but if this interpretation fails, it has to be
  1946. a decimal numeric group ID. @FIXME-xref{}
  1947. Also see the comments for the @option{--owner=@var{user}} option.
  1948. @opindex gzip, summary
  1949. @opindex gunzip, summary
  1950. @opindex ungzip, summary
  1951. @item --gzip
  1952. @itemx --gunzip
  1953. @itemx --ungzip
  1954. @itemx -z
  1955. This option tells @command{tar} to read or write archives through
  1956. @command{gzip}, allowing @command{tar} to directly operate on several
  1957. kinds of compressed archives transparently. @xref{gzip}.
  1958. @opindex help, summary
  1959. @item --help
  1960. @command{tar} will print out a short message summarizing the operations and
  1961. options to @command{tar} and exit. @xref{help}.
  1962. @opindex ignore-case, summary
  1963. @item --ignore-case
  1964. Ignore case when matching member or file names with
  1965. patterns. @xref{controlling pattern-matching}.
  1966. @opindex ignore-command-error, summary
  1967. @item --ignore-command-error
  1968. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  1969. @opindex ignore-failed-read, summary
  1970. @item --ignore-failed-read
  1971. Do not exit unsuccessfully merely because an unreadable file was encountered.
  1972. @xref{Reading}.
  1973. @opindex ignore-zeros, summary
  1974. @item --ignore-zeros
  1975. @itemx -i
  1976. With this option, @command{tar} will ignore zeroed blocks in the
  1977. archive, which normally signals EOF. @xref{Reading}.
  1978. @opindex incremental, summary
  1979. @item --incremental
  1980. @itemx -G
  1981. Used to inform @command{tar} that it is working with an old
  1982. @acronym{GNU}-format incremental backup archive. It is intended
  1983. primarily for backwards compatibility only. @xref{Incremental Dumps},
  1984. for a detailed discussion of incremental archives.
  1985. @opindex index-file, summary
  1986. @item --index-file=@var{file}
  1987. Send verbose output to @var{file} instead of to standard output.
  1988. @opindex info-script, summary
  1989. @opindex new-volume-script, summary
  1990. @item --info-script=@var{script-file}
  1991. @itemx --new-volume-script=@var{script-file}
  1992. @itemx -F @var{script-file}
  1993. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  1994. at the end of each tape. If @var{script-file} exits with nonzero status,
  1995. @command{tar} fails immediately. @xref{info-script}, for a detailed
  1996. discussion of @var{script-file}.
  1997. @opindex interactive, summary
  1998. @item --interactive
  1999. @itemx --confirmation
  2000. @itemx -w
  2001. Specifies that @command{tar} should ask the user for confirmation before
  2002. performing potentially destructive options, such as overwriting files.
  2003. @xref{interactive}.
  2004. @opindex keep-newer-files, summary
  2005. @item --keep-newer-files
  2006. Do not replace existing files that are newer than their archive copies
  2007. when extracting files from an archive.
  2008. @opindex keep-old-files, summary
  2009. @item --keep-old-files
  2010. @itemx -k
  2011. Do not overwrite existing files when extracting files from an archive.
  2012. @xref{Keep Old Files}.
  2013. @opindex label, summary
  2014. @item --label=@var{name}
  2015. @itemx -V @var{name}
  2016. When creating an archive, instructs @command{tar} to write @var{name}
  2017. as a name record in the archive. When extracting or listing archives,
  2018. @command{tar} will only operate on archives that have a label matching
  2019. the pattern specified in @var{name}. @xref{Tape Files}.
  2020. @opindex listed-incremental, summary
  2021. @item --listed-incremental=@var{snapshot-file}
  2022. @itemx -g @var{snapshot-file}
  2023. During a @option{--create} operation, specifies that the archive that
  2024. @command{tar} creates is a new @acronym{GNU}-format incremental
  2025. backup, using @var{snapshot-file} to determine which files to backup.
  2026. With other operations, informs @command{tar} that the archive is in
  2027. incremental format. @xref{Incremental Dumps}.
  2028. @opindex mode, summary
  2029. @item --mode=@var{permissions}
  2030. When adding files to an archive, @command{tar} will use
  2031. @var{permissions} for the archive members, rather than the permissions
  2032. from the files. The program @command{chmod} and this @command{tar}
  2033. option share the same syntax for what @var{permissions} might be.
  2034. @xref{File permissions, Permissions, File permissions, fileutils,
  2035. @acronym{GNU} file utilities}. This reference also has useful
  2036. information for those not being overly familiar with the Unix
  2037. permission system.
  2038. Of course, @var{permissions} might be plainly specified as an octal number.
  2039. However, by using generic symbolic modifications to mode bits, this allows
  2040. more flexibility. For example, the value @samp{a+rw} adds read and write
  2041. permissions for everybody, while retaining executable bits on directories
  2042. or on any other file already marked as executable.
  2043. @opindex multi-volume, summary
  2044. @item --multi-volume
  2045. @itemx -M
  2046. Informs @command{tar} that it should create or otherwise operate on a
  2047. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2048. @opindex new-volume-script, summary
  2049. @item --new-volume-script
  2050. (see --info-script)
  2051. @opindex seek, summary
  2052. @item --seek
  2053. @itemx -n
  2054. Assume that the archive media supports seeks to arbitrary
  2055. locations. Usually @command{tar} determines automatically whether
  2056. the archive can be seeked or not. This option is intended for use
  2057. in cases when such recognition fails.
  2058. @opindex newer, summary
  2059. @item --newer=@var{date}
  2060. @itemx --after-date=@var{date}
  2061. @itemx -N
  2062. When creating an archive, @command{tar} will only add files that have changed
  2063. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2064. is taken to be the name of a file whose data modification time specifies
  2065. the date. @xref{after}.
  2066. @opindex newer-mtime, summary
  2067. @item --newer-mtime=@var{date}
  2068. Like @option{--newer}, but add only files whose
  2069. contents have changed (as opposed to just @option{--newer}, which will
  2070. also back up files for which any status information has changed).
  2071. @opindex no-anchored, summary
  2072. @item --no-anchored
  2073. An exclude pattern can match any subsequence of the name's components.
  2074. @xref{controlling pattern-matching}.
  2075. @opindex no-delay-directory-restore, summary
  2076. @item --no-delay-directory-restore
  2077. Setting modification times and permissions of extracted
  2078. directories when all files from this directory has been
  2079. extracted. This is the default. @xref{Directory Modification Times and Permissions}.
  2080. @opindex no-ignore-case, summary
  2081. @item --no-ignore-case
  2082. Use case-sensitive matching.
  2083. @xref{controlling pattern-matching}.
  2084. @opindex no-ignore-command-error, summary
  2085. @item --no-ignore-command-error
  2086. Print warnings about subprocesses terminated with a non-zero exit
  2087. code. @xref{Writing to an External Program}.
  2088. @opindex no-quote-chars, summary
  2089. @item --no-quote-chars=@var{string}
  2090. Do not quote characters from @var{string}, even if the selected
  2091. quoting style implies they should be quoted (@FIXME-pxref{Quoting Styles}).
  2092. @opindex no-recursion, summary
  2093. @item --no-recursion
  2094. With this option, @command{tar} will not recurse into directories.
  2095. @xref{recurse}.
  2096. @opindex no-same-owner, summary
  2097. @item --no-same-owner
  2098. @itemx -o
  2099. When extracting an archive, do not attempt to preserve the owner
  2100. specified in the @command{tar} archive. This the default behavior
  2101. for ordinary users.
  2102. @opindex no-same-permissions, summary
  2103. @item --no-same-permissions
  2104. When extracting an archive, subtract the user's umask from files from
  2105. the permissions specified in the archive. This is the default behavior
  2106. for ordinary users.
  2107. @opindex no-wildcards, summary
  2108. @item --no-wildcards
  2109. Do not use wildcards.
  2110. @xref{controlling pattern-matching}.
  2111. @opindex no-wildcards-match-slash, summary
  2112. @item --no-wildcards-match-slash
  2113. Wildcards do not match @samp{/}.
  2114. @xref{controlling pattern-matching}.
  2115. @opindex null, summary
  2116. @item --null
  2117. When @command{tar} is using the @option{--files-from} option, this option
  2118. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2119. @command{tar} can correctly work with file names that contain newlines.
  2120. @xref{nul}.
  2121. @opindex numeric-owner, summary
  2122. @item --numeric-owner
  2123. This option will notify @command{tar} that it should use numeric user
  2124. and group IDs when creating a @command{tar} file, rather than names.
  2125. @xref{Attributes}.
  2126. @item -o
  2127. When extracting files, this option is a synonym for
  2128. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2129. restoring ownership of files being extracted.
  2130. When creating an archive, @option{-o} is a synonym for
  2131. @option{--old-archive}. This behavior is for compatibility
  2132. with previous versions of @GNUTAR{}, and will be
  2133. removed in the future releases.
  2134. @xref{Changes}, for more information.
  2135. @opindex occurrence, summary
  2136. @item --occurrence[=@var{number}]
  2137. This option can be used in conjunction with one of the subcommands
  2138. @option{--delete}, @option{--diff}, @option{--extract} or
  2139. @option{--list} when a list of files is given either on the command
  2140. line or via @option{-T} option.
  2141. This option instructs @command{tar} to process only the @var{number}th
  2142. occurrence of each named file. @var{Number} defaults to 1, so
  2143. @smallexample
  2144. tar -x -f archive.tar --occurrence filename
  2145. @end smallexample
  2146. @noindent
  2147. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2148. and will terminate without scanning to the end of the archive.
  2149. @opindex old-archive, summary
  2150. @item --old-archive
  2151. Synonym for @option{--format=v7}.
  2152. @opindex one-file-system, summary
  2153. @item --one-file-system
  2154. Used when creating an archive. Prevents @command{tar} from recursing into
  2155. directories that are on different file systems from the current
  2156. directory @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  2157. synonym for @option{--one-file-system}. This has changed in version
  2158. 1.15.91. @xref{Changes}, for more information.}.
  2159. @opindex overwrite, summary
  2160. @item --overwrite
  2161. Overwrite existing files and directory metadata when extracting files
  2162. from an archive. @xref{Overwrite Old Files}.
  2163. @opindex overwrite-dir, summary
  2164. @item --overwrite-dir
  2165. Overwrite the metadata of existing directories when extracting files
  2166. from an archive. @xref{Overwrite Old Files}.
  2167. @opindex owner, summary
  2168. @item --owner=@var{user}
  2169. Specifies that @command{tar} should use @var{user} as the owner of members
  2170. when creating archives, instead of the user associated with the source
  2171. file. @var{user} is first decoded as a user symbolic name, but if
  2172. this interpretation fails, it has to be a decimal numeric user ID.
  2173. @FIXME-xref{}
  2174. There is no value indicating a missing number, and @samp{0} usually means
  2175. @code{root}. Some people like to force @samp{0} as the value to offer in
  2176. their distributions for the owner of files, because the @code{root} user is
  2177. anonymous anyway, so that might as well be the owner of anonymous archives.
  2178. This option does not affect extraction from archives.
  2179. @opindex quote-chars, summary
  2180. @item --quote-chars=@var{string}
  2181. Always quote characters from @var{string}, even if the selected
  2182. quoting style would not quote them (@FIXME-pxref{Quoting Styles}).
  2183. @opindex quoting-style, summary
  2184. @item --quoting-style=@var{style}
  2185. Set quoting style to use when printing member and file names
  2186. (@FIXME-pxref{Quoting Styles}). Valid @var{style} values are:
  2187. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2188. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2189. style is @code{escape}, unless overridden while configuring the
  2190. package.
  2191. @opindex pax-option, summary
  2192. @item --pax-option=@var{keyword-list}
  2193. @FIXME{Such a detailed description does not belong there, move it elsewhere.}
  2194. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2195. (@pxref{posix}). It modifies the way @command{tar} handles the
  2196. extended header keywords. @var{Keyword-list} is a comma-separated
  2197. list of keyword options, each keyword option taking one of
  2198. the following forms:
  2199. @table @asis
  2200. @item delete=@var{pattern}
  2201. When used with one of archive-creation commands,
  2202. this option instructs @command{tar} to omit from extended header records
  2203. that it produces any keywords matching the string @var{pattern}.
  2204. When used in extract or list mode, this option instructs tar
  2205. to ignore any keywords matching the given @var{pattern} in the extended
  2206. header records. In both cases, matching is performed using the pattern
  2207. matching notation described in @acronym{POSIX 1003.2}, 3.13
  2208. (See @cite{glob(7)}). For example:
  2209. @smallexample
  2210. --pax-option delete=security.*
  2211. @end smallexample
  2212. would suppress security-related information.
  2213. @item exthdr.name=@var{string}
  2214. This keyword allows user control over the name that is written into the
  2215. ustar header blocks for the extended headers. The name is obtained
  2216. from @var{string} after making the following substitutions:
  2217. @multitable @columnfractions .30 .70
  2218. @headitem Meta-character @tab Replaced By
  2219. @item %d @tab The directory name of the file, equivalent to the
  2220. result of the @command{dirname} utility on the translated pathname.
  2221. @item %f @tab The filename of the file, equivalent to the result
  2222. of the @command{basename} utility on the translated pathname.
  2223. @item %p @tab The process ID of the @command{tar} process.
  2224. @item %% @tab A @samp{%} character.
  2225. @end multitable
  2226. Any other @samp{%} characters in @var{string} produce undefined
  2227. results.
  2228. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2229. will use the following default value:
  2230. @smallexample
  2231. %d/PaxHeaders.%p/%f
  2232. @end smallexample
  2233. @item globexthdr.name=@var{string}
  2234. This keyword allows user control over the name that is written into
  2235. the ustar header blocks for global extended header records. The name
  2236. is obtained from the contents of @var{string}, after making
  2237. the following substitutions:
  2238. @multitable @columnfractions .30 .70
  2239. @headitem Meta-character @tab Replaced By
  2240. @item %n @tab An integer that represents the
  2241. sequence number of the global extended header record in the archive,
  2242. starting at 1.
  2243. @item %p @tab The process ID of the @command{tar} process.
  2244. @item %% @tab A @samp{%} character.
  2245. @end multitable
  2246. Any other @samp{%} characters in @var{string} produce undefined results.
  2247. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2248. will use the following default value:
  2249. @smallexample
  2250. $TMPDIR/GlobalHead.%p.%n
  2251. @end smallexample
  2252. @noindent
  2253. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2254. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2255. uses @samp{/tmp}.
  2256. @item @var{keyword}=@var{value}
  2257. When used with one of archive-creation commands, these keyword/value pairs
  2258. will be included at the beginning of the archive in a global extended
  2259. header record. When used with one of archive-reading commands,
  2260. @command{tar} will behave as if it has encountered these keyword/value
  2261. pairs at the beginning of the archive in a global extended header
  2262. record.
  2263. @item @var{keyword}:=@var{value}
  2264. When used with one of archive-creation commands, these keyword/value pairs
  2265. will be included as records at the beginning of an extended header for
  2266. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2267. form except that it creates no global extended header records.
  2268. When used with one of archive-reading commands, @command{tar} will
  2269. behave as if these keyword/value pairs were included as records at the
  2270. end of each extended header; thus, they will override any global or
  2271. file-specific extended header record keywords of the same names.
  2272. For example, in the command:
  2273. @smallexample
  2274. tar --format=posix --create \
  2275. --file archive --pax-option gname:=user .
  2276. @end smallexample
  2277. the group name will be forced to a new value for all files
  2278. stored in the archive.
  2279. @end table
  2280. @opindex portability, summary
  2281. @item --portability
  2282. @itemx --old-archive
  2283. Synonym for @option{--format=v7}.
  2284. @opindex posix, summary
  2285. @item --posix
  2286. Same as @option{--format=posix}.
  2287. @opindex preserve, summary
  2288. @item --preserve
  2289. Synonymous with specifying both @option{--preserve-permissions} and
  2290. @option{--same-order}. @xref{Setting Access Permissions}.
  2291. @opindex preserve-order, summary
  2292. @item --preserve-order
  2293. (See @option{--same-order}; @pxref{Reading}.)
  2294. @opindex preserve-permissions, summary
  2295. @opindex same-permissions, summary
  2296. @item --preserve-permissions
  2297. @itemx --same-permissions
  2298. @itemx -p
  2299. When @command{tar} is extracting an archive, it normally subtracts the
  2300. users' umask from the permissions specified in the archive and uses
  2301. that number as the permissions to create the destination file.
  2302. Specifying this option instructs @command{tar} that it should use the
  2303. permissions directly from the archive. @xref{Setting Access Permissions}.
  2304. @opindex read-full-records, summary
  2305. @item --read-full-records
  2306. @itemx -B
  2307. Specifies that @command{tar} should reblock its input, for reading
  2308. from pipes on systems with buggy implementations. @xref{Reading}.
  2309. @opindex record-size, summary
  2310. @item --record-size=@var{size}
  2311. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2312. archive. @xref{Blocking Factor}.
  2313. @opindex recursion, summary
  2314. @item --recursion
  2315. With this option, @command{tar} recurses into directories.
  2316. @xref{recurse}.
  2317. @opindex recursive-unlink, summary
  2318. @item --recursive-unlink
  2319. Remove existing
  2320. directory hierarchies before extracting directories of the same name
  2321. from the archive. @xref{Recursive Unlink}.
  2322. @opindex remove-files, summary
  2323. @item --remove-files
  2324. Directs @command{tar} to remove the source file from the file system after
  2325. appending it to an archive. @xref{remove files}.
  2326. @opindex restrict, summary
  2327. @item --restrict
  2328. Disable use of some potentially harmful @command{tar} options.
  2329. Currently this option disables shell invocaton from multi-volume menu
  2330. (@pxref{Using Multiple Tapes}).
  2331. @opindex rmt-command, summary
  2332. @item --rmt-command=@var{cmd}
  2333. Notifies @command{tar} that it should use @var{cmd} instead of
  2334. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2335. @opindex rsh-command, summary
  2336. @item --rsh-command=@var{cmd}
  2337. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2338. devices. @xref{Device}.
  2339. @opindex same-order, summary
  2340. @item --same-order
  2341. @itemx --preserve-order
  2342. @itemx -s
  2343. This option is an optimization for @command{tar} when running on machines with
  2344. small amounts of memory. It informs @command{tar} that the list of file
  2345. arguments has already been sorted to match the order of files in the
  2346. archive. @xref{Reading}.
  2347. @opindex same-owner, summary
  2348. @item --same-owner
  2349. When extracting an archive, @command{tar} will attempt to preserve the owner
  2350. specified in the @command{tar} archive with this option present.
  2351. This is the default behavior for the superuser; this option has an
  2352. effect only for ordinary users. @xref{Attributes}.
  2353. @opindex same-permissions, summary
  2354. @item --same-permissions
  2355. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2356. @opindex show-defaults, summary
  2357. @item --show-defaults
  2358. Displays the default options used by @command{tar} and exits
  2359. successfully. This option is intended for use in shell scripts.
  2360. Here is an example of what you can see using this option:
  2361. @smallexample
  2362. $ tar --show-defaults
  2363. --format=gnu -f- -b20 --quoting-style=escape \
  2364. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2365. @end smallexample
  2366. @opindex show-omitted-dirs, summary
  2367. @item --show-omitted-dirs
  2368. Instructs @command{tar} to mention directories its skipping over when
  2369. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2370. @opindex show-stored-names, summary
  2371. @item --show-stored-names
  2372. This option has effect only when used in conjunction with one of
  2373. archive creation operations. It instructs tar to list the member names
  2374. stored in the archive, as opposed to the actual file
  2375. names. @xref{listing member and file names}.
  2376. @opindex sparse, summary
  2377. @item --sparse
  2378. @itemx -S
  2379. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2380. sparse files efficiently. @xref{sparse}.
  2381. @opindex starting-file, summary
  2382. @item --starting-file=@var{name}
  2383. @itemx -K @var{name}
  2384. This option affects extraction only; @command{tar} will skip extracting
  2385. files in the archive until it finds one that matches @var{name}.
  2386. @xref{Scarce}.
  2387. @opindex strip-components, summary
  2388. @item --strip-components=@var{number}
  2389. Strip given @var{number} of leading components from file names before
  2390. extraction.@footnote{This option was called @option{--strip-path} in
  2391. version 1.14.} For example, if archive @file{archive.tar} contained
  2392. @file{/some/file/name}, then running
  2393. @smallexample
  2394. tar --extract --file archive.tar --strip-components=2
  2395. @end smallexample
  2396. @noindent
  2397. would extracted this file to file @file{name}.
  2398. @opindex suffix, summary
  2399. @item --suffix=@var{suffix}
  2400. Alters the suffix @command{tar} uses when backing up files from the default
  2401. @samp{~}. @xref{backup}.
  2402. @opindex tape-length, summary
  2403. @item --tape-length=@var{num}
  2404. @itemx -L @var{num}
  2405. Specifies the length of tapes that @command{tar} is writing as being
  2406. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2407. @opindex test-label, summary
  2408. @item --test-label
  2409. Reads the volume label. If an argument is specified, test whether it
  2410. matches the volume label. @xref{--test-label option}.
  2411. @opindex to-command, summary
  2412. @item --to-command=@var{command}
  2413. During extraction @command{tar} will pipe extracted files to the
  2414. standard input of @var{command}. @xref{Writing to an External Program}.
  2415. @opindex to-stdout, summary
  2416. @item --to-stdout
  2417. @itemx -O
  2418. During extraction, @command{tar} will extract files to stdout rather
  2419. than to the file system. @xref{Writing to Standard Output}.
  2420. @opindex totals, summary
  2421. @item --totals
  2422. Displays the total number of bytes written after creating an archive.
  2423. @xref{verbose}.
  2424. @opindex touch, summary
  2425. @item --touch
  2426. @itemx -m
  2427. Sets the data modification time of extracted files to the extraction time,
  2428. rather than the data modification time stored in the archive.
  2429. @xref{Data Modification Times}.
  2430. @opindex uncompress, summary
  2431. @item --uncompress
  2432. (See @option{--compress}. @pxref{gzip})
  2433. @opindex ungzip, summary
  2434. @item --ungzip
  2435. (See @option{--gzip}. @pxref{gzip})
  2436. @opindex unlink-first, summary
  2437. @item --unlink-first
  2438. @itemx -U
  2439. Directs @command{tar} to remove the corresponding file from the file
  2440. system before extracting it from the archive. @xref{Unlink First}.
  2441. @opindex use-compress-program, summary
  2442. @item --use-compress-program=@var{prog}
  2443. Instructs @command{tar} to access the archive through @var{prog}, which is
  2444. presumed to be a compression program of some sort. @xref{gzip}.
  2445. @opindex utc, summary
  2446. @item --utc
  2447. Display file modification dates in @acronym{UTC}. This option implies
  2448. @option{--verbose}.
  2449. @opindex verbose, summary
  2450. @item --verbose
  2451. @itemx -v
  2452. Specifies that @command{tar} should be more verbose about the operations its
  2453. performing. This option can be specified multiple times for some
  2454. operations to increase the amount of information displayed.
  2455. @xref{verbose}.
  2456. @opindex verify, summary
  2457. @item --verify
  2458. @itemx -W
  2459. Verifies that the archive was correctly written when creating an
  2460. archive. @xref{verify}.
  2461. @opindex version, summary
  2462. @item --version
  2463. Print information about the program's name, version, origin and legal
  2464. status, all on standard output, and then exit successfully.
  2465. @xref{help}.
  2466. @opindex volno-file, summary
  2467. @item --volno-file=@var{file}
  2468. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2469. of which volume of a multi-volume archive its working in @var{file}.
  2470. @xref{volno-file}.
  2471. @opindex wildcards, summary
  2472. @item --wildcards
  2473. Use wildcards when matching member names with patterns.
  2474. @xref{controlling pattern-matching}.
  2475. @opindex wildcards-match-slash, summary
  2476. @item --wildcards-match-slash
  2477. Wildcards match @samp{/}.
  2478. @xref{controlling pattern-matching}.
  2479. @end table
  2480. @node Short Option Summary
  2481. @subsection Short Options Cross Reference
  2482. Here is an alphabetized list of all of the short option forms, matching
  2483. them with the equivalent long option.
  2484. @table @option
  2485. @item -A
  2486. @option{--concatenate}
  2487. @item -B
  2488. @option{--read-full-records}
  2489. @item -C
  2490. @option{--directory}
  2491. @item -F
  2492. @option{--info-script}
  2493. @item -G
  2494. @option{--incremental}
  2495. @item -K
  2496. @option{--starting-file}
  2497. @item -L
  2498. @option{--tape-length}
  2499. @item -M
  2500. @option{--multi-volume}
  2501. @item -N
  2502. @option{--newer}
  2503. @item -O
  2504. @option{--to-stdout}
  2505. @item -P
  2506. @option{--absolute-names}
  2507. @item -R
  2508. @option{--block-number}
  2509. @item -S
  2510. @option{--sparse}
  2511. @item -T
  2512. @option{--files-from}
  2513. @item -U
  2514. @option{--unlink-first}
  2515. @item -V
  2516. @option{--label}
  2517. @item -W
  2518. @option{--verify}
  2519. @item -X
  2520. @option{--exclude-from}
  2521. @item -Z
  2522. @option{--compress}
  2523. @item -b
  2524. @option{--blocking-factor}
  2525. @item -c
  2526. @option{--create}
  2527. @item -d
  2528. @option{--compare}
  2529. @item -f
  2530. @option{--file}
  2531. @item -g
  2532. @option{--listed-incremental}
  2533. @item -h
  2534. @option{--dereference}
  2535. @item -i
  2536. @option{--ignore-zeros}
  2537. @item -j
  2538. @option{--bzip2}
  2539. @item -k
  2540. @option{--keep-old-files}
  2541. @item -l
  2542. @option{--one-file-system}. Use of this short option is deprecated. It
  2543. is retained for compatibility with the earlier versions of GNU
  2544. @command{tar}, and will be changed in future releases.
  2545. @xref{Changes}, for more information.
  2546. @item -m
  2547. @option{--touch}
  2548. @item -o
  2549. When creating --- @option{--no-same-owner}, when extracting ---
  2550. @option{--portability}.
  2551. The later usage is deprecated. It is retained for compatibility with
  2552. the earlier versions of @GNUTAR{}. In the future releases
  2553. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2554. @item -p
  2555. @option{--preserve-permissions}
  2556. @item -r
  2557. @option{--append}
  2558. @item -s
  2559. @option{--same-order}
  2560. @item -t
  2561. @option{--list}
  2562. @item -u
  2563. @option{--update}
  2564. @item -v
  2565. @option{--verbose}
  2566. @item -w
  2567. @option{--interactive}
  2568. @item -x
  2569. @option{--extract}
  2570. @item -z
  2571. @option{--gzip}
  2572. @end table
  2573. @node help
  2574. @section @GNUTAR{} documentation
  2575. @cindex Getting program version number
  2576. @opindex version
  2577. @cindex Version of the @command{tar} program
  2578. Being careful, the first thing is really checking that you are using
  2579. @GNUTAR{}, indeed. The @option{--version} option
  2580. causes @command{tar} to print information about its name, version,
  2581. origin and legal status, all on standard output, and then exit
  2582. successfully. For example, @w{@samp{tar --version}} might print:
  2583. @smallexample
  2584. tar (GNU tar) 1.15.2
  2585. Copyright (C) 2006 Free Software Foundation, Inc.
  2586. This is free software. You may redistribute copies of it under the terms of
  2587. the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  2588. There is NO WARRANTY, to the extent permitted by law.
  2589. Written by John Gilmore and Jay Fenlason.
  2590. @end smallexample
  2591. @noindent
  2592. The first occurrence of @samp{tar} in the result above is the program
  2593. name in the package (for example, @command{rmt} is another program),
  2594. while the second occurrence of @samp{tar} is the name of the package
  2595. itself, containing possibly many programs. The package is currently
  2596. named @samp{tar}, after the name of the main program it
  2597. contains@footnote{There are plans to merge the @command{cpio} and
  2598. @command{tar} packages into a single one which would be called
  2599. @code{paxutils}. So, who knows if, one of this days, the
  2600. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2601. paxutils) 3.2}}}.
  2602. @cindex Obtaining help
  2603. @cindex Listing all @command{tar} options
  2604. @opindex help, introduction
  2605. Another thing you might want to do is checking the spelling or meaning
  2606. of some particular @command{tar} option, without resorting to this
  2607. manual, for once you have carefully read it. @GNUTAR{}
  2608. has a short help feature, triggerable through the
  2609. @option{--help} option. By using this option, @command{tar} will
  2610. print a usage message listing all available options on standard
  2611. output, then exit successfully, without doing anything else and
  2612. ignoring all other options. Even if this is only a brief summary, it
  2613. may be several screens long. So, if you are not using some kind of
  2614. scrollable window, you might prefer to use something like:
  2615. @smallexample
  2616. $ @kbd{tar --help | less}
  2617. @end smallexample
  2618. @noindent
  2619. presuming, here, that you like using @command{less} for a pager. Other
  2620. popular pagers are @command{more} and @command{pg}. If you know about some
  2621. @var{keyword} which interests you and do not want to read all the
  2622. @option{--help} output, another common idiom is doing:
  2623. @smallexample
  2624. tar --help | grep @var{keyword}
  2625. @end smallexample
  2626. @noindent
  2627. for getting only the pertinent lines. Notice, however, that some
  2628. @command{tar} options have long description lines and the above
  2629. command will list only the first of them.
  2630. The exact look of the option summary displayed by @kbd{tar --help} is
  2631. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2632. @opindex usage
  2633. If you only wish to check the spelling of an option, running @kbd{tar
  2634. --usage} may be a better choice. This will display a terse list of
  2635. @command{tar} option without accompanying explanations.
  2636. The short help output is quite succinct, and you might have to get
  2637. back to the full documentation for precise points. If you are reading
  2638. this paragraph, you already have the @command{tar} manual in some
  2639. form. This manual is available in a variety of forms from
  2640. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2641. distribution, provided you have @TeX{} already installed somewhere,
  2642. and a laser printer around. Just configure the distribution, execute
  2643. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2644. usual way (contact your local guru to know how). If @GNUTAR{}
  2645. has been conveniently installed at your place, this
  2646. manual is also available in interactive, hypertextual form as an Info
  2647. file. Just call @w{@samp{info tar}} or, if you do not have the
  2648. @command{info} program handy, use the Info reader provided within
  2649. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2650. There is currently no @code{man} page for @GNUTAR{}.
  2651. If you observe such a @code{man} page on the system you are running,
  2652. either it does not belong to @GNUTAR{}, or it has not
  2653. been produced by @acronym{GNU}. Some package maintainers convert
  2654. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2655. any case, please bear in mind that the authoritative source of
  2656. information about @GNUTAR{} is this Texinfo documentation.
  2657. @node defaults
  2658. @section Obtaining @GNUTAR{} default values
  2659. @opindex show-defaults
  2660. @GNUTAR{} has some predefined defaults that are used when you do not
  2661. explicitely specify another values. To obtain a list of such
  2662. defaults, use @option{--show-defaults} option. This will output the
  2663. values in the form of @command{tar} command line options:
  2664. @smallexample
  2665. @group
  2666. @kbd{tar --show-defaults}
  2667. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2668. @end group
  2669. @end smallexample
  2670. @noindent
  2671. The above output shows that this version of @GNUTAR{} defaults to
  2672. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2673. output as the archive, if no @option{--file} option has been given
  2674. (@pxref{file tutorial}), the default blocking factor is 20
  2675. (@pxref{Blocking Factor}). It also shows the default locations where
  2676. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2677. @node verbose
  2678. @section Checking @command{tar} progress
  2679. Typically, @command{tar} performs most operations without reporting any
  2680. information to the user except error messages. When using @command{tar}
  2681. with many options, particularly ones with complicated or
  2682. difficult-to-predict behavior, it is possible to make serious mistakes.
  2683. @command{tar} provides several options that make observing @command{tar}
  2684. easier. These options cause @command{tar} to print information as it
  2685. progresses in its job, and you might want to use them just for being
  2686. more careful about what is going on, or merely for entertaining
  2687. yourself. If you have encountered a problem when operating on an
  2688. archive, however, you may need more information than just an error
  2689. message in order to solve the problem. The following options can be
  2690. helpful diagnostic tools.
  2691. @cindex Verbose operation
  2692. @opindex verbose
  2693. Normally, the @option{--list} (@option{-t}) command to list an archive
  2694. prints just the file names (one per line) and the other commands are
  2695. silent. When used with most operations, the @option{--verbose}
  2696. (@option{-v}) option causes @command{tar} to print the name of each
  2697. file or archive member as it is processed. This and the other options
  2698. which make @command{tar} print status information can be useful in
  2699. monitoring @command{tar}.
  2700. With @option{--create} or @option{--extract}, @option{--verbose} used
  2701. once just prints the names of the files or members as they are processed.
  2702. Using it twice causes @command{tar} to print a longer listing
  2703. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2704. already prints the names of the members, @option{--verbose} used once
  2705. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2706. type listing of the files in the archive. The following examples both
  2707. extract members with long list output:
  2708. @smallexample
  2709. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2710. $ @kbd{tar xvvf archive.tar}
  2711. @end smallexample
  2712. Verbose output appears on the standard output except when an archive is
  2713. being written to the standard output, as with @samp{tar --create
  2714. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2715. installer let standard output be the default archive). In that case
  2716. @command{tar} writes verbose output to the standard error stream.
  2717. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2718. verbose output to @var{file} rather than to standard output or standard
  2719. error.
  2720. @cindex Obtaining total status information
  2721. @opindex totals
  2722. The @option{--totals} option---which is only meaningful when used with
  2723. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2724. amount written to the archive, after it has been fully created.
  2725. @cindex Progress information
  2726. @opindex checkpoint
  2727. The @option{--checkpoint} option prints an occasional message
  2728. as @command{tar} reads or writes the archive. In fact, it prints
  2729. a message each 10 records read or written. It is designed for
  2730. those who don't need the more detailed (and voluminous) output of
  2731. @option{--block-number} (@option{-R}), but do want visual confirmation that @command{tar}
  2732. is actually making forward progress.
  2733. @FIXME{There is some confusion here. It seems that -R once wrote a
  2734. message at @samp{every} record read or written.}
  2735. @opindex show-omitted-dirs
  2736. @anchor{show-omitted-dirs}
  2737. The @option{--show-omitted-dirs} option, when reading an archive---with
  2738. @option{--list} or @option{--extract}, for example---causes a message
  2739. to be printed for each directory in the archive which is skipped.
  2740. This happens regardless of the reason for skipping: the directory might
  2741. not have been named on the command line (implicitly or explicitly),
  2742. it might be excluded by the use of the @option{--exclude=@var{pattern}} option, or
  2743. some other reason.
  2744. @opindex block-number
  2745. @cindex Block number where error occurred
  2746. @anchor{block-number}
  2747. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2748. every message it would normally produce, the block number within the
  2749. archive where the message was triggered. Also, supplementary messages
  2750. are triggered when reading blocks full of NULs, or when hitting end of
  2751. file on the archive. As of now, if the archive if properly terminated
  2752. with a NUL block, the reading of the file may stop before end of file
  2753. is met, so the position of end of file will not usually show when
  2754. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2755. drains the archive before exiting when reading the
  2756. archive from a pipe.
  2757. @cindex Error message, block number of
  2758. This option is especially useful when reading damaged archives, since
  2759. it helps pinpoint the damaged sections. It can also be used with
  2760. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2761. choose among several backup tapes when retrieving a file later, in
  2762. favor of the tape where the file appears earliest (closest to the
  2763. front of the tape). @xref{backup}.
  2764. @node interactive
  2765. @section Asking for Confirmation During Operations
  2766. @cindex Interactive operation
  2767. Typically, @command{tar} carries out a command without stopping for
  2768. further instructions. In some situations however, you may want to
  2769. exclude some files and archive members from the operation (for instance
  2770. if disk or storage space is tight). You can do this by excluding
  2771. certain files automatically (@pxref{Choosing}), or by performing
  2772. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2773. @command{tar} also accepts @option{--confirmation} for this option.
  2774. @opindex interactive
  2775. When the @option{--interactive} (@option{-w}) option is specified, before
  2776. reading, writing, or deleting files, @command{tar} first prints a message
  2777. for each such file, telling what operation it intends to take, then asks
  2778. for confirmation on the terminal. The actions which require
  2779. confirmation include adding a file to the archive, extracting a file
  2780. from the archive, deleting a file from the archive, and deleting a file
  2781. from disk. To confirm the action, you must type a line of input
  2782. beginning with @samp{y}. If your input line begins with anything other
  2783. than @samp{y}, @command{tar} skips that file.
  2784. If @command{tar} is reading the archive from the standard input,
  2785. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2786. communications.
  2787. Verbose output is normally sent to standard output, separate from
  2788. other error messages. However, if the archive is produced directly
  2789. on standard output, then verbose output is mixed with errors on
  2790. @code{stderr}. Producing the archive on standard output may be used
  2791. as a way to avoid using disk space, when the archive is soon to be
  2792. consumed by another process reading it, say. Some people felt the need
  2793. of producing an archive on stdout, still willing to segregate between
  2794. verbose output and error output. A possible approach would be using a
  2795. named pipe to receive the archive, and having the consumer process to
  2796. read from that named pipe. This has the advantage of letting standard
  2797. output free to receive verbose output, all separate from errors.
  2798. @node operations
  2799. @chapter @GNUTAR{} Operations
  2800. @menu
  2801. * Basic tar::
  2802. * Advanced tar::
  2803. * create options::
  2804. * extract options::
  2805. * backup::
  2806. * Applications::
  2807. * looking ahead::
  2808. @end menu
  2809. @node Basic tar
  2810. @section Basic @GNUTAR{} Operations
  2811. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2812. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2813. @option{-x}), are currently presented and described in the tutorial
  2814. chapter of this manual. This section provides some complementary notes
  2815. for these operations.
  2816. @table @option
  2817. @opindex create, complementary notes
  2818. @item --create
  2819. @itemx -c
  2820. Creating an empty archive would have some kind of elegance. One can
  2821. initialize an empty archive and later use @option{--append}
  2822. (@option{-r}) for adding all members. Some applications would not
  2823. welcome making an exception in the way of adding the first archive
  2824. member. On the other hand, many people reported that it is
  2825. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2826. an empty archive@footnote{This is well described in @cite{Unix-haters
  2827. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2828. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2829. @enumerate
  2830. @item
  2831. Mistakingly using @code{create} instead of @code{extract}, when the
  2832. intent was to extract the full contents of an archive. This error
  2833. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2834. the QWERTY keyboard. Instead of being unpacked, the archive then
  2835. gets wholly destroyed. When users speak about @dfn{exploding} an
  2836. archive, they usually mean something else :-).
  2837. @item
  2838. Forgetting the argument to @code{file}, when the intent was to create
  2839. an archive with a single file in it. This error is likely because a
  2840. tired user can easily add the @kbd{f} key to the cluster of option
  2841. letters, by the mere force of habit, without realizing the full
  2842. consequence of doing so. The usual consequence is that the single
  2843. file, which was meant to be saved, is rather destroyed.
  2844. @end enumerate
  2845. So, recognizing the likelihood and the catastrophical nature of these
  2846. errors, @GNUTAR{} now takes some distance from elegance, and
  2847. cowardly refuses to create an archive when @option{--create} option is
  2848. given, there are no arguments besides options, and
  2849. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2850. around the cautiousness of @GNUTAR{} and nevertheless create an
  2851. archive with nothing in it, one may still use, as the value for the
  2852. @option{--files-from} option, a file with no names in it, as shown in
  2853. the following commands:
  2854. @smallexample
  2855. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2856. @kbd{tar cfT empty-archive.tar /dev/null}
  2857. @end smallexample
  2858. @opindex extract, complementary notes
  2859. @item --extract
  2860. @itemx --get
  2861. @itemx -x
  2862. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2863. @item @option{--list} (@option{-t})
  2864. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2865. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2866. people should get used to ISO 8601 dates. Local American dates should
  2867. be made available again with full date localization support, once
  2868. ready. In the meantime, programs not being localizable for dates
  2869. should prefer international dates, that's really the way to go.
  2870. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2871. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2872. @end table
  2873. @node Advanced tar
  2874. @section Advanced @GNUTAR{} Operations
  2875. Now that you have learned the basics of using @GNUTAR{}, you may want
  2876. to learn about further ways in which @command{tar} can help you.
  2877. This chapter presents five, more advanced operations which you probably
  2878. won't use on a daily basis, but which serve more specialized functions.
  2879. We also explain the different styles of options and why you might want
  2880. to use one or another, or a combination of them in your @command{tar}
  2881. commands. Additionally, this chapter includes options which allow you to
  2882. define the output from @command{tar} more carefully, and provide help and
  2883. error correction in special circumstances.
  2884. @FIXME{check this after the chapter is actually revised to make sure
  2885. it still introduces the info in the chapter correctly : ).}
  2886. @menu
  2887. * Operations::
  2888. * append::
  2889. * update::
  2890. * concatenate::
  2891. * delete::
  2892. * compare::
  2893. @end menu
  2894. @node Operations
  2895. @subsection The Five Advanced @command{tar} Operations
  2896. @UNREVISED
  2897. In the last chapter, you learned about the first three operations to
  2898. @command{tar}. This chapter presents the remaining five operations to
  2899. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2900. @option{--delete}, and @option{--compare}.
  2901. You are not likely to use these operations as frequently as those
  2902. covered in the last chapter; however, since they perform specialized
  2903. functions, they are quite useful when you do need to use them. We
  2904. will give examples using the same directory and files that you created
  2905. in the last chapter. As you may recall, the directory is called
  2906. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2907. @samp{rock}, and the two archive files you created are
  2908. @samp{collection.tar} and @samp{music.tar}.
  2909. We will also use the archive files @samp{afiles.tar} and
  2910. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2911. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2912. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2913. Unless we state otherwise, all practicing you do and examples you follow
  2914. in this chapter will take place in the @file{practice} directory that
  2915. you created in the previous chapter; see @ref{prepare for examples}.
  2916. (Below in this section, we will remind you of the state of the examples
  2917. where the last chapter left them.)
  2918. The five operations that we will cover in this chapter are:
  2919. @table @option
  2920. @item --append
  2921. @itemx -r
  2922. Add new entries to an archive that already exists.
  2923. @item --update
  2924. @itemx -r
  2925. Add more recent copies of archive members to the end of an archive, if
  2926. they exist.
  2927. @item --concatenate
  2928. @itemx --catenate
  2929. @itemx -A
  2930. Add one or more pre-existing archives to the end of another archive.
  2931. @item --delete
  2932. Delete items from an archive (does not work on tapes).
  2933. @item --compare
  2934. @itemx --diff
  2935. @itemx -d
  2936. Compare archive members to their counterparts in the file system.
  2937. @end table
  2938. @node append
  2939. @subsection How to Add Files to Existing Archives: @option{--append}
  2940. @UNREVISED
  2941. @opindex append
  2942. If you want to add files to an existing archive, you don't need to
  2943. create a new archive; you can use @option{--append} (@option{-r}).
  2944. The archive must already exist in order to use @option{--append}. (A
  2945. related operation is the @option{--update} operation; you can use this
  2946. to add newer versions of archive members to an existing archive. To learn how to
  2947. do this with @option{--update}, @pxref{update}.)
  2948. If you use @option{--append} to add a file that has the same name as an
  2949. archive member to an archive containing that archive member, then the
  2950. old member is not deleted. What does happen, however, is somewhat
  2951. complex. @command{tar} @emph{allows} you to have infinite number of files
  2952. with the same name. Some operations treat these same-named members no
  2953. differently than any other set of archive members: for example, if you
  2954. view an archive with @option{--list} (@option{-t}), you will see all
  2955. of those members listed, with their data modification times, owners, etc.
  2956. Other operations don't deal with these members as perfectly as you might
  2957. prefer; if you were to use @option{--extract} to extract the archive,
  2958. only the most recently added copy of a member with the same name as four
  2959. other members would end up in the working directory. This is because
  2960. @option{--extract} extracts an archive in the order the members appeared
  2961. in the archive; the most recently archived members will be extracted
  2962. last. Additionally, an extracted member will @emph{replace} a file of
  2963. the same name which existed in the directory already, and @command{tar}
  2964. will not prompt you about this@footnote{Unless you give it
  2965. @option{--keep-old-files} option, or the disk copy is newer than the
  2966. the one in the archive and you invoke @command{tar} with
  2967. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2968. member will end up being extracted, as it will replace the one
  2969. extracted before it, and so on.
  2970. There exists a special option that allows you to get around this
  2971. behavior and extract (or list) only a particular copy of the file.
  2972. This is @option{--occurrence} option. If you run @command{tar} with
  2973. this option, it will extract only the first copy of the file. You
  2974. may also give this option an argument specifying the number of
  2975. copy to be extracted. Thus, for example if the archive
  2976. @file{archive.tar} contained three copies of file @file{myfile}, then
  2977. the command
  2978. @smallexample
  2979. tar --extract --file archive.tar --occurrence=2 myfile
  2980. @end smallexample
  2981. @noindent
  2982. would extract only the second copy. @xref{Option
  2983. Summary,---occurrence}, for the description of @option{--occurrence}
  2984. option.
  2985. @FIXME{ hag -- you might want to incorporate some of the above into the
  2986. MMwtSN node; not sure. i didn't know how to make it simpler...
  2987. There are a few ways to get around this. (maybe xref Multiple Members
  2988. with the Same Name.}
  2989. @cindex Members, replacing with other members
  2990. @cindex Replacing members with other members
  2991. If you want to replace an archive member, use @option{--delete} to
  2992. delete the member you want to remove from the archive, , and then use
  2993. @option{--append} to add the member you want to be in the archive. Note
  2994. that you can not change the order of the archive; the most recently
  2995. added member will still appear last. In this sense, you cannot truly
  2996. ``replace'' one member with another. (Replacing one member with another
  2997. will not work on certain types of media, such as tapes; see @ref{delete}
  2998. and @ref{Media}, for more information.)
  2999. @menu
  3000. * appending files:: Appending Files to an Archive
  3001. * multiple::
  3002. @end menu
  3003. @node appending files
  3004. @subsubsection Appending Files to an Archive
  3005. @UNREVISED
  3006. @cindex Adding files to an Archive
  3007. @cindex Appending files to an Archive
  3008. @cindex Archives, Appending files to
  3009. The simplest way to add a file to an already existing archive is the
  3010. @option{--append} (@option{-r}) operation, which writes specified files into the
  3011. archive whether or not they are already among the archived files.
  3012. When you use @option{--append}, you @emph{must} specify file name
  3013. arguments, as there is no default. If you specify a file that already
  3014. exists in the archive, another copy of the file will be added to the
  3015. end of the archive. As with other operations, the member names of the
  3016. newly added files will be exactly the same as their names given on the
  3017. command line. The @option{--verbose} (@option{-v}) option will print
  3018. out the names of the files as they are written into the archive.
  3019. @option{--append} cannot be performed on some tape drives, unfortunately,
  3020. due to deficiencies in the formats those tape drives use. The archive
  3021. must be a valid @command{tar} archive, or else the results of using this
  3022. operation will be unpredictable. @xref{Media}.
  3023. To demonstrate using @option{--append} to add a file to an archive,
  3024. create a file called @file{rock} in the @file{practice} directory.
  3025. Make sure you are in the @file{practice} directory. Then, run the
  3026. following @command{tar} command to add @file{rock} to
  3027. @file{collection.tar}:
  3028. @smallexample
  3029. $ @kbd{tar --append --file=collection.tar rock}
  3030. @end smallexample
  3031. @noindent
  3032. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3033. @file{rock} has been added to the archive:
  3034. @smallexample
  3035. $ @kbd{tar --list --file=collection.tar}
  3036. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3037. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3038. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3039. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3040. @end smallexample
  3041. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3042. title claims it will become...}
  3043. @node multiple
  3044. @subsubsection Multiple Files with the Same Name
  3045. You can use @option{--append} (@option{-r}) to add copies of files which have been
  3046. updated since the archive was created. (However, we do not recommend
  3047. doing this since there is another @command{tar} option called
  3048. @option{--update}; @pxref{update} for more information. We describe this
  3049. use of @option{--append} here for the sake of completeness.) @FIXME{is
  3050. this really a good idea, to give this whole description for something
  3051. which i believe is basically a Stupid way of doing something? certain
  3052. aspects of it show ways in which tar is more broken than i'd personally
  3053. like to admit to, specifically the last sentence. On the other hand, i
  3054. don't think it's a good idea to be saying that we explicitly don't
  3055. recommend using something, but i can't see any better way to deal with
  3056. the situation.}When you extract the archive, the older version will be
  3057. effectively lost. This works because files are extracted from an
  3058. archive in the order in which they were archived. Thus, when the
  3059. archive is extracted, a file archived later in time will replace a
  3060. file of the same name which was archived earlier, even though the older
  3061. version of the file will remain in the archive unless you delete all
  3062. versions of the file.
  3063. Supposing you change the file @file{blues} and then append the changed
  3064. version to @file{collection.tar}. As you saw above, the original
  3065. @file{blues} is in the archive @file{collection.tar}. If you change the
  3066. file and append the new version of the file to the archive, there will
  3067. be two copies in the archive. When you extract the archive, the older
  3068. version of the file will be extracted first, and then replaced by the
  3069. newer version when it is extracted.
  3070. You can append the new, changed copy of the file @file{blues} to the
  3071. archive in this way:
  3072. @smallexample
  3073. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3074. blues
  3075. @end smallexample
  3076. @noindent
  3077. Because you specified the @option{--verbose} option, @command{tar} has
  3078. printed the name of the file being appended as it was acted on. Now
  3079. list the contents of the archive:
  3080. @smallexample
  3081. $ @kbd{tar --list --verbose --file=collection.tar}
  3082. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3083. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3084. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3085. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3086. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3087. @end smallexample
  3088. @noindent
  3089. The newest version of @file{blues} is now at the end of the archive
  3090. (note the different creation dates and file sizes). If you extract
  3091. the archive, the older version of the file @file{blues} will be
  3092. replaced by the newer version. You can confirm this by extracting
  3093. the archive and running @samp{ls} on the directory.
  3094. If you wish to extract the first occurrence of the file @file{blues}
  3095. from the archive, use @option{--occurrence} option, as shown in
  3096. the following example:
  3097. @smallexample
  3098. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3099. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3100. @end smallexample
  3101. @xref{Writing}, for more information on @option{--extract} and
  3102. @xref{Option Summary, --occurrence}, for the description of
  3103. @option{--occurrence} option.
  3104. @node update
  3105. @subsection Updating an Archive
  3106. @UNREVISED
  3107. @cindex Updating an archive
  3108. @opindex update
  3109. In the previous section, you learned how to use @option{--append} to
  3110. add a file to an existing archive. A related operation is
  3111. @option{--update} (@option{-u}). The @option{--update} operation
  3112. updates a @command{tar} archive by comparing the date of the specified
  3113. archive members against the date of the file with the same name. If
  3114. the file has been modified more recently than the archive member, then
  3115. the newer version of the file is added to the archive (as with
  3116. @option{--append}).
  3117. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3118. The operation will fail.
  3119. @FIXME{other examples of media on which --update will fail? need to ask
  3120. charles and/or mib/thomas/dave shevett..}
  3121. Both @option{--update} and @option{--append} work by adding to the end
  3122. of the archive. When you extract a file from the archive, only the
  3123. version stored last will wind up in the file system, unless you use
  3124. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3125. Same Name}
  3126. @menu
  3127. * how to update::
  3128. @end menu
  3129. @node how to update
  3130. @subsubsection How to Update an Archive Using @option{--update}
  3131. You must use file name arguments with the @option{--update} (@option{-u}) operation.
  3132. If you don't specify any files, @command{tar} won't act on any files and
  3133. won't tell you that it didn't do anything (which may end up confusing
  3134. you).
  3135. @FIXME{note: the above parenthetical added because in fact, this
  3136. behavior just confused the author. :-) }
  3137. To see the @option{--update} option at work, create a new file,
  3138. @file{classical}, in your practice directory, and some extra text to the
  3139. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3140. the @samp{update} operation and the @option{--verbose} (@option{-v}) option specified,
  3141. using the names of all the files in the practice directory as file name
  3142. arguments:
  3143. @smallexample
  3144. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3145. blues
  3146. classical
  3147. $
  3148. @end smallexample
  3149. @noindent
  3150. Because we have specified verbose mode, @command{tar} prints out the names
  3151. of the files it is working on, which in this case are the names of the
  3152. files that needed to be updated. If you run @samp{tar --list} and look
  3153. at the archive, you will see @file{blues} and @file{classical} at its
  3154. end. There will be a total of two versions of the member @samp{blues};
  3155. the one at the end will be newer and larger, since you added text before
  3156. updating it.
  3157. (The reason @command{tar} does not overwrite the older file when updating
  3158. it is because writing to the middle of a section of tape is a difficult
  3159. process. Tapes are not designed to go backward. @xref{Media}, for more
  3160. information about tapes.
  3161. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3162. reasons: it does not change directory content entries, and it
  3163. lengthens the archive every time it is used. The @GNUTAR{}
  3164. options intended specifically for backups are more
  3165. efficient. If you need to run backups, please consult @ref{Backups}.
  3166. @node concatenate
  3167. @subsection Combining Archives with @option{--concatenate}
  3168. @cindex Adding archives to an archive
  3169. @cindex Concatenating Archives
  3170. @opindex concatenate
  3171. @opindex catenate
  3172. @c @cindex @option{-A} described
  3173. Sometimes it may be convenient to add a second archive onto the end of
  3174. an archive rather than adding individual files to the archive. To add
  3175. one or more archives to the end of another archive, you should use the
  3176. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3177. To use @option{--concatenate}, give the first archive with
  3178. @option{--file} option and name the rest of archives to be
  3179. concatenated on the command line. The members, and their member
  3180. names, will be copied verbatim from those archives to the first one.
  3181. @FIXME-ref{This can cause multiple members to have the same name, for
  3182. information on how this affects reading the archive, Multiple
  3183. Members with the Same Name.}
  3184. The new, concatenated archive will be called by the same name as the
  3185. one given with the @option{--file} option. As usual, if you omit
  3186. @option{--file}, @command{tar} will use the value of the environment
  3187. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3188. @FIXME{There is no way to specify a new name...}
  3189. To demonstrate how @option{--concatenate} works, create two small archives
  3190. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3191. files from @file{practice}:
  3192. @smallexample
  3193. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3194. blues
  3195. rock
  3196. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3197. folk
  3198. jazz
  3199. @end smallexample
  3200. @noindent
  3201. If you like, You can run @samp{tar --list} to make sure the archives
  3202. contain what they are supposed to:
  3203. @smallexample
  3204. $ @kbd{tar -tvf bluesrock.tar}
  3205. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3206. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3207. $ @kbd{tar -tvf jazzfolk.tar}
  3208. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3209. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3210. @end smallexample
  3211. We can concatenate these two archives with @command{tar}:
  3212. @smallexample
  3213. $ @kbd{cd ..}
  3214. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3215. @end smallexample
  3216. If you now list the contents of the @file{bluesrock.tar}, you will see
  3217. that now it also contains the archive members of @file{jazzfolk.tar}:
  3218. @smallexample
  3219. $ @kbd{tar --list --file=bluesrock.tar}
  3220. blues
  3221. rock
  3222. folk
  3223. jazz
  3224. @end smallexample
  3225. When you use @option{--concatenate}, the source and target archives must
  3226. already exist and must have been created using compatible format
  3227. parameters. Notice, that @command{tar} does not check whether the
  3228. archives it concatenates have compatible formats, it does not
  3229. even check if the files are really tar archives.
  3230. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3231. tape drives, due to deficiencies in the formats those tape drives use.
  3232. @cindex @code{concatenate} vs @command{cat}
  3233. @cindex @command{cat} vs @code{concatenate}
  3234. It may seem more intuitive to you to want or try to use @command{cat} to
  3235. concatenate two archives instead of using the @option{--concatenate}
  3236. operation; after all, @command{cat} is the utility for combining files.
  3237. However, @command{tar} archives incorporate an end-of-file marker which
  3238. must be removed if the concatenated archives are to be read properly as
  3239. one archive. @option{--concatenate} removes the end-of-archive marker
  3240. from the target archive before each new archive is appended. If you use
  3241. @command{cat} to combine the archives, the result will not be a valid
  3242. @command{tar} format archive. If you need to retrieve files from an
  3243. archive that was added to using the @command{cat} utility, use the
  3244. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3245. information on dealing with archives improperly combined using the
  3246. @command{cat} shell utility.
  3247. @node delete
  3248. @subsection Removing Archive Members Using @option{--delete}
  3249. @UNREVISED
  3250. @cindex Deleting files from an archive
  3251. @cindex Removing files from an archive
  3252. @opindex delete
  3253. You can remove members from an archive by using the @option{--delete}
  3254. option. Specify the name of the archive with @option{--file}
  3255. (@option{-f}) and then specify the names of the members to be deleted;
  3256. if you list no member names, nothing will be deleted. The
  3257. @option{--verbose} option will cause @command{tar} to print the names
  3258. of the members as they are deleted. As with @option{--extract}, you
  3259. must give the exact member names when using @samp{tar --delete}.
  3260. @option{--delete} will remove all versions of the named file from the
  3261. archive. The @option{--delete} operation can run very slowly.
  3262. Unlike other operations, @option{--delete} has no short form.
  3263. @cindex Tapes, using @option{--delete} and
  3264. @cindex Deleting from tape archives
  3265. This operation will rewrite the archive. You can only use
  3266. @option{--delete} on an archive if the archive device allows you to
  3267. write to any point on the media, such as a disk; because of this, it
  3268. does not work on magnetic tapes. Do not try to delete an archive member
  3269. from a magnetic tape; the action will not succeed, and you will be
  3270. likely to scramble the archive and damage your tape. There is no safe
  3271. way (except by completely re-writing the archive) to delete files from
  3272. most kinds of magnetic tape. @xref{Media}.
  3273. To delete all versions of the file @file{blues} from the archive
  3274. @file{collection.tar} in the @file{practice} directory, make sure you
  3275. are in that directory, and then,
  3276. @smallexample
  3277. $ @kbd{tar --list --file=collection.tar}
  3278. blues
  3279. folk
  3280. jazz
  3281. rock
  3282. practice/blues
  3283. practice/folk
  3284. practice/jazz
  3285. practice/rock
  3286. practice/blues
  3287. $ @kbd{tar --delete --file=collection.tar blues}
  3288. $ @kbd{tar --list --file=collection.tar}
  3289. folk
  3290. jazz
  3291. rock
  3292. $
  3293. @end smallexample
  3294. @FIXME{I changed the order of these nodes around and haven't had a chance
  3295. to fix the above example's results, yet. I have to play with this and
  3296. follow it and see what it actually does!}
  3297. The @option{--delete} option has been reported to work properly when
  3298. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3299. @node compare
  3300. @subsection Comparing Archive Members with the File System
  3301. @cindex Verifying the currency of an archive
  3302. @UNREVISED
  3303. @opindex compare
  3304. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3305. specified archive members against files with the same names, and then
  3306. reports differences in file size, mode, owner, modification date and
  3307. contents. You should @emph{only} specify archive member names, not file
  3308. names. If you do not name any members, then @command{tar} will compare the
  3309. entire archive. If a file is represented in the archive but does not
  3310. exist in the file system, @command{tar} reports a difference.
  3311. You have to specify the record size of the archive when modifying an
  3312. archive with a non-default record size.
  3313. @command{tar} ignores files in the file system that do not have
  3314. corresponding members in the archive.
  3315. The following example compares the archive members @file{rock},
  3316. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3317. files of the same name in the file system. (Note that there is no file,
  3318. @file{funk}; @command{tar} will report an error message.)
  3319. @smallexample
  3320. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3321. rock
  3322. blues
  3323. tar: funk not found in archive
  3324. @end smallexample
  3325. The spirit behind the @option{--compare} (@option{--diff}, @option{-d}) option is to check whether the
  3326. archive represents the current state of files on disk, more than validating
  3327. the integrity of the archive media. For this later goal, @xref{verify}.
  3328. @node create options
  3329. @section Options Used by @option{--create}
  3330. @opindex create, additional options
  3331. The previous chapter described the basics of how to use
  3332. @option{--create} (@option{-c}) to create an archive from a set of files.
  3333. @xref{create}. This section described advanced options to be used with
  3334. @option{--create}.
  3335. @menu
  3336. * Ignore Failed Read::
  3337. @end menu
  3338. @node Ignore Failed Read
  3339. @subsection Ignore Fail Read
  3340. @table @option
  3341. @item --ignore-failed-read
  3342. Do not exit with nonzero on unreadable files or directories.
  3343. @end table
  3344. @node extract options
  3345. @section Options Used by @option{--extract}
  3346. @UNREVISED
  3347. @FIXME{i need to get dan to go over these options with me and see if
  3348. there's a better way of organizing them.}
  3349. @opindex extract, additional options
  3350. The previous chapter showed how to use @option{--extract} to extract
  3351. an archive into the file system. Various options cause @command{tar} to
  3352. extract more information than just file contents, such as the owner,
  3353. the permissions, the modification date, and so forth. This section
  3354. presents options to be used with @option{--extract} when certain special
  3355. considerations arise. You may review the information presented in
  3356. @ref{extract} for more basic information about the
  3357. @option{--extract} operation.
  3358. @menu
  3359. * Reading:: Options to Help Read Archives
  3360. * Writing:: Changing How @command{tar} Writes Files
  3361. * Scarce:: Coping with Scarce Resources
  3362. @end menu
  3363. @node Reading
  3364. @subsection Options to Help Read Archives
  3365. @cindex Options when reading archives
  3366. @UNREVISED
  3367. @cindex Reading incomplete records
  3368. @cindex Records, incomplete
  3369. @opindex read-full-records
  3370. Normally, @command{tar} will request data in full record increments from
  3371. an archive storage device. If the device cannot return a full record,
  3372. @command{tar} will report an error. However, some devices do not always
  3373. return full records, or do not require the last record of an archive to
  3374. be padded out to the next record boundary. To keep reading until you
  3375. obtain a full record, or to accept an incomplete record if it contains
  3376. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3377. in conjunction with the @option{--extract} or @option{--list} operations.
  3378. @xref{Blocking}.
  3379. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3380. @command{tar} reads an archive from standard input, or from a remote
  3381. machine. This is because on BSD Unix systems, attempting to read a
  3382. pipe returns however much happens to be in the pipe, even if it is
  3383. less than was requested. If this option were not enabled, @command{tar}
  3384. would fail as soon as it read an incomplete record from the pipe.
  3385. If you're not sure of the blocking factor of an archive, you can
  3386. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3387. @option{--blocking-factor=@var{512-size}} (@option{-b
  3388. @var{512-size}}), using a blocking factor larger than what the archive
  3389. uses. This lets you avoid having to determine the blocking factor
  3390. of an archive. @xref{Blocking Factor}.
  3391. @menu
  3392. * read full records::
  3393. * Ignore Zeros::
  3394. @end menu
  3395. @node read full records
  3396. @unnumberedsubsubsec Reading Full Records
  3397. @FIXME{need sentence or so of intro here}
  3398. @table @option
  3399. @opindex read-full-records
  3400. @item --read-full-records
  3401. @item -B
  3402. Use in conjunction with @option{--extract} (@option{--get},
  3403. @option{-x}) to read an archive which contains incomplete records, or
  3404. one which has a blocking factor less than the one specified.
  3405. @end table
  3406. @node Ignore Zeros
  3407. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3408. @cindex End-of-archive blocks, ignoring
  3409. @cindex Ignoring end-of-archive blocks
  3410. @opindex ignore-zeros
  3411. Normally, @command{tar} stops reading when it encounters a block of zeros
  3412. between file entries (which usually indicates the end of the archive).
  3413. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3414. completely read an archive which contains a block of zeros before the
  3415. end (i.e., a damaged archive, or one that was created by concatenating
  3416. several archives together).
  3417. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3418. versions of @command{tar} write garbage after the end-of-archive entry,
  3419. since that part of the media is never supposed to be read. @GNUTAR{}
  3420. does not write after the end of an archive, but seeks to
  3421. maintain compatiblity among archiving utilities.
  3422. @table @option
  3423. @item --ignore-zeros
  3424. @itemx -i
  3425. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3426. encountered while reading an archive. Use in conjunction with
  3427. @option{--extract} or @option{--list}.
  3428. @end table
  3429. @node Writing
  3430. @subsection Changing How @command{tar} Writes Files
  3431. @UNREVISED
  3432. @FIXME{Introductory paragraph}
  3433. @menu
  3434. * Dealing with Old Files::
  3435. * Overwrite Old Files::
  3436. * Keep Old Files::
  3437. * Keep Newer Files::
  3438. * Unlink First::
  3439. * Recursive Unlink::
  3440. * Data Modification Times::
  3441. * Setting Access Permissions::
  3442. * Directory Modification Times and Permissions::
  3443. * Writing to Standard Output::
  3444. * Writing to an External Program::
  3445. * remove files::
  3446. @end menu
  3447. @node Dealing with Old Files
  3448. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3449. @opindex overwrite-dir, introduced
  3450. When extracting files, if @command{tar} discovers that the extracted
  3451. file already exists, it normally replaces the file by removing it before
  3452. extracting it, to prevent confusion in the presence of hard or symbolic
  3453. links. (If the existing file is a symbolic link, it is removed, not
  3454. followed.) However, if a directory cannot be removed because it is
  3455. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3456. permission, etc.). The @option{--overwrite-dir} option enables this
  3457. default behavior. To be more cautious and preserve the metadata of
  3458. such a directory, use the @option{--no-overwrite-dir} option.
  3459. @cindex Overwriting old files, prevention
  3460. @opindex keep-old-files, introduced
  3461. To be even more cautious and prevent existing files from being replaced, use
  3462. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3463. to replace or update a file that already exists, i.e., a file with the
  3464. same name as an archive member prevents extraction of that archive
  3465. member. Instead, it reports an error.
  3466. @opindex overwrite, introduced
  3467. To be more aggressive about altering existing files, use the
  3468. @option{--overwrite} option. It causes @command{tar} to overwrite
  3469. existing files and to follow existing symbolic links when extracting.
  3470. @cindex Protecting old files
  3471. Some people argue that @GNUTAR{} should not hesitate
  3472. to overwrite files with other files when extracting. When extracting
  3473. a @command{tar} archive, they expect to see a faithful copy of the
  3474. state of the file system when the archive was created. It is debatable
  3475. that this would always be a proper behavior. For example, suppose one
  3476. has an archive in which @file{usr/local} is a link to
  3477. @file{usr/local2}. Since then, maybe the site removed the link and
  3478. renamed the whole hierarchy from @file{/usr/local2} to
  3479. @file{/usr/local}. Such things happen all the time. I guess it would
  3480. not be welcome at all that @GNUTAR{} removes the
  3481. whole hierarchy just to make room for the link to be reinstated
  3482. (unless it @emph{also} simultaneously restores the full
  3483. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3484. able to remove a whole hierarchy to reestablish a symbolic link, for
  3485. example, but @emph{only if} @option{--recursive-unlink} is specified
  3486. to allow this behavior. In any case, single files are silently
  3487. removed.
  3488. @opindex unlink-first, introduced
  3489. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3490. some cases by causing @command{tar} to remove files unconditionally
  3491. before extracting them.
  3492. @node Overwrite Old Files
  3493. @unnumberedsubsubsec Overwrite Old Files
  3494. @table @option
  3495. @opindex overwrite
  3496. @item --overwrite
  3497. Overwrite existing files and directory metadata when extracting files
  3498. from an archive.
  3499. This causes @command{tar} to write extracted files into the file system without
  3500. regard to the files already on the system; i.e., files with the same
  3501. names as archive members are overwritten when the archive is extracted.
  3502. It also causes @command{tar} to extract the ownership, permissions,
  3503. and time stamps onto any preexisting files or directories.
  3504. If the name of a corresponding file name is a symbolic link, the file
  3505. pointed to by the symbolic link will be overwritten instead of the
  3506. symbolic link itself (if this is possible). Moreover, special devices,
  3507. empty directories and even symbolic links are automatically removed if
  3508. they are in the way of extraction.
  3509. Be careful when using the @option{--overwrite} option, particularly when
  3510. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3511. can change the contents, ownership or permissions of any file on your
  3512. system. Also, many systems do not take kindly to overwriting files that
  3513. are currently being executed.
  3514. @opindex overwrite-dir
  3515. @item --overwrite-dir
  3516. Overwrite the metadata of directories when extracting files from an
  3517. archive, but remove other files before extracting.
  3518. @end table
  3519. @node Keep Old Files
  3520. @unnumberedsubsubsec Keep Old Files
  3521. @table @option
  3522. @opindex keep-old-files
  3523. @item --keep-old-files
  3524. @itemx -k
  3525. Do not replace existing files from archive. The
  3526. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3527. from replacing existing files with files with the same name from the
  3528. archive. The @option{--keep-old-files} option is meaningless with
  3529. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3530. files in the file system during extraction.
  3531. @end table
  3532. @node Keep Newer Files
  3533. @unnumberedsubsubsec Keep Newer Files
  3534. @table @option
  3535. @opindex keep-newer-files
  3536. @item --keep-newer-files
  3537. Do not replace existing files that are newer than their archive
  3538. copies. This option is meaningless with @option{--list} (@option{-t}).
  3539. @end table
  3540. @node Unlink First
  3541. @unnumberedsubsubsec Unlink First
  3542. @table @option
  3543. @opindex unlink-first
  3544. @item --unlink-first
  3545. @itemx -U
  3546. Remove files before extracting over them.
  3547. This can make @command{tar} run a bit faster if you know in advance
  3548. that the extracted files all need to be removed. Normally this option
  3549. slows @command{tar} down slightly, so it is disabled by default.
  3550. @end table
  3551. @node Recursive Unlink
  3552. @unnumberedsubsubsec Recursive Unlink
  3553. @table @option
  3554. @opindex recursive-unlink
  3555. @item --recursive-unlink
  3556. When this option is specified, try removing files and directory hierarchies
  3557. before extracting over them. @emph{This is a dangerous option!}
  3558. @end table
  3559. If you specify the @option{--recursive-unlink} option,
  3560. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3561. as far as current permissions will allow it. This could include removal
  3562. of the contents of a full directory hierarchy.
  3563. @node Data Modification Times
  3564. @unnumberedsubsubsec Setting Data Modification Times
  3565. @cindex Data modification times of extracted files
  3566. @cindex Modification times of extracted files
  3567. Normally, @command{tar} sets the data modification times of extracted
  3568. files to the corresponding times recorded for the files in the archive, but
  3569. limits the permissions of extracted files by the current @code{umask}
  3570. setting.
  3571. To set the data modification times of extracted files to the time when
  3572. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3573. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3574. @table @option
  3575. @opindex touch
  3576. @item --touch
  3577. @itemx -m
  3578. Sets the data modification time of extracted archive members to the time
  3579. they were extracted, not the time recorded for them in the archive.
  3580. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3581. @end table
  3582. @node Setting Access Permissions
  3583. @unnumberedsubsubsec Setting Access Permissions
  3584. @cindex Permissions of extracted files
  3585. @cindex Modes of extracted files
  3586. To set the modes (access permissions) of extracted files to those
  3587. recorded for those files in the archive, use @option{--same-permissions}
  3588. in conjunction with the @option{--extract} (@option{--get},
  3589. @option{-x}) operation. @FIXME{Should be aliased to ignore-umask.}
  3590. @table @option
  3591. @opindex preserve-permission
  3592. @opindex same-permission
  3593. @item --preserve-permission
  3594. @itemx --same-permission
  3595. @c @itemx --ignore-umask
  3596. @itemx -p
  3597. Set modes of extracted archive members to those recorded in the
  3598. archive, instead of current umask settings. Use in conjunction with
  3599. @option{--extract} (@option{--get}, @option{-x}).
  3600. @end table
  3601. @node Directory Modification Times and Permissions
  3602. @unnumberedsubsubsec Directory Modification Times and Permissions
  3603. After sucessfully extracting a file member, @GNUTAR{} normally
  3604. restores its permissions and modification times, as described in the
  3605. previous sections. This cannot be done for directories, because
  3606. after extracting a directory @command{tar} will almost certainly
  3607. extract files into that directory and this will cause the directory
  3608. modification time to be updated. Moreover, restoring that directory
  3609. permissions may not permit file creation within it. Thus, restoring
  3610. directory permissions and modification times must be delayed at least
  3611. until all files have been extracted into that directory. @GNUTAR{}
  3612. restores directories using the following approach.
  3613. The extracted directories are created with the mode specified in the
  3614. archive, as modified by the umask of the user, which gives sufficient
  3615. permissions to allow file creation. The meta-information about the
  3616. directory is recorded in the temporary list of directories. When
  3617. preparing to extract next archive member, @GNUTAR{} checks if the
  3618. directory prefix of this file contains the remembered directory. If
  3619. it does not, the program assumes that all files have been extracted
  3620. into that directory, restores its modification time and permissions
  3621. and removes its entry from the internal list. This approach allows
  3622. to correctly restore directory meta-information in the majority of
  3623. cases, while keeping memory requirements sufficiently small. It is
  3624. based on the fact, that most @command{tar} archives use the predefined
  3625. order of members: first the directory, then all the files and
  3626. subdirectories in that directory.
  3627. However, this is not always true. The most important exception are
  3628. incremental archives (@pxref{Incremental Dumps}). The member order in
  3629. an incremental archive is reversed: first all directory members are
  3630. stored, followed by other (non-directory) members. So, when extracting
  3631. from incremental archives, @GNUTAR{} alters the above procedure. It
  3632. remebers all restored directories, and restores their meta-data
  3633. only after the entire archive has been processed. Notice, that you do
  3634. not need to specity any special options for that, as @GNUTAR{}
  3635. automatically detects archives in incremental format.
  3636. There may be cases, when such processing is required for normal archives
  3637. too. Consider the following example:
  3638. @smallexample
  3639. @group
  3640. $ @kbd{tar --no-recursion -cvf archive \
  3641. foo foo/file1 bar bar/file foo/file2}
  3642. foo/
  3643. foo/file1
  3644. bar/
  3645. bar/file
  3646. foo/file2
  3647. @end group
  3648. @end smallexample
  3649. During the normal operation, after encountering @file{bar}
  3650. @GNUTAR{} will assume that all files from the directory @file{foo}
  3651. were already extracted and will therefore restore its timestamp and
  3652. permission bits. However, after extracting @file{foo/file2} the
  3653. directory timestamp will be offset again.
  3654. To correctly restore directory meta-information in such cases, use
  3655. @option{delay-directory-restore} command line option:
  3656. @table @option
  3657. @opindex delay-directory-restore
  3658. @item --delay-directory-restore
  3659. Delays restoring of the modification times and permissions of extracted
  3660. directories until the end of extraction. This way, correct
  3661. meta-information is restored even if the archive has unusual member
  3662. ordering.
  3663. @opindex no-delay-directory-restore
  3664. @item --no-delay-directory-restore
  3665. Cancel the effect of the previous @option{--delay-directory-restore}.
  3666. Use this option if you have used @option{--delay-directory-restore} in
  3667. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  3668. temporarily disable it.
  3669. @end table
  3670. @node Writing to Standard Output
  3671. @unnumberedsubsubsec Writing to Standard Output
  3672. @cindex Writing extracted files to standard output
  3673. @cindex Standard output, writing extracted files to
  3674. To write the extracted files to the standard output, instead of
  3675. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3676. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3677. extracting files to send them through a pipe, and do not need to
  3678. preserve them in the file system. If you extract multiple members,
  3679. they appear on standard output concatenated, in the order they are
  3680. found in the archive.
  3681. @table @option
  3682. @opindex to-stdout
  3683. @item --to-stdout
  3684. @itemx -O
  3685. Writes files to the standard output. Use only in conjunction with
  3686. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3687. used, instead of creating the files specified, @command{tar} writes
  3688. the contents of the files extracted to its standard output. This may
  3689. be useful if you are only extracting the files in order to send them
  3690. through a pipe. This option is meaningless with @option{--list}
  3691. (@option{-t}).
  3692. @end table
  3693. This can be useful, for example, if you have a tar archive containing
  3694. a big file and don't want to store the file on disk before processing
  3695. it. You can use a command like this:
  3696. @smallexample
  3697. tar -xOzf foo.tgz bigfile | process
  3698. @end smallexample
  3699. or even like this if you want to process the concatenation of the files:
  3700. @smallexample
  3701. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3702. @end smallexample
  3703. Hovewer, @option{--to-command} may be more convenient for use with
  3704. multiple files. See the next section.
  3705. @node Writing to an External Program
  3706. @unnumberedsubsubsec Writing to an External Program
  3707. You can instruct @command{tar} to send the contents of each extracted
  3708. file to the standard input of an external program:
  3709. @table @option
  3710. @opindex to-command
  3711. @item --to-command=@var{command}
  3712. Extract files and pipe their contents to the standard input of
  3713. @var{command}. When this option is used, instead of creating the
  3714. files specified, @command{tar} invokes @var{command} and pipes the
  3715. contents of the files to its standard output. @var{Command} may
  3716. contain command line arguments. The program is executed via
  3717. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3718. extracted. Non-regular files (directories, etc.) are ignored when this
  3719. option is used.
  3720. @end table
  3721. The command can obtain the information about the file it processes
  3722. from the following environment variables:
  3723. @table @var
  3724. @vrindex TAR_FILETYPE, to-command environment
  3725. @item TAR_FILETYPE
  3726. Type of the file. It is a single letter with the following meaning:
  3727. @multitable @columnfractions 0.10 0.90
  3728. @item f @tab Regular file
  3729. @item d @tab Directory
  3730. @item l @tab Symbolic link
  3731. @item h @tab Hard link
  3732. @item b @tab Block device
  3733. @item c @tab Character device
  3734. @end multitable
  3735. Currently only regular files are supported.
  3736. @vrindex TAR_MODE, to-command environment
  3737. @item TAR_MODE
  3738. File mode, an octal number.
  3739. @vrindex TAR_FILENAME, to-command environment
  3740. @item TAR_FILENAME
  3741. The name of the file.
  3742. @vrindex TAR_REALNAME, to-command environment
  3743. @item TAR_REALNAME
  3744. Name of the file as stored in the archive.
  3745. @vrindex TAR_UNAME, to-command environment
  3746. @item TAR_UNAME
  3747. Name of the file owner.
  3748. @vrindex TAR_GNAME, to-command environment
  3749. @item TAR_GNAME
  3750. Name of the file owner group.
  3751. @vrindex TAR_ATIME, to-command environment
  3752. @item TAR_ATIME
  3753. Time of last access. It is a decimal number, representing seconds
  3754. since the epoch. If the archive provides times with nanosecond
  3755. precision, the nanoseconds are appended to the timestamp after a
  3756. decimal point.
  3757. @vrindex TAR_MTIME, to-command environment
  3758. @item TAR_MTIME
  3759. Time of last modification.
  3760. @vrindex TAR_CTIME, to-command environment
  3761. @item TAR_CTIME
  3762. Time of last status change.
  3763. @vrindex TAR_SIZE, to-command environment
  3764. @item TAR_SIZE
  3765. Size of the file.
  3766. @vrindex TAR_UID, to-command environment
  3767. @item TAR_UID
  3768. UID of the file owner.
  3769. @vrindex TAR_GID, to-command environment
  3770. @item TAR_GID
  3771. GID of the file owner.
  3772. @end table
  3773. In addition to these variables, @env{TAR_VERSION} contains the
  3774. @GNUTAR{} version number.
  3775. If @var{command} exits with a non-0 status, @command{tar} will print
  3776. an error message similar to the following:
  3777. @smallexample
  3778. tar: 2345: Child returned status 1
  3779. @end smallexample
  3780. Here, @samp{2345} is the PID of the finished process.
  3781. If this behavior is not wanted, use @option{--ignore-command-error}:
  3782. @table @option
  3783. @opindex ignore-command-error
  3784. @item --ignore-command-error
  3785. Ignore exit codes of subprocesses. Notice that if the program
  3786. exits on signal or otherwise terminates abnormally, the error message
  3787. will be printed even if this option is used.
  3788. @opindex no-ignore-command-error
  3789. @item --no-ignore-command-error
  3790. Cancel the effect of any previous @option{--ignore-command-error}
  3791. option. This option is useful if you have set
  3792. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3793. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3794. @end table
  3795. @node remove files
  3796. @unnumberedsubsubsec Removing Files
  3797. @FIXME{the various macros in the front of the manual think that this
  3798. option goes in this section. i have no idea; i only know it's nowhere
  3799. else in the book...}
  3800. @table @option
  3801. @opindex remove-files
  3802. @item --remove-files
  3803. Remove files after adding them to the archive.
  3804. @end table
  3805. @node Scarce
  3806. @subsection Coping with Scarce Resources
  3807. @UNREVISED
  3808. @cindex Small memory
  3809. @cindex Running out of space
  3810. @menu
  3811. * Starting File::
  3812. * Same Order::
  3813. @end menu
  3814. @node Starting File
  3815. @unnumberedsubsubsec Starting File
  3816. @table @option
  3817. @opindex starting-file
  3818. @item --starting-file=@var{name}
  3819. @itemx -K @var{name}
  3820. Starts an operation in the middle of an archive. Use in conjunction
  3821. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3822. @end table
  3823. @cindex Middle of the archive, starting in the
  3824. If a previous attempt to extract files failed due to lack of disk
  3825. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3826. @var{name}}) to start extracting only after member @var{name} of the
  3827. archive. This assumes, of course, that there is now free space, or
  3828. that you are now extracting into a different file system. (You could
  3829. also choose to suspend @command{tar}, remove unnecessary files from
  3830. the file system, and then restart the same @command{tar} operation.
  3831. In this case, @option{--starting-file} is not necessary.
  3832. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  3833. @node Same Order
  3834. @unnumberedsubsubsec Same Order
  3835. @table @option
  3836. @cindex Large lists of file names on small machines
  3837. @opindex same-order
  3838. @opindex preserve-order
  3839. @item --same-order
  3840. @itemx --preserve-order
  3841. @itemx -s
  3842. To process large lists of file names on machines with small amounts of
  3843. memory. Use in conjunction with @option{--compare} (@option{--diff},
  3844. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  3845. (@option{--get}, @option{-x}).
  3846. @end table
  3847. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  3848. names to be listed or extracted is sorted in the same order as the
  3849. files in the archive. This allows a large list of names to be used,
  3850. even on a small machine that would not otherwise be able to hold all
  3851. the names in memory at the same time. Such a sorted list can easily be
  3852. created by running @samp{tar -t} on the archive and editing its output.
  3853. This option is probably never needed on modern computer systems.
  3854. @node backup
  3855. @section Backup options
  3856. @cindex backup options
  3857. @GNUTAR{} offers options for making backups of files
  3858. before writing new versions. These options control the details of
  3859. these backups. They may apply to the archive itself before it is
  3860. created or rewritten, as well as individual extracted members. Other
  3861. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3862. and @command{mv}, for example) offer similar options.
  3863. Backup options may prove unexpectedly useful when extracting archives
  3864. containing many members having identical name, or when extracting archives
  3865. on systems having file name limitations, making different members appear
  3866. has having similar names through the side-effect of name truncation.
  3867. (This is true only if we have a good scheme for truncated backup names,
  3868. which I'm not sure at all: I suspect work is needed in this area.)
  3869. When any existing file is backed up before being overwritten by extraction,
  3870. then clashing files are automatically be renamed to be unique, and the
  3871. true name is kept for only the last file of a series of clashing files.
  3872. By using verbose mode, users may track exactly what happens.
  3873. At the detail level, some decisions are still experimental, and may
  3874. change in the future, we are waiting comments from our users. So, please
  3875. do not learn to depend blindly on the details of the backup features.
  3876. For example, currently, directories themselves are never renamed through
  3877. using these options, so, extracting a file over a directory still has
  3878. good chances to fail. Also, backup options apply to created archives,
  3879. not only to extracted members. For created archives, backups will not
  3880. be attempted when the archive is a block or character device, or when it
  3881. refers to a remote file.
  3882. For the sake of simplicity and efficiency, backups are made by renaming old
  3883. files prior to creation or extraction, and not by copying. The original
  3884. name is restored if the file creation fails. If a failure occurs after a
  3885. partial extraction of a file, both the backup and the partially extracted
  3886. file are kept.
  3887. @table @samp
  3888. @item --backup[=@var{method}]
  3889. @opindex backup
  3890. @vindex VERSION_CONTROL
  3891. @cindex backups
  3892. Back up files that are about to be overwritten or removed.
  3893. Without this option, the original versions are destroyed.
  3894. Use @var{method} to determine the type of backups made.
  3895. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3896. environment variable. And if @env{VERSION_CONTROL} is not set,
  3897. use the @samp{existing} method.
  3898. @vindex version-control @r{Emacs variable}
  3899. This option corresponds to the Emacs variable @samp{version-control};
  3900. the same values for @var{method} are accepted as in Emacs. This option
  3901. also allows more descriptive names. The valid @var{method}s are:
  3902. @table @samp
  3903. @item t
  3904. @itemx numbered
  3905. @cindex numbered @r{backup method}
  3906. Always make numbered backups.
  3907. @item nil
  3908. @itemx existing
  3909. @cindex existing @r{backup method}
  3910. Make numbered backups of files that already have them, simple backups
  3911. of the others.
  3912. @item never
  3913. @itemx simple
  3914. @cindex simple @r{backup method}
  3915. Always make simple backups.
  3916. @end table
  3917. @item --suffix=@var{suffix}
  3918. @opindex suffix
  3919. @cindex backup suffix
  3920. @vindex SIMPLE_BACKUP_SUFFIX
  3921. Append @var{suffix} to each backup file made with @option{--backup}. If this
  3922. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3923. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3924. set, the default is @samp{~}, just as in Emacs.
  3925. @end table
  3926. Some people express the desire to @emph{always} use the @option{--backup}
  3927. option, by defining some kind of alias or script. This is not as easy
  3928. as one may think, due to the fact that old style options should appear first
  3929. and consume arguments a bit unpredictably for an alias or script. But,
  3930. if you are ready to give up using old style options, you may resort to
  3931. using something like (a Bourne shell function here):
  3932. @smallexample
  3933. tar () @{ /usr/local/bin/tar --backup $*; @}
  3934. @end smallexample
  3935. @node Applications
  3936. @section Notable @command{tar} Usages
  3937. @UNREVISED
  3938. @FIXME{Using Unix file linking capability to recreate directory
  3939. structures---linking files into one subdirectory and then
  3940. @command{tar}ring that directory.}
  3941. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3942. @findex uuencode
  3943. You can easily use archive files to transport a group of files from
  3944. one system to another: put all relevant files into an archive on one
  3945. computer system, transfer the archive to another system, and extract
  3946. the contents there. The basic transfer medium might be magnetic tape,
  3947. Internet FTP, or even electronic mail (though you must encode the
  3948. archive with @command{uuencode} in order to transport it properly by
  3949. mail). Both machines do not have to use the same operating system, as
  3950. long as they both support the @command{tar} program.
  3951. For example, here is how you might copy a directory's contents from
  3952. one disk to another, while preserving the dates, modes, owners and
  3953. link-structure of all the files therein. In this case, the transfer
  3954. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3955. @smallexample
  3956. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
  3957. @end smallexample
  3958. @noindent
  3959. You can avoid subshells by using @option{-C} option:
  3960. @smallexample
  3961. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xf -}
  3962. @end smallexample
  3963. @noindent
  3964. The command also works using short option forms:
  3965. @smallexample
  3966. $ @kbd{(cd sourcedir; tar --create --file=- . ) \
  3967. | (cd targetdir; tar --extract --file=-)}
  3968. # Or:
  3969. $ @kbd{tar --directory sourcedir --create --file=- . ) \
  3970. | tar --directory targetdir --extract --file=-}
  3971. @end smallexample
  3972. @noindent
  3973. This is one of the easiest methods to transfer a @command{tar} archive.
  3974. @node looking ahead
  3975. @section Looking Ahead: The Rest of this Manual
  3976. You have now seen how to use all eight of the operations available to
  3977. @command{tar}, and a number of the possible options. The next chapter
  3978. explains how to choose and change file and archive names, how to use
  3979. files to store names of other files which you can then call as
  3980. arguments to @command{tar} (this can help you save time if you expect to
  3981. archive the same list of files a number of times), and so forth.
  3982. @FIXME{in case it's not obvious, i'm making this up in some sense
  3983. based on my limited memory of what the next chapter *really* does. i
  3984. just wanted to flesh out this final section a little bit so i'd
  3985. remember to stick it in here. :-)}
  3986. If there are too many files to conveniently list on the command line,
  3987. you can list the names in a file, and @command{tar} will read that file.
  3988. @xref{files}.
  3989. There are various ways of causing @command{tar} to skip over some files,
  3990. and not archive them. @xref{Choosing}.
  3991. @node Backups
  3992. @chapter Performing Backups and Restoring Files
  3993. @UNREVISED
  3994. @GNUTAR{} is distributed along with the scripts
  3995. which the Free Software Foundation uses for performing backups. There
  3996. is no corresponding scripts available yet for doing restoration of
  3997. files. Even if there is a good chance those scripts may be satisfying
  3998. to you, they are not the only scripts or methods available for doing
  3999. backups and restore. You may well create your own, or use more
  4000. sophisticated packages dedicated to that purpose.
  4001. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  4002. Automatic Network Disk Archiver), a backup system developed by James
  4003. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  4004. This is free software, and it is available at these places:
  4005. @smallexample
  4006. http://www.cs.umd.edu/projects/amanda/amanda.html
  4007. ftp://ftp.cs.umd.edu/pub/amanda
  4008. @end smallexample
  4009. @FIXME{
  4010. Here is a possible plan for a future documentation about the backuping
  4011. scripts which are provided within the @GNUTAR{}
  4012. distribution.
  4013. @itemize @bullet
  4014. @item dumps
  4015. @itemize @minus
  4016. @item what are dumps
  4017. @item different levels of dumps
  4018. @itemize +
  4019. @item full dump = dump everything
  4020. @item level 1, level 2 dumps etc
  4021. A level @var{n} dump dumps everything changed since the last level
  4022. @var{n}-1 dump (?)
  4023. @end itemize
  4024. @item how to use scripts for dumps (ie, the concept)
  4025. @itemize +
  4026. @item scripts to run after editing backup specs (details)
  4027. @end itemize
  4028. @item Backup Specs, what is it.
  4029. @itemize +
  4030. @item how to customize
  4031. @item actual text of script [/sp/dump/backup-specs]
  4032. @end itemize
  4033. @item Problems
  4034. @itemize +
  4035. @item rsh doesn't work
  4036. @item rtape isn't installed
  4037. @item (others?)
  4038. @end itemize
  4039. @item the @option{--incremental} option of tar
  4040. @item tapes
  4041. @itemize +
  4042. @item write protection
  4043. @item types of media, different sizes and types, useful for different things
  4044. @item files and tape marks
  4045. one tape mark between files, two at end.
  4046. @item positioning the tape
  4047. MT writes two at end of write,
  4048. backspaces over one when writing again.
  4049. @end itemize
  4050. @end itemize
  4051. @end itemize
  4052. }
  4053. This chapter documents both the provided shell scripts and @command{tar}
  4054. options which are more specific to usage as a backup tool.
  4055. To @dfn{back up} a file system means to create archives that contain
  4056. all the files in that file system. Those archives can then be used to
  4057. restore any or all of those files (for instance if a disk crashes or a
  4058. file is accidentally deleted). File system @dfn{backups} are also
  4059. called @dfn{dumps}.
  4060. @menu
  4061. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4062. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4063. * Backup Levels:: Levels of Backups
  4064. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4065. * Scripted Backups:: Using the Backup Scripts
  4066. * Scripted Restoration:: Using the Restore Script
  4067. @end menu
  4068. @node Full Dumps
  4069. @section Using @command{tar} to Perform Full Dumps
  4070. @UNREVISED
  4071. @cindex full dumps
  4072. @cindex dumps, full
  4073. @cindex corrupted archives
  4074. Full dumps should only be made when no other people or programs
  4075. are modifying files in the file system. If files are modified while
  4076. @command{tar} is making the backup, they may not be stored properly in
  4077. the archive, in which case you won't be able to restore them if you
  4078. have to. (Files not being modified are written with no trouble, and do
  4079. not corrupt the entire archive.)
  4080. You will want to use the @option{--label=@var{archive-label}}
  4081. (@option{-V @var{archive-label}}) option to give the archive a
  4082. volume label, so you can tell what this archive is even if the label
  4083. falls off the tape, or anything like that.
  4084. Unless the file system you are dumping is guaranteed to fit on
  4085. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4086. Make sure you have enough tapes on hand to complete the backup.
  4087. If you want to dump each file system separately you will need to use
  4088. the @option{--one-file-system} option to prevent
  4089. @command{tar} from crossing file system boundaries when storing
  4090. (sub)directories.
  4091. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4092. option is not needed, since this is a complete copy of everything in
  4093. the file system, and a full restore from this backup would only be
  4094. done onto a completely
  4095. empty disk.
  4096. Unless you are in a hurry, and trust the @command{tar} program (and your
  4097. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4098. option, to make sure your files really made it onto the dump properly.
  4099. This will also detect cases where the file was modified while (or just
  4100. after) it was being archived. Not all media (notably cartridge tapes)
  4101. are capable of being verified, unfortunately.
  4102. @node Incremental Dumps
  4103. @section Using @command{tar} to Perform Incremental Dumps
  4104. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4105. stores additional metadata so that exact state of the file system
  4106. can be restored when extracting the archive.
  4107. @GNUTAR{} currently offers two options for handling incremental
  4108. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4109. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4110. @opindex listed-incremental
  4111. The option @option{--listed-incremental} instructs tar to operate on
  4112. an incremental archive with additional metadata stored in a standalone
  4113. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4114. determine which files have been changed, added or deleted since the
  4115. last backup, so that the next incremental backup will contain only
  4116. modified files. The name of the snapshot file is given as an argument
  4117. to the option:
  4118. @table @option
  4119. @item --listed-incremental=@var{file}
  4120. @itemx -g @var{file}
  4121. Handle incremental backups with snapshot data in @var{file}.
  4122. @end table
  4123. To create an incremental backup, you would use
  4124. @option{--listed-incremental} together with @option{--create}
  4125. (@pxref{create}). For example:
  4126. @smallexample
  4127. $ @kbd{tar --create \
  4128. --file=archive.1.tar \
  4129. --listed-incremental=/var/log/usr.snar \
  4130. /usr}
  4131. @end smallexample
  4132. This will create in @file{archive.1.tar} an incremental backup of
  4133. the @file{/usr} file system, storing additional metadata in the file
  4134. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4135. created. The created archive will then be a @dfn{level 0 backup};
  4136. please see the next section for more on backup levels.
  4137. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4138. determines which files are modified. In this case only these files will be
  4139. stored in the archive. Suppose, for example, that after running the
  4140. above command, you delete file @file{/usr/doc/old} and create
  4141. directory @file{/usr/local/db} with the following contents:
  4142. @smallexample
  4143. $ @kbd{ls /usr/local/db}
  4144. /usr/local/db/data
  4145. /usr/local/db/index
  4146. @end smallexample
  4147. Some time later you create another incremental backup. You will
  4148. then see:
  4149. @smallexample
  4150. $ @kbd{tar --create \
  4151. --file=archive.2.tar \
  4152. --listed-incremental=/var/log/usr.snar \
  4153. /usr}
  4154. tar: usr/local/db: Directory is new
  4155. usr/local/db/
  4156. usr/local/db/data
  4157. usr/local/db/index
  4158. @end smallexample
  4159. @noindent
  4160. The created archive @file{archive.2.tar} will contain only these
  4161. three members. This archive is called a @dfn{level 1 backup}. Notice
  4162. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4163. you plan to create more @samp{level 1} backups, it is necessary to
  4164. create a working copy of the snapshot file before running
  4165. @command{tar}. The above example will then be modified as follows:
  4166. @smallexample
  4167. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4168. $ @kbd{tar --create \
  4169. --file=archive.2.tar \
  4170. --listed-incremental=/var/log/usr.snar-1 \
  4171. /usr}
  4172. @end smallexample
  4173. Incremental dumps depend crucially on time stamps, so the results are
  4174. unreliable if you modify a file's time stamps during dumping (e.g.,
  4175. with the @option{--atime-preserve=replace} option), or if you set the clock
  4176. backwards.
  4177. Metadata stored in snapshot files include device numbers, which,
  4178. obviously is supposed to be a non-volatile value. However, it turns
  4179. out that NFS devices have undependable values when an automounter
  4180. gets in the picture. This can lead to a great deal of spurious
  4181. redumping in incremental dumps, so it is somewhat useless to compare
  4182. two NFS devices numbers over time. The solution implemented currently
  4183. is to considers all NFS devices as being equal when it comes to
  4184. comparing directories; this is fairly gross, but there does not seem
  4185. to be a better way to go.
  4186. Note that incremental archives use @command{tar} extensions and may
  4187. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4188. @opindex listed-incremental, using with @option{--extract}
  4189. @opindex extract, using with @option{--listed-incremental}
  4190. To extract from the incremental dumps, use
  4191. @option{--listed-incremental} together with @option{--extract}
  4192. option (@pxref{extracting files}). In this case, @command{tar} does
  4193. not need to access snapshot file, since all the data necessary for
  4194. extraction are stored in the archive itself. So, when extracting, you
  4195. can give whatever argument to @option{--listed-incremental}, the usual
  4196. practice is to use @option{--listed-incremental=/dev/null}.
  4197. Alternatively, you can use @option{--incremental}, which needs no
  4198. arguments. In general, @option{--incremental} (@option{-G}) can be
  4199. used as a shortcut for @option{--listed-incremental} when listing or
  4200. extracting incremental backups (for more information, regarding this
  4201. option, @pxref{incremental-op}).
  4202. When extracting from the incremental backup @GNUTAR{} attempts to
  4203. restore the exact state the file system had when the archive was
  4204. created. In particular, it will @emph{delete} those files in the file
  4205. system that did not exist in their directories when the archive was
  4206. created. If you have created several levels of incremental files,
  4207. then in order to restore the exact contents the file system had when
  4208. the last level was created, you will need to restore from all backups
  4209. in turn. Continuing our example, to restore the state of @file{/usr}
  4210. file system, one would do@footnote{Notice, that since both archives
  4211. were created withouth @option{-P} option (@pxref{absolute}), these
  4212. commands should be run from the root file system.}:
  4213. @smallexample
  4214. $ @kbd{tar --extract \
  4215. --listed-incremental=/dev/null \
  4216. --file archive.1.tar}
  4217. $ @kbd{tar --extract \
  4218. --listed-incremental=/dev/null \
  4219. --file archive.2.tar}
  4220. @end smallexample
  4221. To list the contents of an incremental archive, use @option{--list}
  4222. (@pxref{list}), as usual. To obtain more information about the
  4223. archive, use @option{--listed-incremental} or @option{--incremental}
  4224. combined with two @option{--verbose} options@footnote{Two
  4225. @option{--verbose} options were selected to avoid breaking usual
  4226. verbose listing output (@option{--list --verbose}) when using in
  4227. scripts.
  4228. @opindex incremental, using with @option{--list}
  4229. @opindex listed-incremental, using with @option{--list}
  4230. @opindex list, using with @option{--incremental}
  4231. @opindex list, using with @option{--listed-incremental}
  4232. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4233. contents of the DUMPDIR header (with terminating nulls) when
  4234. @option{--incremental} or @option{--listed-incremental} option was
  4235. given, no matter what the verbosity level. This behavior, and,
  4236. especially, the binary output it produced were considered incovenient
  4237. and were changed in version 1.16}:
  4238. @smallexample
  4239. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4240. @end smallexample
  4241. This command will print, for each directory in the archive, the list
  4242. of files in that directory at the time the archive was created. This
  4243. information is put out in a format which is both human-readable and
  4244. unambiguous for a program: each file name is printed as
  4245. @smallexample
  4246. @var{x} @var{file}
  4247. @end smallexample
  4248. @noindent
  4249. where @var{x} is a letter describing the status of the file: @samp{Y}
  4250. if the file is present in the archive, @samp{N} if the file is not
  4251. included in the archive, or a @samp{D} if the file is a directory (and
  4252. is included in the archive).@FIXME-xref{dumpdir format}. Each such
  4253. line is terminated by a newline character. The last line is followed
  4254. by an additional newline to indicate the end of the data.
  4255. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4256. gives the same behavior as @option{--listed-incremental} when used
  4257. with @option{--list} and @option{--extract} options. When used with
  4258. @option{--create} option, it creates an incremental archive without
  4259. creating snapshot file. Thus, it is impossible to create several
  4260. levels of incremental backups with @option{--incremental} option.
  4261. @node Backup Levels
  4262. @section Levels of Backups
  4263. An archive containing all the files in the file system is called a
  4264. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4265. creating a full dump every day. This strategy, however, would waste a
  4266. substantial amount of archive media and user time, as unchanged files
  4267. are daily re-archived.
  4268. It is more efficient to do a full dump only occasionally. To back up
  4269. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4270. one} dump archives all the files that have changed since the last full
  4271. dump.
  4272. A typical dump strategy would be to perform a full dump once a week,
  4273. and a level one dump once a day. This means some versions of files
  4274. will in fact be archived more than once, but this dump strategy makes
  4275. it possible to restore a file system to within one day of accuracy by
  4276. only extracting two archives---the last weekly (full) dump and the
  4277. last daily (level one) dump. The only information lost would be in
  4278. files changed or created since the last daily backup. (Doing dumps
  4279. more than once a day is usually not worth the trouble).
  4280. @GNUTAR{} comes with scripts you can use to do full
  4281. and level-one (actually, even level-two and so on) dumps. Using
  4282. scripts (shell programs) to perform backups and restoration is a
  4283. convenient and reliable alternative to typing out file name lists
  4284. and @command{tar} commands by hand.
  4285. Before you use these scripts, you need to edit the file
  4286. @file{backup-specs}, which specifies parameters used by the backup
  4287. scripts and by the restore script. This file is usually located
  4288. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4289. detailed description. Once the backup parameters are set, you can
  4290. perform backups or restoration by running the appropriate script.
  4291. The name of the backup script is @code{backup}. The name of the
  4292. restore script is @code{restore}. The following sections describe
  4293. their use in detail.
  4294. @emph{Please Note:} The backup and restoration scripts are
  4295. designed to be used together. While it is possible to restore files by
  4296. hand from an archive which was created using a backup script, and to create
  4297. an archive by hand which could then be extracted using the restore script,
  4298. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4299. making such an attempt.
  4300. @node Backup Parameters
  4301. @section Setting Parameters for Backups and Restoration
  4302. The file @file{backup-specs} specifies backup parameters for the
  4303. backup and restoration scripts provided with @command{tar}. You must
  4304. edit @file{backup-specs} to fit your system configuration and schedule
  4305. before using these scripts.
  4306. Syntactically, @file{backup-specs} is a shell script, containing
  4307. mainly variable assignments. However, any valid shell construct
  4308. is allowed in this file. Particularly, you may wish to define
  4309. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4310. For more information about shell script syntax, please refer to
  4311. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4312. g_02, the definition of the Shell Command Language}. See also
  4313. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4314. The shell variables controlling behavior of @code{backup} and
  4315. @code{restore} are described in the following subsections.
  4316. @menu
  4317. * General-Purpose Variables::
  4318. * Magnetic Tape Control::
  4319. * User Hooks::
  4320. * backup-specs example:: An Example Text of @file{Backup-specs}
  4321. @end menu
  4322. @node General-Purpose Variables
  4323. @subsection General-Purpose Variables
  4324. @defvr {Backup variable} ADMINISTRATOR
  4325. The user name of the backup administrator. @code{Backup} scripts
  4326. sends a backup report to this address.
  4327. @end defvr
  4328. @defvr {Backup variable} BACKUP_HOUR
  4329. The hour at which the backups are done. This can be a number from 0
  4330. to 23, or the time specification in form @var{hours}:@var{minutes},
  4331. or the string @samp{now}.
  4332. This variable is used by @code{backup}. Its value may be overridden
  4333. using @option{--time} option (@pxref{Scripted Backups}).
  4334. @end defvr
  4335. @defvr {Backup variable} TAPE_FILE
  4336. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4337. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4338. that your @command{mt} is able to access remote devices. If @var{RSH}
  4339. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4340. invocations of @command{mt}.
  4341. @end defvr
  4342. @defvr {Backup variable} BLOCKING
  4343. The blocking factor @command{tar} will use when writing the dump archive.
  4344. @xref{Blocking Factor}.
  4345. @end defvr
  4346. @defvr {Backup variable} BACKUP_DIRS
  4347. A list of file systems to be dumped (for @code{backup}), or restored
  4348. (for @code{restore}). You can include any directory
  4349. name in the list --- subdirectories on that file system will be
  4350. included, regardless of how they may look to other networked machines.
  4351. Subdirectories on other file systems will be ignored.
  4352. The host name specifies which host to run @command{tar} on, and should
  4353. normally be the host that actually contains the file system. However,
  4354. the host machine must have @GNUTAR{} installed, and
  4355. must be able to access the directory containing the backup scripts and
  4356. their support files using the same file name that is used on the
  4357. machine where the scripts are run (ie. what @command{pwd} will print
  4358. when in that directory on that machine). If the host that contains
  4359. the file system does not have this capability, you can specify another
  4360. host as long as it can access the file system through NFS.
  4361. If the list of file systems is very long you may wish to put it
  4362. in a separate file. This file is usually named
  4363. @file{/etc/backup/dirs}, but this name may be overridden in
  4364. @file{backup-specs} using @code{DIRLIST} variable.
  4365. @end defvr
  4366. @defvr {Backup variable} DIRLIST
  4367. A path to the file containing the list of the file systems to backup
  4368. or restore. By default it is @file{/etc/backup/dirs}.
  4369. @end defvr
  4370. @defvr {Backup variable} BACKUP_FILES
  4371. A list of individual files to be dumped (for @code{backup}), or restored
  4372. (for @code{restore}). These should be accessible from the machine on
  4373. which the backup script is run.
  4374. If the list of file systems is very long you may wish to store it
  4375. in a separate file. This file is usually named
  4376. @file{/etc/backup/files}, but this name may be overridden in
  4377. @file{backup-specs} using @code{FILELIST} variable.
  4378. @end defvr
  4379. @defvr {Backup variable} FILELIST
  4380. A path to the file containing the list of the individual files to backup
  4381. or restore. By default it is @file{/etc/backup/files}.
  4382. @end defvr
  4383. @defvr {Backup variable} MT
  4384. Full file name of @command{mt} binary.
  4385. @end defvr
  4386. @defvr {Backup variable} RSH
  4387. @anchor{RSH}
  4388. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4389. set it to @code{ssh}, to improve security. In this case you will have
  4390. to use public key authentication.
  4391. @end defvr
  4392. @defvr {Backup variable} RSH_COMMAND
  4393. Full file name of @command{rsh} binary on remote mashines. This will
  4394. be passed via @option{--rsh-command} option to the remote invocation
  4395. of @GNUTAR{}.
  4396. @end defvr
  4397. @defvr {Backup variable} VOLNO_FILE
  4398. Name of temporary file to hold volume numbers. This needs to be accessible
  4399. by all the machines which have file systems to be dumped.
  4400. @end defvr
  4401. @defvr {Backup variable} XLIST
  4402. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4403. located on the remote machine and containing the list of files to
  4404. be excluded from the backup. Exclude file lists are searched in
  4405. /etc/tar-backup directory. A common use for exclude file lists
  4406. is to exclude files containing security-sensitive information
  4407. (e.g., @file{/etc/shadow} from backups).
  4408. This variable affects only @code{backup}.
  4409. @end defvr
  4410. @defvr {Backup variable} SLEEP_TIME
  4411. Time to sleep between dumps of any two successive file systems
  4412. This variable affects only @code{backup}.
  4413. @end defvr
  4414. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4415. Script to be run when it's time to insert a new tape in for the next
  4416. volume. Administrators may want to tailor this script for their site.
  4417. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4418. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4419. the console.
  4420. @end defvr
  4421. @defvr {Backup variable} SLEEP_MESSAGE
  4422. Message to display on the terminal while waiting for dump time. Usually
  4423. this will just be some literal text.
  4424. @end defvr
  4425. @defvr {Backup variable} TAR
  4426. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4427. scripts will search @command{tar} in the current shell path.
  4428. @end defvr
  4429. @node Magnetic Tape Control
  4430. @subsection Magnetic Tape Control
  4431. Backup scripts access tape device using special @dfn{hook functions}.
  4432. These functions take a single argument -- the name of the tape
  4433. device. Their names are kept in the following variables:
  4434. @defvr {Backup variable} MT_BEGIN
  4435. The name of @dfn{begin} function. This function is called before
  4436. accessing the drive. By default it retensions the tape:
  4437. @smallexample
  4438. MT_BEGIN=mt_begin
  4439. mt_begin() @{
  4440. mt -f "$1" retension
  4441. @}
  4442. @end smallexample
  4443. @end defvr
  4444. @defvr {Backup variable} MT_REWIND
  4445. The name of @dfn{rewind} function. The default definition is as
  4446. follows:
  4447. @smallexample
  4448. MT_REWIND=mt_rewind
  4449. mt_rewind() @{
  4450. mt -f "$1" rewind
  4451. @}
  4452. @end smallexample
  4453. @end defvr
  4454. @defvr {Backup variable} MT_OFFLINE
  4455. The name of the function switching the tape off line. By default
  4456. it is defined as follows:
  4457. @smallexample
  4458. MT_OFFLINE=mt_offline
  4459. mt_offline() @{
  4460. mt -f "$1" offl
  4461. @}
  4462. @end smallexample
  4463. @end defvr
  4464. @defvr {Backup variable} MT_STATUS
  4465. The name of the function used to obtain the status of the archive device,
  4466. including error count. Default definition:
  4467. @smallexample
  4468. MT_STATUS=mt_status
  4469. mt_status() @{
  4470. mt -f "$1" status
  4471. @}
  4472. @end smallexample
  4473. @end defvr
  4474. @node User Hooks
  4475. @subsection User Hooks
  4476. @dfn{User hooks} are shell functions executed before and after
  4477. each @command{tar} invocation. Thus, there are @dfn{backup
  4478. hooks}, which are executed before and after dumping each file
  4479. system, and @dfn{restore hooks}, executed before and
  4480. after restoring a file system. Each user hook is a shell function
  4481. taking four arguments:
  4482. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4483. Its arguments are:
  4484. @table @var
  4485. @item level
  4486. Current backup or restore level.
  4487. @item host
  4488. Name or IP address of the host machine being dumped or restored.
  4489. @item fs
  4490. Full path name to the file system being dumped or restored.
  4491. @item fsname
  4492. File system name with directory separators replaced with colons. This
  4493. is useful, e.g., for creating unique files.
  4494. @end table
  4495. @end deffn
  4496. Following variables keep the names of user hook functions
  4497. @defvr {Backup variable} DUMP_BEGIN
  4498. Dump begin function. It is executed before dumping the file system.
  4499. @end defvr
  4500. @defvr {Backup variable} DUMP_END
  4501. Executed after dumping the file system.
  4502. @end defvr
  4503. @defvr {Backup variable} RESTORE_BEGIN
  4504. Executed before restoring the file system.
  4505. @end defvr
  4506. @defvr {Backup variable} RESTORE_END
  4507. Executed after restoring the file system.
  4508. @end defvr
  4509. @node backup-specs example
  4510. @subsection An Example Text of @file{Backup-specs}
  4511. The following is an example of @file{backup-specs}:
  4512. @smallexample
  4513. # site-specific parameters for file system backup.
  4514. ADMINISTRATOR=friedman
  4515. BACKUP_HOUR=1
  4516. TAPE_FILE=/dev/nrsmt0
  4517. # Use @code{ssh} instead of the less secure @code{rsh}
  4518. RSH=/usr/bin/ssh
  4519. RSH_COMMAND=/usr/bin/ssh
  4520. # Override MT_STATUS function:
  4521. my_status() @{
  4522. mts -t $TAPE_FILE
  4523. @}
  4524. MT_STATUS=my_status
  4525. # Disable MT_OFFLINE function
  4526. MT_OFFLINE=:
  4527. BLOCKING=124
  4528. BACKUP_DIRS="
  4529. albert:/fs/fsf
  4530. apple-gunkies:/gd
  4531. albert:/fs/gd2
  4532. albert:/fs/gp
  4533. geech:/usr/jla
  4534. churchy:/usr/roland
  4535. albert:/
  4536. albert:/usr
  4537. apple-gunkies:/
  4538. apple-gunkies:/usr
  4539. gnu:/hack
  4540. gnu:/u
  4541. apple-gunkies:/com/mailer/gnu
  4542. apple-gunkies:/com/archive/gnu"
  4543. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4544. @end smallexample
  4545. @node Scripted Backups
  4546. @section Using the Backup Scripts
  4547. The syntax for running a backup script is:
  4548. @smallexample
  4549. backup --level=@var{level} --time=@var{time}
  4550. @end smallexample
  4551. The @option{level} option requests the dump level. Thus, to produce
  4552. a full dump, specify @code{--level=0} (this is the default, so
  4553. @option{--level} may be omitted if its value is @code{0}).
  4554. @footnote{For backward compatibility, the @code{backup} will also
  4555. try to deduce the requested dump level from the name of the
  4556. script itself. If the name consists of a string @samp{level-}
  4557. followed by a single decimal digit, that digit is taken as
  4558. the dump level number. Thus, you may create a link from @code{backup}
  4559. to @code{level-1} and then run @code{level-1} whenever you need to
  4560. create a level one dump.}
  4561. The @option{--time} option determines when should the backup be
  4562. run. @var{Time} may take three forms:
  4563. @table @asis
  4564. @item @var{hh}:@var{mm}
  4565. The dump must be run at @var{hh} hours @var{mm} minutes.
  4566. @item @var{hh}
  4567. The dump must be run at @var{hh} hours
  4568. @item now
  4569. The dump must be run immediately.
  4570. @end table
  4571. You should start a script with a tape or disk mounted. Once you
  4572. start a script, it prompts you for new tapes or disks as it
  4573. needs them. Media volumes don't have to correspond to archive
  4574. files --- a multi-volume archive can be started in the middle of a
  4575. tape that already contains the end of another multi-volume archive.
  4576. The @code{restore} script prompts for media by its archive volume,
  4577. so to avoid an error message you should keep track of which tape
  4578. (or disk) contains which volume of the archive (@pxref{Scripted
  4579. Restoration}).
  4580. The backup scripts write two files on the file system. The first is a
  4581. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4582. to store and retrieve information about which files were dumped. This
  4583. file is not meant to be read by humans, and should not be deleted by
  4584. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4585. file.
  4586. The second file is a log file containing the names of the file systems
  4587. and files dumped, what time the backup was made, and any error
  4588. messages that were generated, as well as how much space was left in
  4589. the media volume after the last volume of the archive was written.
  4590. You should check this log file after every backup. The file name is
  4591. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4592. represents current date, and @var{n} represents current dump level number.
  4593. The script also prints the name of each system being dumped to the
  4594. standard output.
  4595. Following is the full list of options accepted by @code{backup}
  4596. script:
  4597. @table @option
  4598. @item -l @var{level}
  4599. @itemx --level=@var{level}
  4600. Do backup level @var{level} (default 0).
  4601. @item -f
  4602. @itemx --force
  4603. Force backup even if today's log file already exists.
  4604. @item -v[@var{level}]
  4605. @itemx --verbose[=@var{level}]
  4606. Set verbosity level. The higher the level is, the more debugging
  4607. information will be output during execution. Devault @var{level}
  4608. is 100, which means the highest debugging level.
  4609. @item -t @var{start-time}
  4610. @itemx --time=@var{start-time}
  4611. Wait till @var{time}, then do backup.
  4612. @item -h
  4613. @itemx --help
  4614. Display short help message and exit.
  4615. @item -V
  4616. @itemx --version
  4617. Display information about the program's name, version, origin and legal
  4618. status, all on standard output, and then exit successfully.
  4619. @end table
  4620. @node Scripted Restoration
  4621. @section Using the Restore Script
  4622. To restore files that were archived using a scripted backup, use the
  4623. @code{restore} script. Its usage is quite straightforward. In the
  4624. simplest form, invoke @code{restore --all}, it will
  4625. then restore all the file systems and files specified in
  4626. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4627. You may select the file systems (and/or files) to restore by
  4628. giving @code{restore} list of @dfn{patterns} in its command
  4629. line. For example, running
  4630. @smallexample
  4631. restore 'albert:*'
  4632. @end smallexample
  4633. @noindent
  4634. will restore all file systems on the machine @samp{albert}. A more
  4635. complicated example:
  4636. @smallexample
  4637. restore 'albert:*' '*:/var'
  4638. @end smallexample
  4639. @noindent
  4640. This command will restore all file systems on the machine @samp{albert}
  4641. as well as @file{/var} file system on all machines.
  4642. By default @code{restore} will start restoring files from the lowest
  4643. available dump level (usually zero) and will continue through
  4644. all available dump levels. There may be situations where such a
  4645. thorough restore is not necessary. For example, you may wish to
  4646. restore only files from the recent level one backup. To do so,
  4647. use @option{--level} option, as shown in the example below:
  4648. @smallexample
  4649. restore --level=1
  4650. @end smallexample
  4651. The full list of options accepted by @code{restore} follows:
  4652. @table @option
  4653. @item -a
  4654. @itemx --all
  4655. Restore all file systems and files specified in @file{backup-specs}
  4656. @item -l @var{level}
  4657. @itemx --level=@var{level}
  4658. Start restoring from the given backup level, instead of the default 0.
  4659. @item -v[@var{level}]
  4660. @itemx --verbose[=@var{level}]
  4661. Set verbosity level. The higher the level is, the more debugging
  4662. information will be output during execution. Devault @var{level}
  4663. is 100, which means the highest debugging level.
  4664. @item -h
  4665. @itemx --help
  4666. Display short help message and exit.
  4667. @item -V
  4668. @itemx --version
  4669. Display information about the program's name, version, origin and legal
  4670. status, all on standard output, and then exit successfully.
  4671. @end table
  4672. You should start the restore script with the media containing the
  4673. first volume of the archive mounted. The script will prompt for other
  4674. volumes as they are needed. If the archive is on tape, you don't need
  4675. to rewind the tape to to its beginning---if the tape head is
  4676. positioned past the beginning of the archive, the script will rewind
  4677. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4678. positioning.}
  4679. @quotation
  4680. @strong{Warning:} The script will delete files from the active file
  4681. system if they were not in the file system when the archive was made.
  4682. @end quotation
  4683. @xref{Incremental Dumps}, for an explanation of how the script makes
  4684. that determination.
  4685. @node Choosing
  4686. @chapter Choosing Files and Names for @command{tar}
  4687. @UNREVISED
  4688. Certain options to @command{tar} enable you to specify a name for your
  4689. archive. Other options let you decide which files to include or exclude
  4690. from the archive, based on when or whether files were modified, whether
  4691. the file names do or don't match specified patterns, or whether files
  4692. are in specified directories.
  4693. This chapter discusses these options in detail.
  4694. @menu
  4695. * file:: Choosing the Archive's Name
  4696. * Selecting Archive Members::
  4697. * files:: Reading Names from a File
  4698. * exclude:: Excluding Some Files
  4699. * Wildcards:: Wildcards Patterns and Matching
  4700. * after:: Operating Only on New Files
  4701. * recurse:: Descending into Directories
  4702. * one:: Crossing File System Boundaries
  4703. @end menu
  4704. @node file
  4705. @section Choosing and Naming Archive Files
  4706. @UNREVISED
  4707. @FIXME{should the title of this section actually be, "naming an
  4708. archive"?}
  4709. @cindex Naming an archive
  4710. @cindex Archive Name
  4711. @cindex Choosing an archive file
  4712. @cindex Where is the archive?
  4713. By default, @command{tar} uses an archive file name that was compiled when
  4714. it was built on the system; usually this name refers to some physical
  4715. tape drive on the machine. However, the person who installed @command{tar}
  4716. on the system may not have set the default to a meaningful value as far as
  4717. most users are concerned. As a result, you will usually want to tell
  4718. @command{tar} where to find (or create) the archive. The
  4719. @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4720. option allows you to either specify or name a file to use as the archive
  4721. instead of the default archive file location.
  4722. @table @option
  4723. @opindex file, short description
  4724. @item --file=@var{archive-name}
  4725. @itemx -f @var{archive-name}
  4726. Name the archive to create or operate on. Use in conjunction with
  4727. any operation.
  4728. @end table
  4729. For example, in this @command{tar} command,
  4730. @smallexample
  4731. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4732. @end smallexample
  4733. @noindent
  4734. @file{collection.tar} is the name of the archive. It must directly
  4735. follow the @option{-f} option, since whatever directly follows @option{-f}
  4736. @emph{will} end up naming the archive. If you neglect to specify an
  4737. archive name, you may end up overwriting a file in the working directory
  4738. with the archive you create since @command{tar} will use this file's name
  4739. for the archive name.
  4740. An archive can be saved as a file in the file system, sent through a
  4741. pipe or over a network, or written to an I/O device such as a tape,
  4742. floppy disk, or CD write drive.
  4743. @cindex Writing new archives
  4744. @cindex Archive creation
  4745. If you do not name the archive, @command{tar} uses the value of the
  4746. environment variable @env{TAPE} as the file name for the archive. If
  4747. that is not available, @command{tar} uses a default, compiled-in archive
  4748. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4749. @cindex Standard input and output
  4750. @cindex tar to standard input and output
  4751. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4752. archive from standard input (when listing or extracting files), or
  4753. writes it to standard output (when creating an archive). If you use
  4754. @file{-} as an @var{archive-name} when modifying an archive,
  4755. @command{tar} reads the original archive from its standard input and
  4756. writes the entire new archive to its standard output.
  4757. The following example is a convenient way of copying directory
  4758. hierarchy from @file{sourcedir} to @file{targetdir}.
  4759. @smallexample
  4760. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)}
  4761. @end smallexample
  4762. The @option{-C} option allows to avoid using subshells:
  4763. @smallexample
  4764. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xpf -}
  4765. @end smallexample
  4766. In both examples above, the leftmost @command{tar} invocation archives
  4767. the contents of @file{sourcedir} to the standard output, while the
  4768. rightmost one reads this archive from its standard input and
  4769. extracts it. The @option{-p} option tells it to restore permissions
  4770. of the extracted files.
  4771. @cindex Remote devices
  4772. @cindex tar to a remote device
  4773. @anchor{remote-dev}
  4774. To specify an archive file on a device attached to a remote machine,
  4775. use the following:
  4776. @smallexample
  4777. @kbd{--file=@var{hostname}:/@var{dev}/@var{file-name}}
  4778. @end smallexample
  4779. @noindent
  4780. @command{tar} will complete the remote connection, if possible, and
  4781. prompt you for a username and password. If you use
  4782. @option{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @command{tar}
  4783. will complete the remote connection, if possible, using your username
  4784. as the username on the remote machine.
  4785. @cindex Local and remote archives
  4786. @anchor{local and remote archives}
  4787. If the archive file name includes a colon (@samp{:}), then it is assumed
  4788. to be a file on another machine. If the archive file is
  4789. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4790. host @var{host}. The remote host is accessed using the @command{rsh}
  4791. program, with a username of @var{user}. If the username is omitted
  4792. (along with the @samp{@@} sign), then your user name will be used.
  4793. (This is the normal @command{rsh} behavior.) It is necessary for the
  4794. remote machine, in addition to permitting your @command{rsh} access, to
  4795. have the @file{rmt} program installed (This command is included in
  4796. the @GNUTAR{} distribution and by default is installed under
  4797. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4798. installation prefix). If you need to use a file whose name includes a
  4799. colon, then the remote tape drive behavior
  4800. can be inhibited by using the @option{--force-local} option.
  4801. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4802. tries to minimize input and output operations. The Amanda backup
  4803. system, when used with @GNUTAR{}, has an initial sizing pass which
  4804. uses this feature.
  4805. @node Selecting Archive Members
  4806. @section Selecting Archive Members
  4807. @cindex Specifying files to act on
  4808. @cindex Specifying archive members
  4809. @dfn{File Name arguments} specify which files in the file system
  4810. @command{tar} operates on, when creating or adding to an archive, or which
  4811. archive members @command{tar} operates on, when reading or deleting from
  4812. an archive. @xref{Operations}.
  4813. To specify file names, you can include them as the last arguments on
  4814. the command line, as follows:
  4815. @smallexample
  4816. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4817. @end smallexample
  4818. If a file name begins with dash (@samp{-}), precede it with
  4819. @option{--add-file} option to prevent it from being treated as an
  4820. option.
  4821. If you specify a directory name as a file name argument, all the files
  4822. in that directory are operated on by @command{tar}.
  4823. If you do not specify files, @command{tar} behavior differs depending
  4824. on the operation mode as described below:
  4825. When @command{tar} is invoked with @option{--create} (@option{-c}),
  4826. @command{tar} will stop immediately, reporting the following:
  4827. @smallexample
  4828. @group
  4829. $ @kbd{tar cf a.tar}
  4830. tar: Cowardly refusing to create an empty archive
  4831. Try `tar --help' or `tar --usage' for more information.
  4832. @end group
  4833. @end smallexample
  4834. If you specify either @option{--list} (@option{-t}) or
  4835. @option{--extract} (@option{--get}, @option{-x}), @command{tar}
  4836. operates on all the archive members in the archive.
  4837. If run with @option{--diff} option, tar will compare the archive with
  4838. the contents of the current working directory.
  4839. If you specify any other operation, @command{tar} does nothing.
  4840. By default, @command{tar} takes file names from the command line. However,
  4841. there are other ways to specify file or member names, or to modify the
  4842. manner in which @command{tar} selects the files or members upon which to
  4843. operate. @FIXME{add xref here}In general, these methods work both for
  4844. specifying the names of files and archive members.
  4845. @node files
  4846. @section Reading Names from a File
  4847. @cindex Reading file names from a file
  4848. @cindex Lists of file names
  4849. @cindex File Name arguments, alternatives
  4850. Instead of giving the names of files or archive members on the command
  4851. line, you can put the names into a file, and then use the
  4852. @option{--files-from=@var{file-of-names}} (@option{-T
  4853. @var{file-of-names}}) option to @command{tar}. Give the name of the
  4854. file which contains the list of files to include as the argument to
  4855. @option{--files-from}. In the list, the file names should be separated by
  4856. newlines. You will frequently use this option when you have generated
  4857. the list of files to archive with the @command{find} utility.
  4858. @table @option
  4859. @opindex files-from
  4860. @item --files-from=@var{file-name}
  4861. @itemx -T @var{file-name}
  4862. Get names to extract or create from file @var{file-name}.
  4863. @end table
  4864. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  4865. you specify either @code{--files-from=-} or @code{-T -}), then the file
  4866. names are read from standard input.
  4867. Unless you are running @command{tar} with @option{--create}, you can not use
  4868. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  4869. command.
  4870. Any number of @option{-T} options can be given in the command line.
  4871. The following example shows how to use @command{find} to generate a list of
  4872. files smaller than 400K in length and put that list into a file
  4873. called @file{small-files}. You can then use the @option{-T} option to
  4874. @command{tar} to specify the files from that file, @file{small-files}, to
  4875. create the archive @file{little.tgz}. (The @option{-z} option to
  4876. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4877. more information.)
  4878. @smallexample
  4879. $ @kbd{find . -size -400 -print > small-files}
  4880. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4881. @end smallexample
  4882. @noindent
  4883. In the file list given by @option{-T} option, any file name beginning
  4884. with @samp{-} character is considered a @command{tar} option and is
  4885. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  4886. recognized only @option{-C} option in file lists, and only if the
  4887. option and its argument occupied two consecutive lines.} For example,
  4888. the common use of this feature is to change to another directory by
  4889. specifying @option{-C} option:
  4890. @smallexample
  4891. @group
  4892. $ @kbd{cat list}
  4893. -C/etc
  4894. passwd
  4895. hosts
  4896. -C/lib
  4897. libc.a
  4898. $ @kbd{tar -c -f foo.tar --files-from list}
  4899. @end group
  4900. @end smallexample
  4901. @noindent
  4902. In this example, @command{tar} will first switch to @file{/etc}
  4903. directory and add files @file{passwd} and @file{hosts} to the
  4904. archive. Then it will change to @file{/lib} directory and will archive
  4905. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  4906. contain:
  4907. @smallexample
  4908. @group
  4909. $ @kbd{tar tf foo.tar}
  4910. passwd
  4911. hosts
  4912. libc.a
  4913. @end group
  4914. @end smallexample
  4915. @noindent
  4916. @opindex directory, using in @option{--files-from} argument
  4917. Notice that the option parsing algorithm used with @option{-T} is
  4918. stricter than the one used by shell. Namely, when specifying option
  4919. arguments, you should observe the following rules:
  4920. @itemize @bullet
  4921. @item
  4922. When using short (single-letter) option form, its argument must
  4923. immediately follow the option letter, without any intervening
  4924. whitespace. For example: @code{-Cdir}.
  4925. @item
  4926. When using long option form, the option argument must be separated
  4927. from the option by a single equal sign. No whitespace is allowed on
  4928. any side of the equal sign. For example: @code{--directory=dir}.
  4929. @item
  4930. For both short and long option forms, the option argument can be given
  4931. on the next line after the option name, e.g.:
  4932. @smallexample
  4933. @group
  4934. --directory
  4935. dir
  4936. @end group
  4937. @end smallexample
  4938. @noindent
  4939. and
  4940. @smallexample
  4941. @group
  4942. -C
  4943. dir
  4944. @end group
  4945. @end smallexample
  4946. @end itemize
  4947. @opindex add-file
  4948. If you happen to have a file whose name starts with @samp{-},
  4949. precede it with @option{--add-file} option to prevent it from
  4950. being recognized as an option. For example: @code{--add-file=--my-file}.
  4951. @menu
  4952. * nul::
  4953. @end menu
  4954. @node nul
  4955. @subsection @code{NUL} Terminated File Names
  4956. @cindex File names, terminated by @code{NUL}
  4957. @cindex @code{NUL} terminated file names
  4958. The @option{--null} option causes
  4959. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}})
  4960. to read file names terminated by a @code{NUL} instead of a newline, so
  4961. files whose names contain newlines can be archived using
  4962. @option{--files-from}.
  4963. @table @option
  4964. @opindex null
  4965. @item --null
  4966. Only consider @code{NUL} terminated file names, instead of files that
  4967. terminate in a newline.
  4968. @end table
  4969. The @option{--null} option is just like the one in @acronym{GNU}
  4970. @command{xargs} and @command{cpio}, and is useful with the
  4971. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  4972. @command{tar}, @option{--null} also disables special handling for
  4973. file names that begin with dash.
  4974. This example shows how to use @command{find} to generate a list of files
  4975. larger than 800K in length and put that list into a file called
  4976. @file{long-files}. The @option{-print0} option to @command{find} is just
  4977. like @option{-print}, except that it separates files with a @code{NUL}
  4978. rather than with a newline. You can then run @command{tar} with both the
  4979. @option{--null} and @option{-T} options to specify that @command{tar} get the
  4980. files from that file, @file{long-files}, to create the archive
  4981. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  4982. @command{tar} to recognize the @code{NUL} separator between files.
  4983. @smallexample
  4984. $ @kbd{find . -size +800 -print0 > long-files}
  4985. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4986. @end smallexample
  4987. @FIXME{say anything else here to conclude the section?}
  4988. @node exclude
  4989. @section Excluding Some Files
  4990. @UNREVISED
  4991. @cindex File names, excluding files by
  4992. @cindex Excluding files by name and pattern
  4993. @cindex Excluding files by file system
  4994. To avoid operating on files whose names match a particular pattern,
  4995. use the @option{--exclude} or @option{--exclude-from} options.
  4996. @table @option
  4997. @opindex exclude
  4998. @item --exclude=@var{pattern}
  4999. Causes @command{tar} to ignore files that match the @var{pattern}.
  5000. @end table
  5001. @findex exclude
  5002. The @option{--exclude=@var{pattern}} option prevents any file or
  5003. member whose name matches the shell wildcard (@var{pattern}) from
  5004. being operated on.
  5005. For example, to create an archive with all the contents of the directory
  5006. @file{src} except for files whose names end in @file{.o}, use the
  5007. command @samp{tar -cf src.tar --exclude='*.o' src}.
  5008. You may give multiple @option{--exclude} options.
  5009. @table @option
  5010. @opindex exclude-from
  5011. @item --exclude-from=@var{file}
  5012. @itemx -X @var{file}
  5013. Causes @command{tar} to ignore files that match the patterns listed in
  5014. @var{file}.
  5015. @end table
  5016. @findex exclude-from
  5017. Use the @option{--exclude-from} option to read a
  5018. list of patterns, one per line, from @var{file}; @command{tar} will
  5019. ignore files matching those patterns. Thus if @command{tar} is
  5020. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  5021. single line @file{*.o}, no files whose names end in @file{.o} will be
  5022. added to the archive.
  5023. @table @option
  5024. @opindex exclude-caches
  5025. @item --exclude-caches
  5026. Causes @command{tar} to ignore directories containing a cache directory tag.
  5027. @end table
  5028. @findex exclude-caches
  5029. When creating an archive, the @option{--exclude-caches} option causes
  5030. @command{tar} to exclude all directories that contain a @dfn{cache
  5031. directory tag}. A cache directory tag is a short file with the
  5032. well-known name @file{CACHEDIR.TAG} and having a standard header
  5033. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5034. Various applications write cache directory tags into directories they
  5035. use to hold regenerable, non-precious data, so that such data can be
  5036. more easily excluded from backups.
  5037. @menu
  5038. * problems with exclude::
  5039. @end menu
  5040. @node problems with exclude
  5041. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5042. @opindex exclude, potential problems with
  5043. Some users find @samp{exclude} options confusing. Here are some common
  5044. pitfalls:
  5045. @itemize @bullet
  5046. @item
  5047. The main operating mode of @command{tar} does not act on a path name
  5048. explicitly listed on the command line if one of its file name
  5049. components is excluded. In the example above, if
  5050. you create an archive and exclude files that end with @samp{*.o}, but
  5051. explicitly name the file @samp{dir.o/foo} after all the options have been
  5052. listed, @samp{dir.o/foo} will be excluded from the archive.
  5053. @item
  5054. You can sometimes confuse the meanings of @option{--exclude} and
  5055. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5056. to be excluded are given as a pattern on the command line. Use
  5057. @option{--exclude-from} to introduce the name of a file which contains
  5058. a list of patterns, one per line; each of these patterns can exclude
  5059. zero, one, or many files.
  5060. @item
  5061. When you use @option{--exclude=@var{pattern}}, be sure to quote the
  5062. @var{pattern} parameter, so @GNUTAR{} sees wildcard characters
  5063. like @samp{*}. If you do not do this, the shell might expand the
  5064. @samp{*} itself using files at hand, so @command{tar} might receive a
  5065. list of files instead of one pattern, or none at all, making the
  5066. command somewhat illegal. This might not correspond to what you want.
  5067. For example, write:
  5068. @smallexample
  5069. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5070. @end smallexample
  5071. @noindent
  5072. rather than:
  5073. @smallexample
  5074. # @emph{Wrong!}
  5075. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5076. @end smallexample
  5077. @item
  5078. You must use use shell syntax, or globbing, rather than @code{regexp}
  5079. syntax, when using exclude options in @command{tar}. If you try to use
  5080. @code{regexp} syntax to describe files to be excluded, your command
  5081. might fail.
  5082. @item
  5083. @FIXME{The change in semantics must have occurred before 1.11,
  5084. so I doubt if it is worth mentioning at all. Anyway, should at
  5085. least specify in which version the semantics changed.}
  5086. In earlier versions of @command{tar}, what is now the
  5087. @option{--exclude-from} option was called @option{--exclude} instead.
  5088. Now, @option{--exclude} applies to patterns listed on the command
  5089. line and @option{--exclude-from} applies to patterns listed in a
  5090. file.
  5091. @end itemize
  5092. @node Wildcards
  5093. @section Wildcards Patterns and Matching
  5094. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5095. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5096. existing files matching the given pattern. @GNUTAR{} can use wildcard
  5097. patterns for matching (or globbing) archive members when extracting
  5098. from or listing an archive. Wildcard patterns are also used for
  5099. verifying volume labels of @command{tar} archives. This section has the
  5100. purpose of explaining wildcard syntax for @command{tar}.
  5101. @FIXME{the next few paragraphs need work.}
  5102. A @var{pattern} should be written according to shell syntax, using wildcard
  5103. characters to effect globbing. Most characters in the pattern stand
  5104. for themselves in the matched string, and case is significant: @samp{a}
  5105. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5106. pattern matches any single character in the matched string. The character
  5107. @samp{*} in the pattern matches zero, one, or more single characters in
  5108. the matched string. The character @samp{\} says to take the following
  5109. character of the pattern @emph{literally}; it is useful when one needs to
  5110. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5111. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5112. class. A @dfn{character class} is a list of acceptable characters
  5113. for the next single character of the matched string. For example,
  5114. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5115. Note that within a character class, all of the ``special characters''
  5116. listed above other than @samp{\} lose their special meaning; for example,
  5117. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5118. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5119. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5120. @emph{last} in a character class.)
  5121. @cindex Excluding characters from a character class
  5122. @cindex Character class, excluding characters from
  5123. If the first character of the class after the opening @samp{[}
  5124. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5125. Rather than listing character to match, it lists those characters which
  5126. are @emph{forbidden} as the next single character of the matched string.
  5127. Other characters of the class stand for themselves. The special
  5128. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5129. letters, is meant to represent all characters between @var{a} and
  5130. @var{e}, inclusive.
  5131. @FIXME{need to add a sentence or so here to make this clear for those
  5132. who don't have dan around.}
  5133. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5134. special for wildcard matches. However, if a pattern completely matches
  5135. a directory prefix of a matched string, then it matches the full matched
  5136. string: thus, excluding a directory also excludes all the files beneath it.
  5137. @menu
  5138. * controlling pattern-matching::
  5139. @end menu
  5140. @node controlling pattern-matching
  5141. @unnumberedsubsec Controlling Pattern-Matching
  5142. For the purposes of this section, we call @dfn{exclusion members} all
  5143. member names obtained while processing @option{--exclude} and
  5144. @option{--exclude-from} options, and @dfn{inclusion members} those
  5145. member names that were given in the command line or read from the file
  5146. specified with @option{--files-from} option.
  5147. These two pairs of member lists are used in the following operations:
  5148. @option{--diff}, @option{--extract}, @option{--list},
  5149. @option{--update}.
  5150. There are no inclusion members in create mode (@option{--create} and
  5151. @option{--append}), since in this mode the names obtained from the
  5152. command line refer to @emph{files}, not archive members.
  5153. By default, inclusion members are compared with archive members
  5154. literally @footnote{Notice that earlier @GNUTAR{} versions used
  5155. globbing for inclusion members, which contradicted to UNIX98
  5156. specification and was not documented. @xref{Changes}, for more
  5157. information on this and other changes} and exclusion members are
  5158. treated as globbing patterns. For example:
  5159. @smallexample
  5160. @group
  5161. $ @kbd{tar tf foo.tar}
  5162. a.c
  5163. b.c
  5164. a.txt
  5165. [remarks]
  5166. # @i{Member names are used verbatim:}
  5167. $ @kbd{tar -xf foo.tar -v '[remarks]'}
  5168. [remarks]
  5169. # @i{Exclude member names are globbed:}
  5170. $ @kbd{tar -xf foo.tar -v --exclude '*.c'}
  5171. a.txt
  5172. [remarks]
  5173. @end group
  5174. @end smallexample
  5175. This behavior can be altered by using the following options:
  5176. @table @option
  5177. @opindex wildcards
  5178. @item --wildcards
  5179. Treat all member names as wildcards.
  5180. @opindex no-wildcards
  5181. @item --no-wildcards
  5182. Treat all member names as literal strings.
  5183. @end table
  5184. Thus, to extract files whose names end in @samp{.c}, you can use:
  5185. @smallexample
  5186. $ @kbd{tar -xf foo.tar -v --wildcards '*.c'}
  5187. a.c
  5188. b.c
  5189. @end smallexample
  5190. @noindent
  5191. Notice quoting of the pattern to prevent the shell from interpreting
  5192. it.
  5193. The effect of @option{--wildcards} option is cancelled by
  5194. @option{--no-wildcards}. This can be used to pass part of
  5195. the command line arguments verbatim and other part as globbing
  5196. patterns. For example, the following invocation:
  5197. @smallexample
  5198. $ @kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
  5199. @end smallexample
  5200. @noindent
  5201. instructs @command{tar} to extract from @file{foo.tar} all files whose
  5202. names end in @samp{.txt} and the file named @file{[remarks]}.
  5203. Normally, a pattern matches a name if an initial subsequence of the
  5204. name's components matches the pattern, where @samp{*}, @samp{?}, and
  5205. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  5206. and wildcards can match @samp{/}.
  5207. Other than optionally stripping leading @samp{/} from names
  5208. (@pxref{absolute}), patterns and names are used as-is. For
  5209. example, trailing @samp{/} is not trimmed from a user-specified name
  5210. before deciding whether to exclude it.
  5211. However, this matching procedure can be altered by the options listed
  5212. below. These options accumulate. For example:
  5213. @smallexample
  5214. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  5215. @end smallexample
  5216. ignores case when excluding @samp{makefile}, but not when excluding
  5217. @samp{readme}.
  5218. @table @option
  5219. @opindex anchored
  5220. @opindex no-anchored
  5221. @item --anchored
  5222. @itemx --no-anchored
  5223. If anchored, a pattern must match an initial subsequence
  5224. of the name's components. Otherwise, the pattern can match any
  5225. subsequence. Default is @option{--no-anchored} for exclusion members
  5226. and @option{--anchored} inclusion members.
  5227. @opindex ignore-case
  5228. @opindex no-ignore-case
  5229. @item --ignore-case
  5230. @itemx --no-ignore-case
  5231. When ignoring case, upper-case patterns match lower-case names and vice versa.
  5232. When not ignoring case (the default), matching is case-sensitive.
  5233. @opindex wildcards-match-slash
  5234. @opindex no-wildcards-match-slash
  5235. @item --wildcards-match-slash
  5236. @itemx --no-wildcards-match-slash
  5237. When wildcards match slash (the default for exclusion members), a
  5238. wildcard like @samp{*} in the pattern can match a @samp{/} in the
  5239. name. Otherwise, @samp{/} is matched only by @samp{/}.
  5240. @end table
  5241. The @option{--recursion} and @option{--no-recursion} options
  5242. (@pxref{recurse}) also affect how member patterns are interpreted. If
  5243. recursion is in effect, a pattern matches a name if it matches any of
  5244. the name's parent directories.
  5245. The following table summarizes pattern-matching default values:
  5246. @multitable @columnfractions .3 .7
  5247. @headitem Members @tab Default settings
  5248. @item Inclusion @tab @option{--no-wildcards --anchored --no-wildcards-match-slash}
  5249. @item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
  5250. @end multitable
  5251. @node after
  5252. @section Operating Only on New Files
  5253. @UNREVISED
  5254. @cindex Excluding file by age
  5255. @cindex Data Modification time, excluding files by
  5256. @cindex Modification time, excluding files by
  5257. @cindex Age, excluding files by
  5258. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5259. @option{-N @var{date}}) option causes @command{tar} to only work on
  5260. files whose data modification or status change times are newer than
  5261. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5262. it is taken to be a file name; the data modification time of that file
  5263. is used as the date. If you use this option when creating or appending
  5264. to an archive, the archive will only include new files. If you use
  5265. @option{--after-date} when extracting an archive, @command{tar} will
  5266. only extract files newer than the @var{date} you specify.
  5267. If you only want @command{tar} to make the date comparison based on
  5268. modification of the file's data (rather than status
  5269. changes), then use the @option{--newer-mtime=@var{date}} option.
  5270. You may use these options with any operation. Note that these options
  5271. differ from the @option{--update} (@option{-u}) operation in that they
  5272. allow you to specify a particular date against which @command{tar} can
  5273. compare when deciding whether or not to archive the files.
  5274. @table @option
  5275. @opindex after-date
  5276. @opindex newer
  5277. @item --after-date=@var{date}
  5278. @itemx --newer=@var{date}
  5279. @itemx -N @var{date}
  5280. Only store files newer than @var{date}.
  5281. Acts on files only if their data modification or status change times are
  5282. later than @var{date}. Use in conjunction with any operation.
  5283. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5284. name; the data modification time of that file is used as the date.
  5285. @opindex newer-mtime
  5286. @item --newer-mtime=@var{date}
  5287. Acts like @option{--after-date}, but only looks at data modification times.
  5288. @end table
  5289. These options limit @command{tar} to operate only on files which have
  5290. been modified after the date specified. A file's status is considered to have
  5291. changed if its contents have been modified, or if its owner,
  5292. permissions, and so forth, have been changed. (For more information on
  5293. how to specify a date, see @ref{Date input formats}; remember that the
  5294. entire date argument must be quoted if it contains any spaces.)
  5295. Gurus would say that @option{--after-date} tests both the data
  5296. modification time (@code{mtime}, the time the contents of the file
  5297. were last modified) and the status change time (@code{ctime}, the time
  5298. the file's status was last changed: owner, permissions, etc.@:)
  5299. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5300. field.
  5301. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5302. @code{ctime} and processes the file if either one is more recent than
  5303. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5304. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5305. contents of the file were looked at).
  5306. Date specifiers can have embedded spaces. Because of this, you may need
  5307. to quote date arguments to keep the shell from parsing them as separate
  5308. arguments.
  5309. @FIXME{Need example of --newer-mtime with quoted argument.}
  5310. @quotation
  5311. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5312. should not be used for incremental backups. Some files (such as those
  5313. in renamed directories) are not selected properly by these options.
  5314. @xref{Incremental Dumps}.
  5315. @end quotation
  5316. @noindent
  5317. @FIXME{which tells -- need to fill this in!}
  5318. @node recurse
  5319. @section Descending into Directories
  5320. @UNREVISED
  5321. @cindex Avoiding recursion in directories
  5322. @cindex Descending directories, avoiding
  5323. @cindex Directories, avoiding recursion
  5324. @cindex Recursion in directories, avoiding
  5325. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5326. @FIXME{show dan bob's comments, from 2-10-97}
  5327. Usually, @command{tar} will recursively explore all directories (either
  5328. those given on the command line or through the @option{--files-from}
  5329. option) for the various files they contain. However, you may not always
  5330. want @command{tar} to act this way.
  5331. @opindex no-recursion
  5332. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5333. into specified directories. If you specify @option{--no-recursion}, you can
  5334. use the @command{find} utility for hunting through levels of directories to
  5335. construct a list of file names which you could then pass to @command{tar}.
  5336. @command{find} allows you to be more selective when choosing which files to
  5337. archive; see @ref{files} for more information on using @command{find} with
  5338. @command{tar}, or look.
  5339. @table @option
  5340. @item --no-recursion
  5341. Prevents @command{tar} from recursively descending directories.
  5342. @opindex recursion
  5343. @item --recursion
  5344. Requires @command{tar} to recursively descend directories.
  5345. This is the default.
  5346. @end table
  5347. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5348. directory entries themselves, but does not descend on them
  5349. recursively. Many people use @command{find} for locating files they
  5350. want to back up, and since @command{tar} @emph{usually} recursively
  5351. descends on directories, they have to use the @samp{@w{! -d}} option
  5352. to @command{find} @FIXME{needs more explanation or a cite to another
  5353. info file}as they usually do not want all the files in a directory.
  5354. They then use the @option{--files-from} option to archive the files
  5355. located via @command{find}.
  5356. The problem when restoring files archived in this manner is that the
  5357. directories themselves are not in the archive; so the
  5358. @option{--same-permissions} (@option{--preserve-permissions},
  5359. @option{-p}) option does not affect them---while users might really
  5360. like it to. Specifying @option{--no-recursion} is a way to tell
  5361. @command{tar} to grab only the directory entries given to it, adding
  5362. no new files on its own.
  5363. The @option{--no-recursion} option also applies when extracting: it
  5364. causes @command{tar} to extract only the matched directory entries, not
  5365. the files under those directories.
  5366. The @option{--no-recursion} option also affects how globbing patterns
  5367. are interpreted (@pxref{controlling pattern-matching}).
  5368. The @option{--no-recursion} and @option{--recursion} options apply to
  5369. later options and operands, and can be overridden by later occurrences
  5370. of @option{--no-recursion} and @option{--recursion}. For example:
  5371. @smallexample
  5372. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5373. @end smallexample
  5374. @noindent
  5375. creates an archive with one entry for @file{grape}, and the recursive
  5376. contents of @file{grape/concord}, but no entries under @file{grape}
  5377. other than @file{grape/concord}.
  5378. @node one
  5379. @section Crossing File System Boundaries
  5380. @cindex File system boundaries, not crossing
  5381. @UNREVISED
  5382. @command{tar} will normally automatically cross file system boundaries in
  5383. order to archive files which are part of a directory tree. You can
  5384. change this behavior by running @command{tar} and specifying
  5385. @option{--one-file-system}. This option only affects files that are
  5386. archived because they are in a directory that is being archived;
  5387. @command{tar} will still archive files explicitly named on the command line
  5388. or through @option{--files-from}, regardless of where they reside.
  5389. @table @option
  5390. @opindex one-file-system
  5391. @item --one-file-system
  5392. @itemx -l
  5393. Prevents @command{tar} from crossing file system boundaries when
  5394. archiving. Use in conjunction with any write operation.
  5395. @end table
  5396. The @option{--one-file-system} option causes @command{tar} to modify its
  5397. normal behavior in archiving the contents of directories. If a file in
  5398. a directory is not on the same file system as the directory itself, then
  5399. @command{tar} will not archive that file. If the file is a directory
  5400. itself, @command{tar} will not archive anything beneath it; in other words,
  5401. @command{tar} will not cross mount points.
  5402. It is reported that using this option, the mount point is is archived,
  5403. but nothing under it.
  5404. This option is useful for making full or incremental archival backups of
  5405. a file system. If this option is used in conjunction with
  5406. @option{--verbose} (@option{-v}), files that are excluded are mentioned by name on the
  5407. standard error.
  5408. @menu
  5409. * directory:: Changing Directory
  5410. * absolute:: Absolute File Names
  5411. @end menu
  5412. @node directory
  5413. @subsection Changing the Working Directory
  5414. @UNREVISED
  5415. @FIXME{need to read over this node now for continuity; i've switched
  5416. things around some.}
  5417. @cindex Changing directory mid-stream
  5418. @cindex Directory, changing mid-stream
  5419. @cindex Working directory, specifying
  5420. To change the working directory in the middle of a list of file names,
  5421. either on the command line or in a file specified using
  5422. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5423. This will change the working directory to the specified directory
  5424. after that point in the list.
  5425. @table @option
  5426. @opindex directory
  5427. @item --directory=@var{directory}
  5428. @itemx -C @var{directory}
  5429. Changes the working directory in the middle of a command line.
  5430. @end table
  5431. For example,
  5432. @smallexample
  5433. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5434. @end smallexample
  5435. @noindent
  5436. will place the files @file{grape} and @file{prune} from the current
  5437. directory into the archive @file{jams.tar}, followed by the file
  5438. @file{cherry} from the directory @file{food}. This option is especially
  5439. useful when you have several widely separated files that you want to
  5440. store in the same archive.
  5441. Note that the file @file{cherry} is recorded in the archive under the
  5442. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5443. archive will contain three files that all appear to have come from the
  5444. same directory; if the archive is extracted with plain @samp{tar
  5445. --extract}, all three files will be written in the current directory.
  5446. Contrast this with the command,
  5447. @smallexample
  5448. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5449. @end smallexample
  5450. @noindent
  5451. which records the third file in the archive under the name
  5452. @file{red/cherry} so that, if the archive is extracted using
  5453. @samp{tar --extract}, the third file will be written in a subdirectory
  5454. named @file{orange-colored}.
  5455. You can use the @option{--directory} option to make the archive
  5456. independent of the original name of the directory holding the files.
  5457. The following command places the files @file{/etc/passwd},
  5458. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5459. @file{foo.tar}:
  5460. @smallexample
  5461. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5462. @end smallexample
  5463. @noindent
  5464. However, the names of the archive members will be exactly what they were
  5465. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5466. They will not appear to be related by file name to the original
  5467. directories where those files were located.
  5468. Note that @option{--directory} options are interpreted consecutively. If
  5469. @option{--directory} specifies a relative file name, it is interpreted
  5470. relative to the then current directory, which might not be the same as
  5471. the original current working directory of @command{tar}, due to a previous
  5472. @option{--directory} option.
  5473. When using @option{--files-from} (@pxref{files}), you can put various
  5474. @command{tar} options (including @option{-C}) in the file list. Notice,
  5475. however, that in this case the option and its argument may not be
  5476. separated by whitespace. If you use short option, its argument must
  5477. either follow the option letter immediately, without any intervening
  5478. whitespace, or occupy the next line. Otherwise, if you use long
  5479. option, separate its argument by an equal sign.
  5480. For instance, the file list for the above example will be:
  5481. @smallexample
  5482. @group
  5483. -C
  5484. /etc
  5485. passwd
  5486. hosts
  5487. -C
  5488. /lib
  5489. libc.a
  5490. @end group
  5491. @end smallexample
  5492. @noindent
  5493. To use it, you would invoke @command{tar} as follows:
  5494. @smallexample
  5495. $ @kbd{tar -c -f foo.tar --files-from list}
  5496. @end smallexample
  5497. Notice also that you can only use the short option variant in the file
  5498. list, i.e., always use @option{-C}, not @option{--directory}.
  5499. The interpretation of @option{--directory} is disabled by
  5500. @option{--null} option.
  5501. @node absolute
  5502. @subsection Absolute File Names
  5503. @UNREVISED
  5504. @table @option
  5505. @opindex absolute-names
  5506. @item --absolute-names
  5507. @itemx -P
  5508. Do not strip leading slashes from file names, and permit file names
  5509. containing a @file{..} file name component.
  5510. @end table
  5511. By default, @GNUTAR{} drops a leading @samp{/} on
  5512. input or output, and complains about file names containing a @file{..}
  5513. component. This option turns off this behavior.
  5514. When @command{tar} extracts archive members from an archive, it strips any
  5515. leading slashes (@samp{/}) from the member name. This causes absolute
  5516. member names in the archive to be treated as relative file names. This
  5517. allows you to have such members extracted wherever you want, instead of
  5518. being restricted to extracting the member in the exact directory named
  5519. in the archive. For example, if the archive member has the name
  5520. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5521. really @file{etc/passwd}.
  5522. File names containing @file{..} can cause problems when extracting, so
  5523. @command{tar} normally warns you about such files when creating an
  5524. archive, and rejects attempts to extracts such files.
  5525. Other @command{tar} programs do not do this. As a result, if you
  5526. create an archive whose member names start with a slash, they will be
  5527. difficult for other people with a non-@GNUTAR{}
  5528. program to use. Therefore, @GNUTAR{} also strips
  5529. leading slashes from member names when putting members into the
  5530. archive. For example, if you ask @command{tar} to add the file
  5531. @file{/bin/ls} to an archive, it will do so, but the member name will
  5532. be @file{bin/ls}.@footnote{A side effect of this is that when
  5533. @option{--create} is used with @option{--verbose} the resulting output
  5534. is not, generally speaking, the same as the one you'd get running
  5535. @kbd{tar --list} command. This may be important if you use some
  5536. scripts for comparing both outputs. @xref{listing member and file names},
  5537. for the information on how to handle this case.}
  5538. If you use the @option{--absolute-names} (@option{-P}) option,
  5539. @command{tar} will do none of these transformations.
  5540. To archive or extract files relative to the root directory, specify
  5541. the @option{--absolute-names} (@option{-P}) option.
  5542. Normally, @command{tar} acts on files relative to the working
  5543. directory---ignoring superior directory names when archiving, and
  5544. ignoring leading slashes when extracting.
  5545. When you specify @option{--absolute-names} (@option{-P}),
  5546. @command{tar} stores file names including all superior directory
  5547. names, and preserves leading slashes. If you only invoked
  5548. @command{tar} from the root directory you would never need the
  5549. @option{--absolute-names} option, but using this option
  5550. may be more convenient than switching to root.
  5551. @FIXME{Should be an example in the tutorial/wizardry section using this
  5552. to transfer files between systems.}
  5553. @FIXME{Is write access an issue?}
  5554. @table @option
  5555. @item --absolute-names
  5556. Preserves full file names (including superior directory names) when
  5557. archiving files. Preserves leading slash when extracting files.
  5558. @end table
  5559. @FIXME{this is still horrible; need to talk with dan on monday.}
  5560. @command{tar} prints out a message about removing the @samp{/} from
  5561. file names. This message appears once per @GNUTAR{}
  5562. invocation. It represents something which ought to be told; ignoring
  5563. what it means can cause very serious surprises, later.
  5564. Some people, nevertheless, do not want to see this message. Wanting to
  5565. play really dangerously, one may of course redirect @command{tar} standard
  5566. error to the sink. For example, under @command{sh}:
  5567. @smallexample
  5568. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5569. @end smallexample
  5570. @noindent
  5571. Another solution, both nicer and simpler, would be to change to
  5572. the @file{/} directory first, and then avoid absolute notation.
  5573. For example:
  5574. @smallexample
  5575. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5576. $ @kbd{tar -c -f archive.tar -C / home}
  5577. @end smallexample
  5578. @include getdate.texi
  5579. @node Formats
  5580. @chapter Controlling the Archive Format
  5581. @cindex Tar archive formats
  5582. Due to historical reasons, there are several formats of tar archives.
  5583. All of them are based on the same principles, but have some subtle
  5584. differences that often make them incompatible with each other.
  5585. GNU tar is able to create and handle archives in a variety of formats.
  5586. The most frequently used formats are (in alphabetical order):
  5587. @table @asis
  5588. @item gnu
  5589. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5590. from an early @acronym{POSIX} standard, adding some improvements such as
  5591. sparse file handling and incremental archives. Unfortunately these
  5592. features were implemented in a way incompatible with other archive
  5593. formats.
  5594. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5595. length.
  5596. @item oldgnu
  5597. Format used by @GNUTAR{} of versions prior to 1.12.
  5598. @item v7
  5599. Archive format, compatible with the V7 implementation of tar. This
  5600. format imposes a number of limitations. The most important of them
  5601. are:
  5602. @enumerate
  5603. @item The maximum length of a file name is limited to 99 characters.
  5604. @item The maximum length of a symbolic link is limited to 99 characters.
  5605. @item It is impossible to store special files (block and character
  5606. devices, fifos etc.)
  5607. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5608. octal)
  5609. @item V7 archives do not contain symbolic ownership information (user
  5610. and group name of the file owner).
  5611. @end enumerate
  5612. This format has traditionally been used by Automake when producing
  5613. Makefiles. This practice will change in the future, in the meantime,
  5614. however this means that projects containing filenames more than 99
  5615. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5616. Automake prior to 1.9.
  5617. @item ustar
  5618. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5619. symbolic ownership information. It is also able to store
  5620. special files. However, it imposes several restrictions as well:
  5621. @enumerate
  5622. @item The maximum length of a file name is limited to 256 characters,
  5623. provided that the filename can be split at directory separator in
  5624. two parts, first of them being at most 155 bytes long. So, in most
  5625. cases the maximum file name length will be shorter than 256
  5626. characters.
  5627. @item The maximum length of a symbolic link name is limited to
  5628. 100 characters.
  5629. @item Maximum size of a file the archive is able to accomodate
  5630. is 8GB
  5631. @item Maximum value of UID/GID is 2097151.
  5632. @item Maximum number of bits in device major and minor numbers is 21.
  5633. @end enumerate
  5634. @item star
  5635. Format used by J@"org Schilling @command{star}
  5636. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5637. currently does not produce them.
  5638. @item posix
  5639. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5640. most flexible and feature-rich format. It does not impose any
  5641. restrictions on file sizes or filename lengths. This format is quite
  5642. recent, so not all tar implementations are able to handle it properly.
  5643. However, this format is designed in such a way that any tar
  5644. implementation able to read @samp{ustar} archives will be able to read
  5645. most @samp{posix} archives as well, with the only exception that any
  5646. additional information (such as long file names etc.) will in such
  5647. case be extracted as plain text files along with the files it refers to.
  5648. This archive format will be the default format for future versions
  5649. of @GNUTAR{}.
  5650. @end table
  5651. The following table summarizes the limitations of each of these
  5652. formats:
  5653. @multitable @columnfractions .10 .20 .20 .20 .20
  5654. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  5655. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5656. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5657. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5658. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5659. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5660. @end multitable
  5661. The default format for @GNUTAR{} is defined at compilation
  5662. time. You may check it by running @command{tar --help}, and examining
  5663. the last lines of its output. Usually, @GNUTAR{} is configured
  5664. to create archives in @samp{gnu} format, however, future version will
  5665. switch to @samp{posix}.
  5666. @menu
  5667. * Portability:: Making @command{tar} Archives More Portable
  5668. * Compression:: Using Less Space through Compression
  5669. * Attributes:: Handling File Attributes
  5670. * Standard:: The Standard Format
  5671. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5672. * cpio:: Comparison of @command{tar} and @command{cpio}
  5673. @end menu
  5674. @node Portability
  5675. @section Making @command{tar} Archives More Portable
  5676. Creating a @command{tar} archive on a particular system that is meant to be
  5677. useful later on many other machines and with other versions of @command{tar}
  5678. is more challenging than you might think. @command{tar} archive formats
  5679. have been evolving since the first versions of Unix. Many such formats
  5680. are around, and are not always compatible with each other. This section
  5681. discusses a few problems, and gives some advice about making @command{tar}
  5682. archives more portable.
  5683. One golden rule is simplicity. For example, limit your @command{tar}
  5684. archives to contain only regular files and directories, avoiding
  5685. other kind of special files. Do not attempt to save sparse files or
  5686. contiguous files as such. Let's discuss a few more problems, in turn.
  5687. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  5688. archives and archive labels) in GNU and PAX formats.}
  5689. @menu
  5690. * Portable Names:: Portable Names
  5691. * dereference:: Symbolic Links
  5692. * old:: Old V7 Archives
  5693. * ustar:: Ustar Archives
  5694. * gnu:: GNU and old GNU format archives.
  5695. * posix:: @acronym{POSIX} archives
  5696. * Checksumming:: Checksumming Problems
  5697. * Large or Negative Values:: Large files, negative time stamps, etc.
  5698. @end menu
  5699. @node Portable Names
  5700. @subsection Portable Names
  5701. Use portable file and member names. A name is portable if it contains
  5702. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5703. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5704. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5705. old Unix hosts, limit your file name components to 14 characters or
  5706. less.
  5707. If you intend to have your @command{tar} archives to be read under
  5708. MSDOS, you should not rely on case distinction for file names, and you
  5709. might use the @acronym{GNU} @command{doschk} program for helping you
  5710. further diagnosing illegal MSDOS names, which are even more limited
  5711. than System V's.
  5712. @node dereference
  5713. @subsection Symbolic Links
  5714. @cindex File names, using symbolic links
  5715. @cindex Symbolic link as file name
  5716. @opindex dereference
  5717. Normally, when @command{tar} archives a symbolic link, it writes a
  5718. block to the archive naming the target of the link. In that way, the
  5719. @command{tar} archive is a faithful record of the file system contents.
  5720. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  5721. @command{tar} to archive the files symbolic links point to, instead of
  5722. the links themselves. When this option is used, when @command{tar}
  5723. encounters a symbolic link, it will archive the linked-to file,
  5724. instead of simply recording the presence of a symbolic link.
  5725. The name under which the file is stored in the file system is not
  5726. recorded in the archive. To record both the symbolic link name and
  5727. the file name in the system, archive the file under both names. If
  5728. all links were recorded automatically by @command{tar}, an extracted file
  5729. might be linked to a file name that no longer exists in the file
  5730. system.
  5731. If a linked-to file is encountered again by @command{tar} while creating
  5732. the same archive, an entire second copy of it will be stored. (This
  5733. @emph{might} be considered a bug.)
  5734. So, for portable archives, do not archive symbolic links as such,
  5735. and use @option{--dereference} (@option{-h}): many systems do not support
  5736. symbolic links, and moreover, your distribution might be unusable if
  5737. it contains unresolved symbolic links.
  5738. @node old
  5739. @subsection Old V7 Archives
  5740. @cindex Format, old style
  5741. @cindex Old style format
  5742. @cindex Old style archives
  5743. @cindex v7 archive format
  5744. Certain old versions of @command{tar} cannot handle additional
  5745. information recorded by newer @command{tar} programs. To create an
  5746. archive in V7 format (not ANSI), which can be read by these old
  5747. versions, specify the @option{--format=v7} option in
  5748. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  5749. accepts @option{--portability} or @samp{op-old-archive} for this
  5750. option). When you specify it,
  5751. @command{tar} leaves out information about directories, pipes, fifos,
  5752. contiguous files, and device files, and specifies file ownership by
  5753. group and user IDs instead of group and user names.
  5754. When updating an archive, do not use @option{--format=v7}
  5755. unless the archive was created using this option.
  5756. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5757. @command{tar} program without serious trouble, so this option should
  5758. seldom be needed. On the other hand, most modern @command{tar}s are
  5759. able to read old format archives, so it might be safer for you to
  5760. always use @option{--format=v7} for your distributions.
  5761. @node ustar
  5762. @subsection Ustar Archive Format
  5763. @cindex ustar archive format
  5764. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5765. @code{ustar}. Although it is more flexible than the V7 format, it
  5766. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5767. description of @code{ustar} format). Along with V7 format,
  5768. @code{ustar} format is a good choice for archives intended to be read
  5769. with other implementations of @command{tar}.
  5770. To create archive in @code{ustar} format, use @option{--format=ustar}
  5771. option in conjunction with the @option{--create} (@option{-c}).
  5772. @node gnu
  5773. @subsection @acronym{GNU} and old @GNUTAR{} format
  5774. @cindex GNU archive format
  5775. @cindex Old GNU archive format
  5776. @GNUTAR{} was based on an early draft of the
  5777. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5778. @command{tar}, such as the support for file names longer than 100
  5779. characters, use portions of the @command{tar} header record which were
  5780. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  5781. @acronym{POSIX} have allocated the same parts of the header record for
  5782. other purposes. As a result, @GNUTAR{} format is
  5783. incompatible with the current @acronym{POSIX} specification, and with
  5784. @command{tar} programs that follow it.
  5785. In the majority of cases, @command{tar} will be configured to create
  5786. this format by default. This will change in the future releases, since
  5787. we plan to make @samp{posix} format the default.
  5788. To force creation a @GNUTAR{} archive, use option
  5789. @option{--format=gnu}.
  5790. @node posix
  5791. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  5792. @cindex POSIX archive format
  5793. @cindex PAX archive format
  5794. The version @value{VERSION} of @GNUTAR{} is able
  5795. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  5796. A @acronym{POSIX} conformant archive will be created if @command{tar}
  5797. was given @option{--format=posix} option.
  5798. @node Checksumming
  5799. @subsection Checksumming Problems
  5800. SunOS and HP-UX @command{tar} fail to accept archives created using
  5801. @GNUTAR{} and containing non-ASCII file names, that
  5802. is, file names having characters with the eight bit set, because they
  5803. use signed checksums, while @GNUTAR{} uses unsigned
  5804. checksums while creating archives, as per @acronym{POSIX} standards. On
  5805. reading, @GNUTAR{} computes both checksums and
  5806. accept any. It is somewhat worrying that a lot of people may go
  5807. around doing backup of their files using faulty (or at least
  5808. non-standard) software, not learning about it until it's time to
  5809. restore their missing files with an incompatible file extractor, or
  5810. vice versa.
  5811. @GNUTAR{} compute checksums both ways, and accept
  5812. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5813. wrong checksums. @GNUTAR{} produces the standard
  5814. checksum, however, raising incompatibilities with Sun. That is to
  5815. say, @GNUTAR{} has not been modified to
  5816. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5817. I've been told that more recent Sun @command{tar} now read standard
  5818. archives, so maybe Sun did a similar patch, after all?
  5819. The story seems to be that when Sun first imported @command{tar}
  5820. sources on their system, they recompiled it without realizing that
  5821. the checksums were computed differently, because of a change in
  5822. the default signing of @code{char}'s in their compiler. So they
  5823. started computing checksums wrongly. When they later realized their
  5824. mistake, they merely decided to stay compatible with it, and with
  5825. themselves afterwards. Presumably, but I do not really know, HP-UX
  5826. has chosen that their @command{tar} archives to be compatible with Sun's.
  5827. The current standards do not favor Sun @command{tar} format. In any
  5828. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5829. a @command{tar} able to read the good archives they receive.
  5830. @node Large or Negative Values
  5831. @subsection Large or Negative Values
  5832. @cindex large values
  5833. @cindex future time stamps
  5834. @cindex negative time stamps
  5835. @UNREVISED{}
  5836. The above sections suggest to use @samp{oldest possible} archive
  5837. format if in doubt. However, sometimes it is not possible. If you
  5838. attempt to archive a file whose metadata cannot be represented using
  5839. required format, @GNUTAR{} will print error message and ignore such a
  5840. file. You will than have to switch to a format that is able to
  5841. handle such values. The format summary table (@pxref{Formats}) will
  5842. help you to do so.
  5843. In particular, when trying to archive files larger than 8GB or with
  5844. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  5845. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  5846. @acronym{POSIX} archive formats. When considering which format to
  5847. choose, bear in mind that the @acronym{GNU} format uses
  5848. two's-complement base-256 notation to store values that do not fit
  5849. into standard @acronym{ustar} range. Such archives can generally be
  5850. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  5851. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  5852. example, using two's complement representation for negative time
  5853. stamps that assumes a signed 32-bit @code{time_t} generates archives
  5854. that are not portable to hosts with differing @code{time_t}
  5855. representations.
  5856. On the other hand, @acronym{POSIX} archives, generally speaking, can
  5857. be extracted by any tar implementation that understands older
  5858. @acronym{ustar} format. The only exception are files larger than 8GB.
  5859. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  5860. POSIX-aware tars.}
  5861. @node Compression
  5862. @section Using Less Space through Compression
  5863. @menu
  5864. * gzip:: Creating and Reading Compressed Archives
  5865. * sparse:: Archiving Sparse Files
  5866. @end menu
  5867. @node gzip
  5868. @subsection Creating and Reading Compressed Archives
  5869. @cindex Compressed archives
  5870. @cindex Storing archives in compressed format
  5871. @GNUTAR{} is able to create and read compressed archives. It supports
  5872. @command{gzip} and @command{bzip2} compression programs. For backward
  5873. compatibilty, it also supports @command{compress} command, although
  5874. we strongly recommend against using it, since there is a patent
  5875. covering the algorithm it uses and you could be sued for patent
  5876. infringement merely by running @command{compress}! Besides, it is less
  5877. effective than @command{gzip} and @command{bzip2}.
  5878. Creating a compressed archive is simple: you just specify a
  5879. @dfn{compression option} along with the usual archive creation
  5880. commands. The compression option is @option{-z} (@option{--gzip}) to
  5881. create a @command{gzip} compressed archive, @option{-j}
  5882. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  5883. @option{-Z} (@option{--compress}) to use @command{compress} program.
  5884. For example:
  5885. @smallexample
  5886. $ @kbd{tar cfz archive.tar.gz .}
  5887. @end smallexample
  5888. Reading compressed archive is even simpler: you don't need to specify
  5889. any additional options as @GNUTAR{} recognizes its format
  5890. automatically. Thus, the following commands will list and extract the
  5891. archive created in previous example:
  5892. @smallexample
  5893. # List the compressed archive
  5894. $ @kbd{tar tf archive.tar.gz}
  5895. # Extract the compressed archive
  5896. $ @kbd{tar xf archive.tar.gz}
  5897. @end smallexample
  5898. The only case when you have to specify a decompression option while
  5899. reading the archive is when reading from a pipe or from a tape drive
  5900. that does not support random access. However, in this case @GNUTAR{}
  5901. will indicate which option you should use. For example:
  5902. @smallexample
  5903. $ @kbd{cat archive.tar.gz | tar tf -}
  5904. tar: Archive is compressed. Use -z option
  5905. tar: Error is not recoverable: exiting now
  5906. @end smallexample
  5907. If you see such diagnostics, just add the suggested option to the
  5908. invocation of @GNUTAR{}:
  5909. @smallexample
  5910. $ @kbd{cat archive.tar.gz | tar tfz -}
  5911. @end smallexample
  5912. Notice also, that there are several restrictions on operations on
  5913. compressed archives. First of all, compressed archives cannot be
  5914. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  5915. (@option{--delete}) members from them. Likewise, you cannot append
  5916. another @command{tar} archive to a compressed archive using
  5917. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  5918. compressed.
  5919. The following table summarizes compression options used by @GNUTAR{}.
  5920. @table @option
  5921. @opindex gzip
  5922. @opindex ungzip
  5923. @item -z
  5924. @itemx --gzip
  5925. @itemx --ungzip
  5926. Filter the archive through @command{gzip}.
  5927. You can use @option{--gzip} and @option{--gunzip} on physical devices
  5928. (tape drives, etc.) and remote files as well as on normal files; data
  5929. to or from such devices or remote files is reblocked by another copy
  5930. of the @command{tar} program to enforce the specified (or default) record
  5931. size. The default compression parameters are used; if you need to
  5932. override them, set @env{GZIP} environment variable, e.g.:
  5933. @smallexample
  5934. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  5935. @end smallexample
  5936. @noindent
  5937. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  5938. @command{gzip} explicitly:
  5939. @smallexample
  5940. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  5941. @end smallexample
  5942. @cindex corrupted archives
  5943. About corrupted compressed archives: @command{gzip}'ed files have no
  5944. redundancy, for maximum compression. The adaptive nature of the
  5945. compression scheme means that the compression tables are implicitly
  5946. spread all over the archive. If you lose a few blocks, the dynamic
  5947. construction of the compression tables becomes unsynchronized, and there
  5948. is little chance that you could recover later in the archive.
  5949. There are pending suggestions for having a per-volume or per-file
  5950. compression in @GNUTAR{}. This would allow for viewing the
  5951. contents without decompression, and for resynchronizing decompression at
  5952. every volume or file, in case of corrupted archives. Doing so, we might
  5953. lose some compressibility. But this would have make recovering easier.
  5954. So, there are pros and cons. We'll see!
  5955. @opindex bzip2
  5956. @item -j
  5957. @itemx --bzip2
  5958. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  5959. @opindex compress
  5960. @opindex uncompress
  5961. @item -Z
  5962. @itemx --compress
  5963. @itemx --uncompress
  5964. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  5965. The @acronym{GNU} Project recommends you not use
  5966. @command{compress}, because there is a patent covering the algorithm it
  5967. uses. You could be sued for patent infringement merely by running
  5968. @command{compress}.
  5969. @opindex use-compress-program
  5970. @item --use-compress-program=@var{prog}
  5971. Use external compression program @var{prog}. Use this option if you
  5972. have a compression program that @GNUTAR{} does not support. There
  5973. are two requirements to which @var{prog} should comply:
  5974. First, when called without options, it should read data from standard
  5975. input, compress it and output it on standard output.
  5976. Secondly, if called with @option{-d} argument, it should do exactly
  5977. the opposite, i.e., read the compressed data from the standard input
  5978. and produce uncompressed data on the standard output.
  5979. @end table
  5980. @FIXME{I have one question, or maybe it's a suggestion if there isn't a way
  5981. to do it now. I would like to use @option{--gzip}, but I'd also like
  5982. the output to be fed through a program like @acronym{GNU}
  5983. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5984. to use :-)), basically adding ECC protection on top of compression.
  5985. It seems as if this should be quite easy to do, but I can't work out
  5986. exactly how to go about it. Of course, I can pipe the standard output
  5987. of @command{tar} through @command{ecc}, but then I lose (though I
  5988. haven't started using it yet, I confess) the ability to have
  5989. @command{tar} use @command{rmt} for it's I/O (I think).
  5990. I think the most straightforward thing would be to let me specify a
  5991. general set of filters outboard of compression (preferably ordered,
  5992. so the order can be automatically reversed on input operations, and
  5993. with the options they require specifiable), but beggars shouldn't be
  5994. choosers and anything you decide on would be fine with me.
  5995. By the way, I like @command{ecc} but if (as the comments say) it can't
  5996. deal with loss of block sync, I'm tempted to throw some time at adding
  5997. that capability. Supposing I were to actually do such a thing and
  5998. get it (apparently) working, do you accept contributed changes to
  5999. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  6000. Isn't that exactly the role of the @option{--use-compress-prog=@var{program}} option?
  6001. I never tried it myself, but I suspect you may want to write a
  6002. @var{prog} script or program able to filter stdin to stdout to
  6003. way you want. It should recognize the @option{-d} option, for when
  6004. extraction is needed rather than creation.
  6005. It has been reported that if one writes compressed data (through the
  6006. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  6007. the DLT compression mode, the data will actually get bigger and one will
  6008. end up with less space on the tape.}
  6009. @node sparse
  6010. @subsection Archiving Sparse Files
  6011. @cindex Sparse Files
  6012. @UNREVISED
  6013. @table @option
  6014. @opindex sparse
  6015. @item -S
  6016. @itemx --sparse
  6017. Handle sparse files efficiently.
  6018. @end table
  6019. This option causes all files to be put in the archive to be tested for
  6020. sparseness, and handled specially if they are. The @option{--sparse}
  6021. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  6022. backed up. Using this option dramatically decreases the amount of
  6023. space needed to store such a file.
  6024. In later versions, this option may be removed, and the testing and
  6025. treatment of sparse files may be done automatically with any special
  6026. @acronym{GNU} options. For now, it is an option needing to be specified on
  6027. the command line with the creation or updating of an archive.
  6028. Files in the file system occasionally have ``holes.'' A hole in a file
  6029. is a section of the file's contents which was never written. The
  6030. contents of a hole read as all zeros. On many operating systems,
  6031. actual disk storage is not allocated for holes, but they are counted
  6032. in the length of the file. If you archive such a file, @command{tar}
  6033. could create an archive longer than the original. To have @command{tar}
  6034. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  6035. you use this option, then, for any file using less disk space than
  6036. would be expected from its length, @command{tar} searches the file for
  6037. consecutive stretches of zeros. It then records in the archive for
  6038. the file where the consecutive stretches of zeros are, and only
  6039. archives the ``real contents'' of the file. On extraction (using
  6040. @option{--sparse} is not needed on extraction) any such
  6041. files have holes created wherever the continuous stretches of zeros
  6042. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  6043. won't take more space than the original.
  6044. A file is sparse if it contains blocks of zeros whose existence is
  6045. recorded, but that have no space allocated on disk. When you specify
  6046. the @option{--sparse} option in conjunction with the @option{--create}
  6047. (@option{-c}) operation, @command{tar} tests all files for sparseness
  6048. while archiving. If @command{tar} finds a file to be sparse, it uses a
  6049. sparse representation of the file in the archive. @xref{create}, for
  6050. more information about creating archives.
  6051. @option{--sparse} is useful when archiving files, such as dbm files,
  6052. likely to contain many nulls. This option dramatically
  6053. decreases the amount of space needed to store such an archive.
  6054. @quotation
  6055. @strong{Please Note:} Always use @option{--sparse} when performing file
  6056. system backups, to avoid archiving the expanded forms of files stored
  6057. sparsely in the system.
  6058. Even if your system has no sparse files currently, some may be
  6059. created in the future. If you use @option{--sparse} while making file
  6060. system backups as a matter of course, you can be assured the archive
  6061. will never take more space on the media than the files take on disk
  6062. (otherwise, archiving a disk filled with sparse files might take
  6063. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  6064. @end quotation
  6065. @command{tar} ignores the @option{--sparse} option when reading an archive.
  6066. @table @option
  6067. @item --sparse
  6068. @itemx -S
  6069. Files stored sparsely in the file system are represented sparsely in
  6070. the archive. Use in conjunction with write operations.
  6071. @end table
  6072. However, users should be well aware that at archive creation time,
  6073. @GNUTAR{} still has to read whole disk file to
  6074. locate the @dfn{holes}, and so, even if sparse files use little space
  6075. on disk and in the archive, they may sometimes require inordinate
  6076. amount of time for reading and examining all-zero blocks of a file.
  6077. Although it works, it's painfully slow for a large (sparse) file, even
  6078. though the resulting tar archive may be small. (One user reports that
  6079. dumping a @file{core} file of over 400 megabytes, but with only about
  6080. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  6081. ELC, with full CPU utilization.)
  6082. This reading is required in all cases and is not related to the fact
  6083. the @option{--sparse} option is used or not, so by merely @emph{not}
  6084. using the option, you are not saving time@footnote{Well! We should say
  6085. the whole truth, here. When @option{--sparse} is selected while creating
  6086. an archive, the current @command{tar} algorithm requires sparse files to be
  6087. read twice, not once. We hope to develop a new archive format for saving
  6088. sparse files in which one pass will be sufficient.}.
  6089. Programs like @command{dump} do not have to read the entire file; by
  6090. examining the file system directly, they can determine in advance
  6091. exactly where the holes are and thus avoid reading through them. The
  6092. only data it need read are the actual allocated data blocks.
  6093. @GNUTAR{} uses a more portable and straightforward
  6094. archiving approach, it would be fairly difficult that it does
  6095. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  6096. 1990-12-10:
  6097. @quotation
  6098. What I did say is that you cannot tell the difference between a hole and an
  6099. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  6100. best tells you how many holes there are; it doesn't tell you @emph{where}.
  6101. Just as programs may, conceivably, care what @code{st_blocks} is (care
  6102. to name one that does?), they may also care where the holes are (I have
  6103. no examples of this one either, but it's equally imaginable).
  6104. I conclude from this that good archivers are not portable. One can
  6105. arguably conclude that if you want a portable program, you can in good
  6106. conscience restore files with as many holes as possible, since you can't
  6107. get it right.
  6108. @end quotation
  6109. @node Attributes
  6110. @section Handling File Attributes
  6111. @UNREVISED
  6112. When @command{tar} reads files, it updates their access times. To
  6113. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  6114. reset the access time retroactively or avoid changing it in the first
  6115. place.
  6116. Handling of file attributes
  6117. @table @option
  6118. @opindex atime-preserve
  6119. @item --atime-preserve
  6120. @itemx --atime-preserve=replace
  6121. @itemx --atime-preserve=system
  6122. Preserve the access times of files that are read. This works only for
  6123. files that you own, unless you have superuser privileges.
  6124. @option{--atime-preserve=replace} works on most systems, but it also
  6125. restores the data modification time and updates the status change
  6126. time. Hence it doesn't interact with incremental dumps nicely
  6127. (@pxref{Backups}), and it can set access or data modification times
  6128. incorrectly if other programs access the file while @command{tar} is
  6129. running.
  6130. @option{--atime-preserve=system} avoids changing the access time in
  6131. the first place, if the operating system supports this.
  6132. Unfortunately, this may or may not work on any given operating system
  6133. or file system. If @command{tar} knows for sure it won't work, it
  6134. complains right away.
  6135. Currently @option{--atime-preserve} with no operand defaults to
  6136. @option{--atime-preserve=replace}, but this is intended to change to
  6137. @option{--atime-preserve=system} when the latter is better-supported.
  6138. @opindex touch
  6139. @item -m
  6140. @itemx --touch
  6141. Do not extract data modification time.
  6142. When this option is used, @command{tar} leaves the data modification times
  6143. of the files it extracts as the times when the files were extracted,
  6144. instead of setting it to the times recorded in the archive.
  6145. This option is meaningless with @option{--list} (@option{-t}).
  6146. @opindex same-owner
  6147. @item --same-owner
  6148. Create extracted files with the same ownership they have in the
  6149. archive.
  6150. This is the default behavior for the superuser,
  6151. so this option is meaningful only for non-root users, when @command{tar}
  6152. is executed on those systems able to give files away. This is
  6153. considered as a security flaw by many people, at least because it
  6154. makes quite difficult to correctly account users for the disk space
  6155. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6156. files are easily and silently lost when files are given away.
  6157. When writing an archive, @command{tar} writes the user id and user name
  6158. separately. If it can't find a user name (because the user id is not
  6159. in @file{/etc/passwd}), then it does not write one. When restoring,
  6160. and doing a @code{chmod} like when you use @option{--same-permissions},
  6161. @FIXME{same-owner?}it tries to look the name (if one was written)
  6162. up in @file{/etc/passwd}. If it fails, then it uses the user id
  6163. stored in the archive instead.
  6164. @opindex no-same-owner
  6165. @item --no-same-owner
  6166. @itemx -o
  6167. Do not attempt to restore ownership when extracting. This is the
  6168. default behavior for ordinary users, so this option has an effect
  6169. only for the superuser.
  6170. @opindex numeric-owner
  6171. @item --numeric-owner
  6172. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6173. without user/group name information or such information to be ignored
  6174. when extracting. It effectively disables the generation and/or use
  6175. of user/group name information. This option forces extraction using
  6176. the numeric ids from the archive, ignoring the names.
  6177. This is useful in certain circumstances, when restoring a backup from
  6178. an emergency floppy with different passwd/group files for example.
  6179. It is otherwise impossible to extract files with the right ownerships
  6180. if the password file in use during the extraction does not match the
  6181. one belonging to the file system(s) being extracted. This occurs,
  6182. for example, if you are restoring your files after a major crash and
  6183. had booted from an emergency floppy with no password file or put your
  6184. disk into another machine to do the restore.
  6185. The numeric ids are @emph{always} saved into @command{tar} archives.
  6186. The identifying names are added at create time when provided by the
  6187. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6188. used when moving archives between a collection of machines using
  6189. a centralized management for attribution of numeric ids to users
  6190. and groups. This is often made through using the NIS capabilities.
  6191. When making a @command{tar} file for distribution to other sites, it
  6192. is sometimes cleaner to use a single owner for all files in the
  6193. distribution, and nicer to specify the write permission bits of the
  6194. files as stored in the archive independently of their actual value on
  6195. the file system. The way to prepare a clean distribution is usually
  6196. to have some Makefile rule creating a directory, copying all needed
  6197. files in that directory, then setting ownership and permissions as
  6198. wanted (there are a lot of possible schemes), and only then making a
  6199. @command{tar} archive out of this directory, before cleaning
  6200. everything out. Of course, we could add a lot of options to
  6201. @GNUTAR{} for fine tuning permissions and ownership.
  6202. This is not the good way, I think. @GNUTAR{} is
  6203. already crowded with options and moreover, the approach just explained
  6204. gives you a great deal of control already.
  6205. @opindex same-permissions, short description
  6206. @opindex preserve-permissions, short description
  6207. @item -p
  6208. @itemx --same-permissions
  6209. @itemx --preserve-permissions
  6210. Extract all protection information.
  6211. This option causes @command{tar} to set the modes (access permissions) of
  6212. extracted files exactly as recorded in the archive. If this option
  6213. is not used, the current @code{umask} setting limits the permissions
  6214. on extracted files. This option is by default enabled when
  6215. @command{tar} is executed by a superuser.
  6216. This option is meaningless with @option{--list} (@option{-t}).
  6217. @opindex preserve
  6218. @item --preserve
  6219. Same as both @option{--same-permissions} and @option{--same-order}.
  6220. The @option{--preserve} option has no equivalent short option name.
  6221. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6222. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  6223. @end table
  6224. @node Standard
  6225. @section Basic Tar Format
  6226. @UNREVISED
  6227. While an archive may contain many files, the archive itself is a
  6228. single ordinary file. Like any other file, an archive file can be
  6229. written to a storage device such as a tape or disk, sent through a
  6230. pipe or over a network, saved on the active file system, or even
  6231. stored in another archive. An archive file is not easy to read or
  6232. manipulate without using the @command{tar} utility or Tar mode in
  6233. @acronym{GNU} Emacs.
  6234. Physically, an archive consists of a series of file entries terminated
  6235. by an end-of-archive entry, which consists of two 512 blocks of zero
  6236. bytes. A file
  6237. entry usually describes one of the files in the archive (an
  6238. @dfn{archive member}), and consists of a file header and the contents
  6239. of the file. File headers contain file names and statistics, checksum
  6240. information which @command{tar} uses to detect file corruption, and
  6241. information about file types.
  6242. Archives are permitted to have more than one member with the same
  6243. member name. One way this situation can occur is if more than one
  6244. version of a file has been stored in the archive. For information
  6245. about adding new versions of a file to an archive, see @ref{update}.
  6246. @FIXME-xref{To learn more about having more than one archive member with the
  6247. same name, see -backup node, when it's written.}
  6248. In addition to entries describing archive members, an archive may
  6249. contain entries which @command{tar} itself uses to store information.
  6250. @xref{label}, for an example of such an archive entry.
  6251. A @command{tar} archive file contains a series of blocks. Each block
  6252. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  6253. of as being on magnetic tape, other media are often used.
  6254. Each file archived is represented by a header block which describes
  6255. the file, followed by zero or more blocks which give the contents
  6256. of the file. At the end of the archive file there are two 512-byte blocks
  6257. filled with binary zeros as an end-of-file marker. A reasonable system
  6258. should write such end-of-file marker at the end of an archive, but
  6259. must not assume that such a block exists when reading an archive. In
  6260. particular @GNUTAR{} always issues a warning if it does not encounter it.
  6261. The blocks may be @dfn{blocked} for physical I/O operations.
  6262. Each record of @var{n} blocks (where @var{n} is set by the
  6263. @option{--blocking-factor=@var{512-size}} (@option{-b @var{512-size}}) option to @command{tar}) is written with a single
  6264. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  6265. such a write is a single record. When writing an archive,
  6266. the last record of blocks should be written at the full size, with
  6267. blocks after the zero block containing all zeros. When reading
  6268. an archive, a reasonable system should properly handle an archive
  6269. whose last record is shorter than the rest, or which contains garbage
  6270. records after a zero block.
  6271. The header block is defined in C as follows. In the @GNUTAR{}
  6272. distribution, this is part of file @file{src/tar.h}:
  6273. @smallexample
  6274. @include header.texi
  6275. @end smallexample
  6276. All characters in header blocks are represented by using 8-bit
  6277. characters in the local variant of ASCII. Each field within the
  6278. structure is contiguous; that is, there is no padding used within
  6279. the structure. Each character on the archive medium is stored
  6280. contiguously.
  6281. Bytes representing the contents of files (after the header block
  6282. of each file) are not translated in any way and are not constrained
  6283. to represent characters in any character set. The @command{tar} format
  6284. does not distinguish text files from binary files, and no translation
  6285. of file contents is performed.
  6286. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  6287. @code{gname} are null-terminated character strings. All other fields
  6288. are zero-filled octal numbers in ASCII. Each numeric field of width
  6289. @var{w} contains @var{w} minus 1 digits, and a null.
  6290. The @code{name} field is the file name of the file, with directory names
  6291. (if any) preceding the file name, separated by slashes.
  6292. @FIXME{how big a name before field overflows?}
  6293. The @code{mode} field provides nine bits specifying file permissions
  6294. and three bits to specify the Set UID, Set GID, and Save Text
  6295. (@dfn{sticky}) modes. Values for these bits are defined above.
  6296. When special permissions are required to create a file with a given
  6297. mode, and the user restoring files from the archive does not hold such
  6298. permissions, the mode bit(s) specifying those special permissions
  6299. are ignored. Modes which are not supported by the operating system
  6300. restoring files from the archive will be ignored. Unsupported modes
  6301. should be faked up when creating or updating an archive; e.g., the
  6302. group permission could be copied from the @emph{other} permission.
  6303. The @code{uid} and @code{gid} fields are the numeric user and group
  6304. ID of the file owners, respectively. If the operating system does
  6305. not support numeric user or group IDs, these fields should be ignored.
  6306. The @code{size} field is the size of the file in bytes; linked files
  6307. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6308. particular the @option{--incremental} (@option{-G}) option.}
  6309. The @code{mtime} field is the data modification time of the file at
  6310. the time it was archived. It is the ASCII representation of the octal
  6311. value of the last time the file's contents were modified, represented
  6312. as an integer number of
  6313. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6314. The @code{chksum} field is the ASCII representation of the octal value
  6315. of the simple sum of all bytes in the header block. Each 8-bit
  6316. byte in the header is added to an unsigned integer, initialized to
  6317. zero, the precision of which shall be no less than seventeen bits.
  6318. When calculating the checksum, the @code{chksum} field is treated as
  6319. if it were all blanks.
  6320. The @code{typeflag} field specifies the type of file archived. If a
  6321. particular implementation does not recognize or permit the specified
  6322. type, the file will be extracted as if it were a regular file. As this
  6323. action occurs, @command{tar} issues a warning to the standard error.
  6324. The @code{atime} and @code{ctime} fields are used in making incremental
  6325. backups; they store, respectively, the particular file's access and
  6326. status change times.
  6327. The @code{offset} is used by the @option{--multi-volume} (@option{-M}) option, when
  6328. making a multi-volume archive. The offset is number of bytes into
  6329. the file that we need to restart at to continue the file on the next
  6330. tape, i.e., where we store the location that a continued file is
  6331. continued at.
  6332. The following fields were added to deal with sparse files. A file
  6333. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6334. represented as zeros, i.e., no useful data. A test to see if a file
  6335. is sparse is to look at the number blocks allocated for it versus the
  6336. number of characters in the file; if there are fewer blocks allocated
  6337. for the file than would normally be allocated for a file of that
  6338. size, then the file is sparse. This is the method @command{tar} uses to
  6339. detect a sparse file, and once such a file is detected, it is treated
  6340. differently from non-sparse files.
  6341. Sparse files are often @code{dbm} files, or other database-type files
  6342. which have data at some points and emptiness in the greater part of
  6343. the file. Such files can appear to be very large when an @samp{ls
  6344. -l} is done on them, when in truth, there may be a very small amount
  6345. of important data contained in the file. It is thus undesirable
  6346. to have @command{tar} think that it must back up this entire file, as
  6347. great quantities of room are wasted on empty blocks, which can lead
  6348. to running out of room on a tape far earlier than is necessary.
  6349. Thus, sparse files are dealt with so that these empty blocks are
  6350. not written to the tape. Instead, what is written to the tape is a
  6351. description, of sorts, of the sparse file: where the holes are, how
  6352. big the holes are, and how much data is found at the end of the hole.
  6353. This way, the file takes up potentially far less room on the tape,
  6354. and when the file is extracted later on, it will look exactly the way
  6355. it looked beforehand. The following is a description of the fields
  6356. used to handle a sparse file:
  6357. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6358. sparse} contains two 12-character strings which represent an offset
  6359. into the file and a number of bytes to be written at that offset.
  6360. The offset is absolute, and not relative to the offset in preceding
  6361. array element.
  6362. The header can hold four of these @code{struct sparse} at the moment;
  6363. if more are needed, they are not stored in the header.
  6364. The @code{isextended} flag is set when an @code{extended_header}
  6365. is needed to deal with a file. Note that this means that this flag
  6366. can only be set when dealing with a sparse file, and it is only set
  6367. in the event that the description of the file will not fit in the
  6368. allotted room for sparse structures in the header. In other words,
  6369. an extended_header is needed.
  6370. The @code{extended_header} structure is used for sparse files which
  6371. need more sparse structures than can fit in the header. The header can
  6372. fit 4 such structures; if more are needed, the flag @code{isextended}
  6373. gets set and the next block is an @code{extended_header}.
  6374. Each @code{extended_header} structure contains an array of 21
  6375. sparse structures, along with a similar @code{isextended} flag
  6376. that the header had. There can be an indeterminate number of such
  6377. @code{extended_header}s to describe a sparse file.
  6378. @table @asis
  6379. @item @code{REGTYPE}
  6380. @itemx @code{AREGTYPE}
  6381. These flags represent a regular file. In order to be compatible
  6382. with older versions of @command{tar}, a @code{typeflag} value of
  6383. @code{AREGTYPE} should be silently recognized as a regular file.
  6384. New archives should be created using @code{REGTYPE}. Also, for
  6385. backward compatibility, @command{tar} treats a regular file whose name
  6386. ends with a slash as a directory.
  6387. @item @code{LNKTYPE}
  6388. This flag represents a file linked to another file, of any type,
  6389. previously archived. Such files are identified in Unix by each
  6390. file having the same device and inode number. The linked-to name is
  6391. specified in the @code{linkname} field with a trailing null.
  6392. @item @code{SYMTYPE}
  6393. This represents a symbolic link to another file. The linked-to name
  6394. is specified in the @code{linkname} field with a trailing null.
  6395. @item @code{CHRTYPE}
  6396. @itemx @code{BLKTYPE}
  6397. These represent character special files and block special files
  6398. respectively. In this case the @code{devmajor} and @code{devminor}
  6399. fields will contain the major and minor device numbers respectively.
  6400. Operating systems may map the device specifications to their own
  6401. local specification, or may ignore the entry.
  6402. @item @code{DIRTYPE}
  6403. This flag specifies a directory or sub-directory. The directory
  6404. name in the @code{name} field should end with a slash. On systems where
  6405. disk allocation is performed on a directory basis, the @code{size} field
  6406. will contain the maximum number of bytes (which may be rounded to
  6407. the nearest disk block allocation unit) which the directory may
  6408. hold. A @code{size} field of zero indicates no such limiting. Systems
  6409. which do not support limiting in this manner should ignore the
  6410. @code{size} field.
  6411. @item @code{FIFOTYPE}
  6412. This specifies a FIFO special file. Note that the archiving of a
  6413. FIFO file archives the existence of this file and not its contents.
  6414. @item @code{CONTTYPE}
  6415. This specifies a contiguous file, which is the same as a normal
  6416. file except that, in operating systems which support it, all its
  6417. space is allocated contiguously on the disk. Operating systems
  6418. which do not allow contiguous allocation should silently treat this
  6419. type as a normal file.
  6420. @item @code{A} @dots{} @code{Z}
  6421. These are reserved for custom implementations. Some of these are
  6422. used in the @acronym{GNU} modified format, as described below.
  6423. @end table
  6424. Other values are reserved for specification in future revisions of
  6425. the P1003 standard, and should not be used by any @command{tar} program.
  6426. The @code{magic} field indicates that this archive was output in
  6427. the P1003 archive format. If this field contains @code{TMAGIC},
  6428. the @code{uname} and @code{gname} fields will contain the ASCII
  6429. representation of the owner and group of the file respectively.
  6430. If found, the user and group IDs are used rather than the values in
  6431. the @code{uid} and @code{gid} fields.
  6432. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6433. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6434. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6435. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6436. @node Extensions
  6437. @section @acronym{GNU} Extensions to the Archive Format
  6438. @UNREVISED
  6439. The @acronym{GNU} format uses additional file types to describe new types of
  6440. files in an archive. These are listed below.
  6441. @table @code
  6442. @item GNUTYPE_DUMPDIR
  6443. @itemx 'D'
  6444. This represents a directory and a list of files created by the
  6445. @option{--incremental} (@option{-G}) option. The @code{size} field gives the total
  6446. size of the associated list of files. Each file name is preceded by
  6447. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6448. (The file is a directory, or is not stored in the archive.) Each file
  6449. name is terminated by a null. There is an additional null after the
  6450. last file name.
  6451. @item GNUTYPE_MULTIVOL
  6452. @itemx 'M'
  6453. This represents a file continued from another volume of a multi-volume
  6454. archive created with the @option{--multi-volume} (@option{-M}) option. The original
  6455. type of the file is not given here. The @code{size} field gives the
  6456. maximum size of this piece of the file (assuming the volume does
  6457. not end before the file is written out). The @code{offset} field
  6458. gives the offset from the beginning of the file where this part of
  6459. the file begins. Thus @code{size} plus @code{offset} should equal
  6460. the original size of the file.
  6461. @item GNUTYPE_SPARSE
  6462. @itemx 'S'
  6463. This flag indicates that we are dealing with a sparse file. Note
  6464. that archiving a sparse file requires special operations to find
  6465. holes in the file, which mark the positions of these holes, along
  6466. with the number of bytes of data to be found after the hole.
  6467. @item GNUTYPE_VOLHDR
  6468. @itemx 'V'
  6469. This file type is used to mark the volume header that was given with
  6470. the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option when the archive was created. The @code{name}
  6471. field contains the @code{name} given after the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option.
  6472. The @code{size} field is zero. Only the first file in each volume
  6473. of an archive should have this type.
  6474. @end table
  6475. You may have trouble reading a @acronym{GNU} format archive on a
  6476. non-@acronym{GNU} system if the options @option{--incremental} (@option{-G}),
  6477. @option{--multi-volume} (@option{-M}), @option{--sparse} (@option{-S}), or @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) were
  6478. used when writing the archive. In general, if @command{tar} does not
  6479. use the @acronym{GNU}-added fields of the header, other versions of
  6480. @command{tar} should be able to read the archive. Otherwise, the
  6481. @command{tar} program will give an error, the most likely one being a
  6482. checksum error.
  6483. @node cpio
  6484. @section Comparison of @command{tar} and @command{cpio}
  6485. @UNREVISED
  6486. @FIXME{Reorganize the following material}
  6487. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6488. pathname lengths. The binary and old ASCII formats have a max path
  6489. length of 256, and the new ASCII and CRC ASCII formats have a max
  6490. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6491. with arbitrary pathname lengths, but other @command{cpio} implementations
  6492. may crash unexplainedly trying to read them.
  6493. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6494. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6495. in System V prior to SVR4, and some vendors may have added symlinks
  6496. to their system without enhancing @command{cpio} to know about them.
  6497. Others may have enhanced it in a way other than the way I did it
  6498. at Sun, and which was adopted by AT&T (and which is, I think, also
  6499. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6500. into a later BSD release---I think I gave them my changes).
  6501. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6502. can handle @command{tar} format input, and write it on output, and it
  6503. probably handles symbolic links. They may not have bothered doing
  6504. anything to enhance @command{tar} as a result.)
  6505. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6506. @command{tar} comes with V7, System III, System V, and BSD source;
  6507. @command{cpio} comes only with System III, System V, and later BSD
  6508. (4.3-tahoe and later).
  6509. @command{tar}'s way of handling multiple hard links to a file can handle
  6510. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6511. @command{cpio}s way requires you to play some games (in its "binary"
  6512. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6513. they're 18 bits---it would have to play games with the "file system ID"
  6514. field of the header to make sure that the file system ID/i-number pairs
  6515. of different files were always different), and I don't know which
  6516. @command{cpio}s, if any, play those games. Those that don't might get
  6517. confused and think two files are the same file when they're not, and
  6518. make hard links between them.
  6519. @command{tar}s way of handling multiple hard links to a file places only
  6520. one copy of the link on the tape, but the name attached to that copy
  6521. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6522. way puts one copy for every link, but you can retrieve it using any
  6523. of the names.
  6524. @quotation
  6525. What type of check sum (if any) is used, and how is this calculated.
  6526. @end quotation
  6527. See the attached manual pages for @command{tar} and @command{cpio} format.
  6528. @command{tar} uses a checksum which is the sum of all the bytes in the
  6529. @command{tar} header for a file; @command{cpio} uses no checksum.
  6530. @quotation
  6531. If anyone knows why @command{cpio} was made when @command{tar} was present
  6532. at the unix scene,
  6533. @end quotation
  6534. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6535. generally-available version of UNIX had @command{tar} at the time. I don't
  6536. know whether any version that was generally available @emph{within AT&T}
  6537. had @command{tar}, or, if so, whether the people within AT&T who did
  6538. @command{cpio} knew about it.
  6539. On restore, if there is a corruption on a tape @command{tar} will stop at
  6540. that point, while @command{cpio} will skip over it and try to restore the
  6541. rest of the files.
  6542. The main difference is just in the command syntax and header format.
  6543. @command{tar} is a little more tape-oriented in that everything is blocked
  6544. to start on a record boundary.
  6545. @quotation
  6546. Is there any differences between the ability to recover crashed
  6547. archives between the two of them. (Is there any chance of recovering
  6548. crashed archives at all.)
  6549. @end quotation
  6550. Theoretically it should be easier under @command{tar} since the blocking
  6551. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6552. However, modern @command{cpio}'s and variations have an option to just
  6553. search for the next file header after an error with a reasonable chance
  6554. of resyncing. However, lots of tape driver software won't allow you to
  6555. continue past a media error which should be the only reason for getting
  6556. out of sync unless a file changed sizes while you were writing the
  6557. archive.
  6558. @quotation
  6559. If anyone knows why @command{cpio} was made when @command{tar} was present
  6560. at the unix scene, please tell me about this too.
  6561. @end quotation
  6562. Probably because it is more media efficient (by not blocking everything
  6563. and using only the space needed for the headers where @command{tar}
  6564. always uses 512 bytes per file header) and it knows how to archive
  6565. special files.
  6566. You might want to look at the freely available alternatives. The
  6567. major ones are @command{afio}, @GNUTAR{}, and
  6568. @command{pax}, each of which have their own extensions with some
  6569. backwards compatibility.
  6570. Sparse files were @command{tar}red as sparse files (which you can
  6571. easily test, because the resulting archive gets smaller, and
  6572. @acronym{GNU} @command{cpio} can no longer read it).
  6573. @node Media
  6574. @chapter Tapes and Other Archive Media
  6575. @UNREVISED
  6576. A few special cases about tape handling warrant more detailed
  6577. description. These special cases are discussed below.
  6578. Many complexities surround the use of @command{tar} on tape drives. Since
  6579. the creation and manipulation of archives located on magnetic tape was
  6580. the original purpose of @command{tar}, it contains many features making
  6581. such manipulation easier.
  6582. Archives are usually written on dismountable media---tape cartridges,
  6583. mag tapes, or floppy disks.
  6584. The amount of data a tape or disk holds depends not only on its size,
  6585. but also on how it is formatted. A 2400 foot long reel of mag tape
  6586. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6587. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6588. Magnetic media are re-usable---once the archive on a tape is no longer
  6589. needed, the archive can be erased and the tape or disk used over.
  6590. Media quality does deteriorate with use, however. Most tapes or disks
  6591. should be discarded when they begin to produce data errors. EXABYTE
  6592. tape cartridges should be discarded when they generate an @dfn{error
  6593. count} (number of non-usable bits) of more than 10k.
  6594. Magnetic media are written and erased using magnetic fields, and
  6595. should be protected from such fields to avoid damage to stored data.
  6596. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6597. not a good idea.
  6598. @menu
  6599. * Device:: Device selection and switching
  6600. * Remote Tape Server::
  6601. * Common Problems and Solutions::
  6602. * Blocking:: Blocking
  6603. * Many:: Many archives on one tape
  6604. * Using Multiple Tapes:: Using Multiple Tapes
  6605. * label:: Including a Label in the Archive
  6606. * verify::
  6607. * Write Protection::
  6608. @end menu
  6609. @node Device
  6610. @section Device Selection and Switching
  6611. @UNREVISED
  6612. @table @option
  6613. @item -f [@var{hostname}:]@var{file}
  6614. @itemx --file=[@var{hostname}:]@var{file}
  6615. Use archive file or device @var{file} on @var{hostname}.
  6616. @end table
  6617. This option is used to specify the file name of the archive @command{tar}
  6618. works on.
  6619. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6620. input (when listing or extracting), or writes it to standard output
  6621. (when creating). If the @samp{-} file name is given when updating an
  6622. archive, @command{tar} will read the original archive from its standard
  6623. input, and will write the entire new archive to its standard output.
  6624. If the file name contains a @samp{:}, it is interpreted as
  6625. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6626. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  6627. either case, @command{tar} will invoke the command @command{rsh} (or
  6628. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6629. machine. If you give an alternate login name, it will be given to the
  6630. @command{rsh}.
  6631. Naturally, the remote machine must have an executable
  6632. @command{/usr/libexec/rmt}. This program is free software from the
  6633. University of California, and a copy of the source code can be found
  6634. with the sources for @command{tar}; it's compiled and installed by default.
  6635. The exact path to this utility is determined when configuring the package.
  6636. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6637. your installation prefix. This location may also be overridden at
  6638. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  6639. ---rmt-command}, for detailed description of this option. @xref{Remote
  6640. Tape Server}, for the description of @command{rmt} command).
  6641. If this option is not given, but the environment variable @env{TAPE}
  6642. is set, its value is used; otherwise, old versions of @command{tar}
  6643. used a default archive name (which was picked when @command{tar} was
  6644. compiled). The default is normally set up to be the @dfn{first} tape
  6645. drive or other transportable I/O medium on the system.
  6646. Starting with version 1.11.5, @GNUTAR{} uses
  6647. standard input and standard output as the default device, and I will
  6648. not try anymore supporting automatic device detection at installation
  6649. time. This was failing really in too many cases, it was hopeless.
  6650. This is now completely left to the installer to override standard
  6651. input and standard output for default device, if this seems
  6652. preferable. Further, I think @emph{most} actual usages of
  6653. @command{tar} are done with pipes or disks, not really tapes,
  6654. cartridges or diskettes.
  6655. Some users think that using standard input and output is running
  6656. after trouble. This could lead to a nasty surprise on your screen if
  6657. you forget to specify an output file name---especially if you are going
  6658. through a network or terminal server capable of buffering large amounts
  6659. of output. We had so many bug reports in that area of configuring
  6660. default tapes automatically, and so many contradicting requests, that
  6661. we finally consider the problem to be portably intractable. We could
  6662. of course use something like @samp{/dev/tape} as a default, but this
  6663. is @emph{also} running after various kind of trouble, going from hung
  6664. processes to accidental destruction of real tapes. After having seen
  6665. all this mess, using standard input and output as a default really
  6666. sounds like the only clean choice left, and a very useful one too.
  6667. @GNUTAR{} reads and writes archive in records, I
  6668. suspect this is the main reason why block devices are preferred over
  6669. character devices. Most probably, block devices are more efficient
  6670. too. The installer could also check for @samp{DEFTAPE} in
  6671. @file{<sys/mtio.h>}.
  6672. @table @option
  6673. @opindex force-local, short description
  6674. @item --force-local
  6675. Archive file is local even if it contains a colon.
  6676. @opindex rsh-command
  6677. @item --rsh-command=@var{command}
  6678. Use remote @var{command} instead of @command{rsh}. This option exists
  6679. so that people who use something other than the standard @command{rsh}
  6680. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6681. When this command is not used, the shell command found when
  6682. the @command{tar} program was installed is used instead. This is
  6683. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6684. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6685. The installer may have overridden this by defining the environment
  6686. variable @env{RSH} @emph{at installation time}.
  6687. @item -[0-7][lmh]
  6688. Specify drive and density.
  6689. @opindex multi-volume, short description
  6690. @item -M
  6691. @itemx --multi-volume
  6692. Create/list/extract multi-volume archive.
  6693. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6694. that may be larger than will fit on the medium used to hold it.
  6695. @xref{Multi-Volume Archives}.
  6696. @opindex tape-length, short description
  6697. @item -L @var{num}
  6698. @itemx --tape-length=@var{num}
  6699. Change tape after writing @var{num} x 1024 bytes.
  6700. This option might be useful when your tape drivers do not properly
  6701. detect end of physical tapes. By being slightly conservative on the
  6702. maximum tape length, you might avoid the problem entirely.
  6703. @opindex info-script, short description
  6704. @opindex new-volume-script, short description
  6705. @item -F @var{file}
  6706. @itemx --info-script=@var{file}
  6707. @itemx --new-volume-script=@var{file}
  6708. Execute @file{file} at end of each tape. This implies
  6709. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  6710. description of this option.
  6711. @end table
  6712. @node Remote Tape Server
  6713. @section The Remote Tape Server
  6714. @cindex remote tape drive
  6715. @pindex rmt
  6716. In order to access the tape drive on a remote machine, @command{tar}
  6717. uses the remote tape server written at the University of California at
  6718. Berkeley. The remote tape server must be installed as
  6719. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6720. want to use. @command{tar} calls @command{rmt} by running an
  6721. @command{rsh} or @command{remsh} to the remote machine, optionally
  6722. using a different login name if one is supplied.
  6723. A copy of the source for the remote tape server is provided. It is
  6724. Copyright @copyright{} 1983 by the Regents of the University of
  6725. California, but can be freely distributed. It is compiled and
  6726. installed by default.
  6727. @cindex absolute file names
  6728. Unless you use the @option{--absolute-names} (@option{-P}) option,
  6729. @GNUTAR{} will not allow you to create an archive that contains
  6730. absolute file names (a file name beginning with @samp{/}.) If you try,
  6731. @command{tar} will automatically remove the leading @samp{/} from the
  6732. file names it stores in the archive. It will also type a warning
  6733. message telling you what it is doing.
  6734. When reading an archive that was created with a different
  6735. @command{tar} program, @GNUTAR{} automatically
  6736. extracts entries in the archive which have absolute file names as if
  6737. the file names were not absolute. This is an important feature. A
  6738. visitor here once gave a @command{tar} tape to an operator to restore;
  6739. the operator used Sun @command{tar} instead of @GNUTAR{},
  6740. and the result was that it replaced large portions of
  6741. our @file{/bin} and friends with versions from the tape; needless to
  6742. say, we were unhappy about having to recover the file system from
  6743. backup tapes.
  6744. For example, if the archive contained a file @file{/usr/bin/computoy},
  6745. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6746. relative to the current directory. If you want to extract the files in
  6747. an archive to the same absolute names that they had when the archive
  6748. was created, you should do a @samp{cd /} before extracting the files
  6749. from the archive, or you should either use the @option{--absolute-names}
  6750. option, or use the command @samp{tar -C / @dots{}}.
  6751. @cindex Ultrix 3.1 and write failure
  6752. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6753. can claim that a short write near the end of a tape succeeded,
  6754. when it actually failed. This will result in the -M option not
  6755. working correctly. The best workaround at the moment is to use a
  6756. significantly larger blocking factor than the default 20.
  6757. In order to update an archive, @command{tar} must be able to backspace the
  6758. archive in order to reread or rewrite a record that was just read (or
  6759. written). This is currently possible only on two kinds of files: normal
  6760. disk files (or any other file that can be backspaced with @samp{lseek}),
  6761. and industry-standard 9-track magnetic tape (or any other kind of tape
  6762. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6763. This means that the @option{--append}, @option{--concatenate}, and
  6764. @option{--delete} commands will not work on any other kind of file.
  6765. Some media simply cannot be backspaced, which means these commands and
  6766. options will never be able to work on them. These non-backspacing
  6767. media include pipes and cartridge tape drives.
  6768. Some other media can be backspaced, and @command{tar} will work on them
  6769. once @command{tar} is modified to do so.
  6770. Archives created with the @option{--multi-volume}, @option{--label}, and
  6771. @option{--incremental} (@option{-G}) options may not be readable by other version
  6772. of @command{tar}. In particular, restoring a file that was split over
  6773. a volume boundary will require some careful work with @command{dd}, if
  6774. it can be done at all. Other versions of @command{tar} may also create
  6775. an empty file whose name is that of the volume header. Some versions
  6776. of @command{tar} may create normal files instead of directories archived
  6777. with the @option{--incremental} (@option{-G}) option.
  6778. @node Common Problems and Solutions
  6779. @section Some Common Problems and their Solutions
  6780. @ifclear PUBLISH
  6781. @format
  6782. errors from system:
  6783. permission denied
  6784. no such file or directory
  6785. not owner
  6786. errors from @command{tar}:
  6787. directory checksum error
  6788. header format error
  6789. errors from media/system:
  6790. i/o error
  6791. device busy
  6792. @end format
  6793. @end ifclear
  6794. @node Blocking
  6795. @section Blocking
  6796. @UNREVISED
  6797. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6798. is also confusing to the expert reader. On the other hand, readers
  6799. who are new to the field have a fresh mind, and they may safely skip
  6800. the next two paragraphs, as the remainder of this manual uses those
  6801. two terms in a quite consistent way.
  6802. John Gilmore, the writer of the public domain @command{tar} from which
  6803. @GNUTAR{} was originally derived, wrote (June 1995):
  6804. @quotation
  6805. The nomenclature of tape drives comes from IBM, where I believe
  6806. they were invented for the IBM 650 or so. On IBM mainframes, what
  6807. is recorded on tape are tape blocks. The logical organization of
  6808. data is into records. There are various ways of putting records into
  6809. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6810. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6811. to a block), @code{VB} (variable size records, @var{n} to a block),
  6812. @code{VSB} (variable spanned blocked: variable sized records that can
  6813. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6814. parameter specified this to the operating system.
  6815. The Unix man page on @command{tar} was totally confused about this.
  6816. When I wrote @code{PD TAR}, I used the historically correct terminology
  6817. (@command{tar} writes data records, which are grouped into blocks).
  6818. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  6819. here), and now Fran@,{c}ois has migrated that terminology back
  6820. into the source code too.
  6821. @end quotation
  6822. The term @dfn{physical block} means the basic transfer chunk from or
  6823. to a device, after which reading or writing may stop without anything
  6824. being lost. In this manual, the term @dfn{block} usually refers to
  6825. a disk physical block, @emph{assuming} that each disk block is 512
  6826. bytes in length. It is true that some disk devices have different
  6827. physical blocks, but @command{tar} ignore these differences in its own
  6828. format, which is meant to be portable, so a @command{tar} block is always
  6829. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6830. The term @dfn{logical block} often represents the basic chunk of
  6831. allocation of many disk blocks as a single entity, which the operating
  6832. system treats somewhat atomically; this concept is only barely used
  6833. in @GNUTAR{}.
  6834. The term @dfn{physical record} is another way to speak of a physical
  6835. block, those two terms are somewhat interchangeable. In this manual,
  6836. the term @dfn{record} usually refers to a tape physical block,
  6837. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6838. It is true that archives may be put on disk or used with pipes,
  6839. but nevertheless, @command{tar} tries to read and write the archive one
  6840. @dfn{record} at a time, whatever the medium in use. One record is made
  6841. up of an integral number of blocks, and this operation of putting many
  6842. disk blocks into a single tape block is called @dfn{reblocking}, or
  6843. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6844. the logical organization of many characters into something meaningful
  6845. to the application. The term @dfn{unit record} describes a small set
  6846. of characters which are transmitted whole to or by the application,
  6847. and often refers to a line of text. Those two last terms are unrelated
  6848. to what we call a @dfn{record} in @GNUTAR{}.
  6849. When writing to tapes, @command{tar} writes the contents of the archive
  6850. in chunks known as @dfn{records}. To change the default blocking
  6851. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  6852. @var{512-size}}) option. Each record will then be composed of
  6853. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  6854. @xref{Standard}.) Each file written to the archive uses at least one
  6855. full record. As a result, using a larger record size can result in
  6856. more wasted space for small files. On the other hand, a larger record
  6857. size can often be read and written much more efficiently.
  6858. Further complicating the problem is that some tape drives ignore the
  6859. blocking entirely. For these, a larger record size can still improve
  6860. performance (because the software layers above the tape drive still
  6861. honor the blocking), but not as dramatically as on tape drives that
  6862. honor blocking.
  6863. When reading an archive, @command{tar} can usually figure out the
  6864. record size on itself. When this is the case, and a non-standard
  6865. record size was used when the archive was created, @command{tar} will
  6866. print a message about a non-standard blocking factor, and then operate
  6867. normally. On some tape devices, however, @command{tar} cannot figure
  6868. out the record size itself. On most of those, you can specify a
  6869. blocking factor (with @option{--blocking-factor}) larger than the
  6870. actual blocking factor, and then use the @option{--read-full-records}
  6871. (@option{-B}) option. (If you specify a blocking factor with
  6872. @option{--blocking-factor} and don't use the
  6873. @option{--read-full-records} option, then @command{tar} will not
  6874. attempt to figure out the recording size itself.) On some devices,
  6875. you must always specify the record size exactly with
  6876. @option{--blocking-factor} when reading, because @command{tar} cannot
  6877. figure it out. In any case, use @option{--list} (@option{-t}) before
  6878. doing any extractions to see whether @command{tar} is reading the archive
  6879. correctly.
  6880. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6881. putting them into records is to put a whole number of them (one or
  6882. more) into each record. @command{tar} records are all the same size;
  6883. at the end of the file there's a block containing all zeros, which
  6884. is how you tell that the remainder of the last record(s) are garbage.
  6885. In a standard @command{tar} file (no options), the block size is 512
  6886. and the record size is 10240, for a blocking factor of 20. What the
  6887. @option{--blocking-factor} option does is sets the blocking factor,
  6888. changing the record size while leaving the block size at 512 bytes.
  6889. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6890. most tape drives these days prefer much bigger records in order to
  6891. stream and not waste tape. When writing tapes for myself, some tend
  6892. to use a factor of the order of 2048, say, giving a record size of
  6893. around one megabyte.
  6894. If you use a blocking factor larger than 20, older @command{tar}
  6895. programs might not be able to read the archive, so we recommend this
  6896. as a limit to use in practice. @GNUTAR{}, however,
  6897. will support arbitrarily large record sizes, limited only by the
  6898. amount of virtual memory or the physical characteristics of the tape
  6899. device.
  6900. @menu
  6901. * Format Variations:: Format Variations
  6902. * Blocking Factor:: The Blocking Factor of an Archive
  6903. @end menu
  6904. @node Format Variations
  6905. @subsection Format Variations
  6906. @cindex Format Parameters
  6907. @cindex Format Options
  6908. @cindex Options, archive format specifying
  6909. @cindex Options, format specifying
  6910. @UNREVISED
  6911. Format parameters specify how an archive is written on the archive
  6912. media. The best choice of format parameters will vary depending on
  6913. the type and number of files being archived, and on the media used to
  6914. store the archive.
  6915. To specify format parameters when accessing or creating an archive,
  6916. you can use the options described in the following sections.
  6917. If you do not specify any format parameters, @command{tar} uses
  6918. default parameters. You cannot modify a compressed archive.
  6919. If you create an archive with the @option{--blocking-factor} option
  6920. specified (@pxref{Blocking Factor}), you must specify that
  6921. blocking-factor when operating on the archive. @xref{Formats}, for other
  6922. examples of format parameter considerations.
  6923. @node Blocking Factor
  6924. @subsection The Blocking Factor of an Archive
  6925. @cindex Blocking Factor
  6926. @cindex Record Size
  6927. @cindex Number of blocks per record
  6928. @cindex Number of bytes per record
  6929. @cindex Bytes per record
  6930. @cindex Blocks per record
  6931. @UNREVISED
  6932. @opindex blocking-factor
  6933. The data in an archive is grouped into blocks, which are 512 bytes.
  6934. Blocks are read and written in whole number multiples called
  6935. @dfn{records}. The number of blocks in a record (ie. the size of a
  6936. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6937. The @option{--blocking-factor=@var{512-size}} (@option{-b
  6938. @var{512-size}}) option specifies the blocking factor of an archive.
  6939. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  6940. can be specified at installation. To find out the blocking factor of
  6941. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  6942. This may not work on some devices.
  6943. Records are separated by gaps, which waste space on the archive media.
  6944. If you are archiving on magnetic tape, using a larger blocking factor
  6945. (and therefore larger records) provides faster throughput and allows you
  6946. to fit more data on a tape (because there are fewer gaps). If you are
  6947. archiving on cartridge, a very large blocking factor (say 126 or more)
  6948. greatly increases performance. A smaller blocking factor, on the other
  6949. hand, may be useful when archiving small files, to avoid archiving lots
  6950. of nulls as @command{tar} fills out the archive to the end of the record.
  6951. In general, the ideal record size depends on the size of the
  6952. inter-record gaps on the tape you are using, and the average size of the
  6953. files you are archiving. @xref{create}, for information on
  6954. writing archives.
  6955. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6956. Archives with blocking factors larger than 20 cannot be read
  6957. by very old versions of @command{tar}, or by some newer versions
  6958. of @command{tar} running on old machines with small address spaces.
  6959. With @GNUTAR{}, the blocking factor of an archive is limited
  6960. only by the maximum record size of the device containing the archive,
  6961. or by the amount of available virtual memory.
  6962. Also, on some systems, not using adequate blocking factors, as sometimes
  6963. imposed by the device drivers, may yield unexpected diagnostics. For
  6964. example, this has been reported:
  6965. @smallexample
  6966. Cannot write to /dev/dlt: Invalid argument
  6967. @end smallexample
  6968. @noindent
  6969. In such cases, it sometimes happen that the @command{tar} bundled by
  6970. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6971. requires an explicit specification for the block size,
  6972. which it cannot guess. This yields some people to consider
  6973. @GNUTAR{} is misbehaving, because by comparison,
  6974. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6975. for example, might resolve the problem.
  6976. If you use a non-default blocking factor when you create an archive, you
  6977. must specify the same blocking factor when you modify that archive. Some
  6978. archive devices will also require you to specify the blocking factor when
  6979. reading that archive, however this is not typically the case. Usually, you
  6980. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  6981. reports a non-default record size and then lists the archive members as
  6982. it would normally. To extract files from an archive with a non-standard
  6983. blocking factor (particularly if you're not sure what the blocking factor
  6984. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  6985. specifying a blocking factor larger then the blocking factor of the archive
  6986. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6987. @xref{list}, for more information on the @option{--list} (@option{-t})
  6988. operation. @xref{Reading}, for a more detailed explanation of that option.
  6989. @table @option
  6990. @item --blocking-factor=@var{number}
  6991. @itemx -b @var{number}
  6992. Specifies the blocking factor of an archive. Can be used with any
  6993. operation, but is usually not necessary with @option{--list} (@option{-t}).
  6994. @end table
  6995. Device blocking
  6996. @table @option
  6997. @item -b @var{blocks}
  6998. @itemx --blocking-factor=@var{blocks}
  6999. Set record size to @math{@var{blocks} * 512} bytes.
  7000. This option is used to specify a @dfn{blocking factor} for the archive.
  7001. When reading or writing the archive, @command{tar}, will do reads and writes
  7002. of the archive in records of @math{@var{block}*512} bytes. This is true
  7003. even when the archive is compressed. Some devices requires that all
  7004. write operations be a multiple of a certain size, and so, @command{tar}
  7005. pads the archive out to the next record boundary.
  7006. The default blocking factor is set when @command{tar} is compiled, and is
  7007. typically 20. Blocking factors larger than 20 cannot be read by very
  7008. old versions of @command{tar}, or by some newer versions of @command{tar}
  7009. running on old machines with small address spaces.
  7010. With a magnetic tape, larger records give faster throughput and fit
  7011. more data on a tape (because there are fewer inter-record gaps).
  7012. If the archive is in a disk file or a pipe, you may want to specify
  7013. a smaller blocking factor, since a large one will result in a large
  7014. number of null bytes at the end of the archive.
  7015. When writing cartridge or other streaming tapes, a much larger
  7016. blocking factor (say 126 or more) will greatly increase performance.
  7017. However, you must specify the same blocking factor when reading or
  7018. updating the archive.
  7019. Apparently, Exabyte drives have a physical block size of 8K bytes.
  7020. If we choose our blocksize as a multiple of 8k bytes, then the problem
  7021. seems to disappear. Id est, we are using block size of 112 right
  7022. now, and we haven't had the problem since we switched@dots{}
  7023. With @GNUTAR{} the blocking factor is limited only
  7024. by the maximum record size of the device containing the archive, or by
  7025. the amount of available virtual memory.
  7026. However, deblocking or reblocking is virtually avoided in a special
  7027. case which often occurs in practice, but which requires all the
  7028. following conditions to be simultaneously true:
  7029. @itemize @bullet
  7030. @item
  7031. the archive is subject to a compression option,
  7032. @item
  7033. the archive is not handled through standard input or output, nor
  7034. redirected nor piped,
  7035. @item
  7036. the archive is directly handled to a local disk, instead of any special
  7037. device,
  7038. @item
  7039. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  7040. invocation.
  7041. @end itemize
  7042. If the output goes directly to a local disk, and not through
  7043. stdout, then the last write is not extended to a full record size.
  7044. Otherwise, reblocking occurs. Here are a few other remarks on this
  7045. topic:
  7046. @itemize @bullet
  7047. @item
  7048. @command{gzip} will complain about trailing garbage if asked to
  7049. uncompress a compressed archive on tape, there is an option to turn
  7050. the message off, but it breaks the regularity of simply having to use
  7051. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  7052. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  7053. Gailly, by sending a copy of this message to him.
  7054. @item
  7055. @command{compress} does not show this problem, but as Jean-loup pointed
  7056. out to Michael, @samp{compress -d} silently adds garbage after
  7057. the result of decompression, which tar ignores because it already
  7058. recognized its end-of-file indicator. So this bug may be safely
  7059. ignored.
  7060. @item
  7061. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  7062. but will still return an exit status of 2 which tar reports in turn.
  7063. @command{tar} might ignore the exit status returned, but I hate doing
  7064. that, as it weakens the protection @command{tar} offers users against
  7065. other possible problems at decompression time. If @command{gzip} was
  7066. silently skipping trailing zeros @emph{and} also avoiding setting the
  7067. exit status in this innocuous case, that would solve this situation.
  7068. @item
  7069. @command{tar} should become more solid at not stopping to read a pipe at
  7070. the first null block encountered. This inelegantly breaks the pipe.
  7071. @command{tar} should rather drain the pipe out before exiting itself.
  7072. @end itemize
  7073. @opindex ignore-zeros, short description
  7074. @item -i
  7075. @itemx --ignore-zeros
  7076. Ignore blocks of zeros in archive (means EOF).
  7077. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  7078. of zeros in the archive. Normally a block of zeros indicates the
  7079. end of the archive, but when reading a damaged archive, or one which
  7080. was created by concatenating several archives together, this option
  7081. allows @command{tar} to read the entire archive. This option is not on
  7082. by default because many versions of @command{tar} write garbage after
  7083. the zeroed blocks.
  7084. Note that this option causes @command{tar} to read to the end of the
  7085. archive file, which may sometimes avoid problems when multiple files
  7086. are stored on a single physical tape.
  7087. @opindex read-full-records, short description
  7088. @item -B
  7089. @itemx --read-full-records
  7090. Reblock as we read (for reading 4.2BSD pipes).
  7091. If @option{--read-full-records} is used, @command{tar}
  7092. will not panic if an attempt to read a record from the archive does
  7093. not return a full record. Instead, @command{tar} will keep reading
  7094. until it has obtained a full
  7095. record.
  7096. This option is turned on by default when @command{tar} is reading
  7097. an archive from standard input, or from a remote machine. This is
  7098. because on BSD Unix systems, a read of a pipe will return however
  7099. much happens to be in the pipe, even if it is less than @command{tar}
  7100. requested. If this option was not used, @command{tar} would fail as
  7101. soon as it read an incomplete record from the pipe.
  7102. This option is also useful with the commands for updating an archive.
  7103. @end table
  7104. Tape blocking
  7105. @FIXME{Appropriate options should be moved here from elsewhere.}
  7106. @cindex blocking factor
  7107. @cindex tape blocking
  7108. When handling various tapes or cartridges, you have to take care of
  7109. selecting a proper blocking, that is, the number of disk blocks you
  7110. put together as a single tape block on the tape, without intervening
  7111. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  7112. with no information on it, used for decelerating the tape to a
  7113. full stop, and for later regaining the reading or writing speed.
  7114. When the tape driver starts reading a record, the record has to
  7115. be read whole without stopping, as a tape gap is needed to stop the
  7116. tape motion without loosing information.
  7117. @cindex Exabyte blocking
  7118. @cindex DAT blocking
  7119. Using higher blocking (putting more disk blocks per tape block) will use
  7120. the tape more efficiently as there will be less tape gaps. But reading
  7121. such tapes may be more difficult for the system, as more memory will be
  7122. required to receive at once the whole record. Further, if there is a
  7123. reading error on a huge record, this is less likely that the system will
  7124. succeed in recovering the information. So, blocking should not be too
  7125. low, nor it should be too high. @command{tar} uses by default a blocking of
  7126. 20 for historical reasons, and it does not really matter when reading or
  7127. writing to disk. Current tape technology would easily accommodate higher
  7128. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  7129. We were told that for some DLT drives, the blocking should be a multiple
  7130. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  7131. Other manufacturers may use different recommendations for the same tapes.
  7132. This might also depends of the buffering techniques used inside modern
  7133. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  7134. Others request blocking to be some exponent of two.
  7135. So, there is no fixed rule for blocking. But blocking at read time
  7136. should ideally be the same as blocking used at write time. At one place
  7137. I know, with a wide variety of equipment, they found it best to use a
  7138. blocking of 32 to guarantee that their tapes are fully interchangeable.
  7139. I was also told that, for recycled tapes, prior erasure (by the same
  7140. drive unit that will be used to create the archives) sometimes lowers
  7141. the error rates observed at rewriting time.
  7142. I might also use @option{--number-blocks} instead of
  7143. @option{--block-number}, so @option{--block} will then expand to
  7144. @option{--blocking-factor} unambiguously.
  7145. @node Many
  7146. @section Many Archives on One Tape
  7147. @FIXME{Appropriate options should be moved here from elsewhere.}
  7148. @findex ntape @r{device}
  7149. Most tape devices have two entries in the @file{/dev} directory, or
  7150. entries that come in pairs, which differ only in the minor number for
  7151. this device. Let's take for example @file{/dev/tape}, which often
  7152. points to the only or usual tape device of a given system. There might
  7153. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7154. name is the @emph{rewinding} version of the device, while the name
  7155. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7156. device.
  7157. A rewinding tape device will bring back the tape to its beginning point
  7158. automatically when this device is opened or closed. Since @command{tar}
  7159. opens the archive file before using it and closes it afterwards, this
  7160. means that a simple:
  7161. @smallexample
  7162. $ @kbd{tar cf /dev/tape @var{directory}}
  7163. @end smallexample
  7164. @noindent
  7165. will reposition the tape to its beginning both prior and after saving
  7166. @var{directory} contents to it, thus erasing prior tape contents and
  7167. making it so that any subsequent write operation will destroy what has
  7168. just been saved.
  7169. @cindex tape positioning
  7170. So, a rewinding device is normally meant to hold one and only one file.
  7171. If you want to put more than one @command{tar} archive on a given tape, you
  7172. will need to avoid using the rewinding version of the tape device. You
  7173. will also have to pay special attention to tape positioning. Errors in
  7174. positioning may overwrite the valuable data already on your tape. Many
  7175. people, burnt by past experiences, will only use rewinding devices and
  7176. limit themselves to one file per tape, precisely to avoid the risk of
  7177. such errors. Be fully aware that writing at the wrong position on a
  7178. tape loses all information past this point and most probably until the
  7179. end of the tape, and this destroyed information @emph{cannot} be
  7180. recovered.
  7181. To save @var{directory-1} as a first archive at the beginning of a
  7182. tape, and leave that tape ready for a second archive, you should use:
  7183. @smallexample
  7184. $ @kbd{mt -f /dev/nrtape rewind}
  7185. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  7186. @end smallexample
  7187. @cindex tape marks
  7188. @dfn{Tape marks} are special magnetic patterns written on the tape
  7189. media, which are later recognizable by the reading hardware. These
  7190. marks are used after each file, when there are many on a single tape.
  7191. An empty file (that is to say, two tape marks in a row) signal the
  7192. logical end of the tape, after which no file exist. Usually,
  7193. non-rewinding tape device drivers will react to the close request issued
  7194. by @command{tar} by first writing two tape marks after your archive, and by
  7195. backspacing over one of these. So, if you remove the tape at that time
  7196. from the tape drive, it is properly terminated. But if you write
  7197. another file at the current position, the second tape mark will be
  7198. erased by the new information, leaving only one tape mark between files.
  7199. So, you may now save @var{directory-2} as a second archive after the
  7200. first on the same tape by issuing the command:
  7201. @smallexample
  7202. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7203. @end smallexample
  7204. @noindent
  7205. and so on for all the archives you want to put on the same tape.
  7206. Another usual case is that you do not write all the archives the same
  7207. day, and you need to remove and store the tape between two archive
  7208. sessions. In general, you must remember how many files are already
  7209. saved on your tape. Suppose your tape already has 16 files on it, and
  7210. that you are ready to write the 17th. You have to take care of skipping
  7211. the first 16 tape marks before saving @var{directory-17}, say, by using
  7212. these commands:
  7213. @smallexample
  7214. $ @kbd{mt -f /dev/nrtape rewind}
  7215. $ @kbd{mt -f /dev/nrtape fsf 16}
  7216. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7217. @end smallexample
  7218. In all the previous examples, we put aside blocking considerations, but
  7219. you should do the proper things for that as well. @xref{Blocking}.
  7220. @menu
  7221. * Tape Positioning:: Tape Positions and Tape Marks
  7222. * mt:: The @command{mt} Utility
  7223. @end menu
  7224. @node Tape Positioning
  7225. @subsection Tape Positions and Tape Marks
  7226. @UNREVISED
  7227. Just as archives can store more than one file from the file system,
  7228. tapes can store more than one archive file. To keep track of where
  7229. archive files (or any other type of file stored on tape) begin and
  7230. end, tape archive devices write magnetic @dfn{tape marks} on the
  7231. archive media. Tape drives write one tape mark between files,
  7232. two at the end of all the file entries.
  7233. If you think of data as a series of records "rrrr"'s, and tape marks as
  7234. "*"'s, a tape might look like the following:
  7235. @smallexample
  7236. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7237. @end smallexample
  7238. Tape devices read and write tapes using a read/write @dfn{tape
  7239. head}---a physical part of the device which can only access one
  7240. point on the tape at a time. When you use @command{tar} to read or
  7241. write archive data from a tape device, the device will begin reading
  7242. or writing from wherever on the tape the tape head happens to be,
  7243. regardless of which archive or what part of the archive the tape
  7244. head is on. Before writing an archive, you should make sure that no
  7245. data on the tape will be overwritten (unless it is no longer needed).
  7246. Before reading an archive, you should make sure the tape head is at
  7247. the beginning of the archive you want to read. You can do it manually
  7248. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7249. that automatically (@pxref{Scripted Restoration}).
  7250. If you want to add new archive file entries to a tape, you should
  7251. advance the tape to the end of the existing file entries, backspace
  7252. over the last tape mark, and write the new archive file. If you were
  7253. to add two archives to the example above, the tape might look like the
  7254. following:
  7255. @smallexample
  7256. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7257. @end smallexample
  7258. @node mt
  7259. @subsection The @command{mt} Utility
  7260. @UNREVISED
  7261. @FIXME{Is it true that this only works on non-block devices?
  7262. should explain the difference, (fixed or variable).}
  7263. @xref{Blocking Factor}.
  7264. You can use the @command{mt} utility to advance or rewind a tape past a
  7265. specified number of archive files on the tape. This will allow you
  7266. to move to the beginning of an archive before extracting or reading
  7267. it, or to the end of all the archives before writing a new one.
  7268. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7269. together"?}
  7270. The syntax of the @command{mt} command is:
  7271. @smallexample
  7272. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7273. @end smallexample
  7274. where @var{tapename} is the name of the tape device, @var{number} is
  7275. the number of times an operation is performed (with a default of one),
  7276. and @var{operation} is one of the following:
  7277. @FIXME{is there any use for record operations?}
  7278. @table @option
  7279. @item eof
  7280. @itemx weof
  7281. Writes @var{number} tape marks at the current position on the tape.
  7282. @item fsf
  7283. Moves tape position forward @var{number} files.
  7284. @item bsf
  7285. Moves tape position back @var{number} files.
  7286. @item rewind
  7287. Rewinds the tape. (Ignores @var{number}).
  7288. @item offline
  7289. @itemx rewoff1
  7290. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7291. @item status
  7292. Prints status information about the tape unit.
  7293. @end table
  7294. @FIXME{Is there a better way to frob the spacing on the list?}
  7295. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7296. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  7297. @file{/dev/rmt12}.
  7298. @command{mt} returns a 0 exit status when the operation(s) were
  7299. successful, 1 if the command was unrecognized, and 2 if an operation
  7300. failed.
  7301. @node Using Multiple Tapes
  7302. @section Using Multiple Tapes
  7303. @UNREVISED
  7304. Often you might want to write a large archive, one larger than will fit
  7305. on the actual tape you are using. In such a case, you can run multiple
  7306. @command{tar} commands, but this can be inconvenient, particularly if you
  7307. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7308. Therefore, @command{tar} supports multiple tapes automatically.
  7309. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7310. then @command{tar} will, when it reaches the end of the tape, prompt
  7311. for another tape, and continue the archive. Each tape will have an
  7312. independent archive, and can be read without needing the other. (As
  7313. an exception to this, the file that @command{tar} was archiving when
  7314. it ran out of tape will usually be split between the two archives; in
  7315. this case you need to extract from the first archive, using
  7316. @option{--multi-volume}, and then put in the second tape when
  7317. prompted, so @command{tar} can restore both halves of the file.)
  7318. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7319. You need @GNUTAR{} at both ends to process them properly.
  7320. When prompting for a new tape, @command{tar} accepts any of the following
  7321. responses:
  7322. @table @kbd
  7323. @item ?
  7324. Request @command{tar} to explain possible responses
  7325. @item q
  7326. Request @command{tar} to exit immediately.
  7327. @item n @var{file-name}
  7328. Request @command{tar} to write the next volume on the file @var{file-name}.
  7329. @item !
  7330. Request @command{tar} to run a subshell. This option can be disabled
  7331. by giving @option{--restrict} command line option to @command{tar}.
  7332. @item y
  7333. Request @command{tar} to begin writing the next volume.
  7334. @end table
  7335. (You should only type @samp{y} after you have changed the tape;
  7336. otherwise @command{tar} will write over the volume it just finished.)
  7337. @cindex End-of-archive info script
  7338. @cindex Info script
  7339. @anchor{info-script}
  7340. @opindex info-script
  7341. @opindex new-volume-script
  7342. If you want more elaborate behavior than this, give @command{tar} the
  7343. @option{--info-script=@var{script-name}}
  7344. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7345. @var{script-name}}) option. The file @var{script-name} is expected to
  7346. be a program (or shell script) to be run instead of the normal
  7347. prompting procedure. It is executed without any command line
  7348. arguments. Additional data is passed to it via the following
  7349. environment variables:
  7350. @table @env
  7351. @vrindex TAR_VERSION, info script environment variable
  7352. @item TAR_VERSION
  7353. @GNUTAR{} version number.
  7354. @vrindex TAR_ARCHIVE, info script environment variable
  7355. @item TAR_ARCHIVE
  7356. The name of the archive @command{tar} is processing.
  7357. @vrindex TAR_VOLUME, info script environment variable
  7358. @item TAR_VOLUME
  7359. Ordinal number of the volume @command{tar} is about to start.
  7360. @vrindex TAR_SUBCOMMAND, info script environment variable
  7361. @item TAR_SUBCOMMAND
  7362. Short option describing the operation @command{tar} is executed.
  7363. @xref{Operations}, for a complete list of subcommand options.
  7364. @vrindex TAR_FORMAT, info script environment variable
  7365. @item TAR_FORMAT
  7366. Format of the archive being processed. @xref{Formats}, for a complete
  7367. list of archive format names.
  7368. @end table
  7369. The info script can instruct @command{tar} to use new archive name,
  7370. by writing in to file descriptor 3 (see below for an
  7371. example).
  7372. If the info script fails, @command{tar} exits; otherwise, it begins
  7373. writing the next volume.
  7374. The method @command{tar} uses to detect end of tape is not perfect, and
  7375. fails on some operating systems or on some devices. You can use the
  7376. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7377. @command{tar} can't detect the end of the tape itself. This option
  7378. selects @option{--multi-volume} (@option{-M}) automatically. The
  7379. @var{size} argument should then be the usable size of the tape in
  7380. units of 1024 bytes. But for many devices, and floppy disks in
  7381. particular, this option is never required for real, as far as we know.
  7382. @cindex Volume number file
  7383. @cindex volno file
  7384. @anchor{volno-file}
  7385. @opindex volno-file
  7386. The volume number used by @command{tar} in its tape-change prompt
  7387. can be changed; if you give the
  7388. @option{--volno-file=@var{file-of-number}} option, then
  7389. @var{file-of-number} should be an unexisting file to be created, or
  7390. else, a file already containing a decimal number. That number will be
  7391. used as the volume number of the first volume written. When
  7392. @command{tar} is finished, it will rewrite the file with the
  7393. now-current volume number. (This does not change the volume number
  7394. written on a tape label, as per @ref{label}, it @emph{only} affects
  7395. the number used in the prompt.)
  7396. If you want @command{tar} to cycle through a series of files or tape
  7397. drives, there are three approaches to choose from. First of all, you
  7398. can give @command{tar} multiple @option{--file} options. In this case
  7399. the specified files will be used, in sequence, as the successive
  7400. volumes of the archive. Only when the first one in the sequence needs
  7401. to be used again will @command{tar} prompt for a tape change (or run
  7402. the info script). Secondly, you can use the @samp{n} response to the
  7403. tape-change prompt, and, finally, you can use an info script, that
  7404. writes new archive name to file descriptor. The following example
  7405. illustrates this approach:
  7406. @smallexample
  7407. @group
  7408. #! /bin/sh
  7409. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7410. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7411. case $TAR_SUBCOMMAND in
  7412. -c) ;;
  7413. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7414. ;;
  7415. *) exit 1
  7416. esac
  7417. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7418. @end group
  7419. @end smallexample
  7420. Each volume of a multi-volume archive is an independent @command{tar}
  7421. archive, complete in itself. For example, you can list or extract any
  7422. volume alone; just don't specify @option{--multi-volume}
  7423. (@option{-M}). However, if one file in the archive is split across
  7424. volumes, the only way to extract it successfully is with a
  7425. multi-volume extract command @option{--extract --multi-volume}
  7426. (@option{-xM}) starting on or before the volume where the file begins.
  7427. For example, let's presume someone has two tape drives on a system
  7428. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7429. to switch to the second drive when it needs to write the
  7430. second tape, and then back to the first tape, etc., just do either of:
  7431. @smallexample
  7432. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7433. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7434. @end smallexample
  7435. @menu
  7436. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7437. * Tape Files:: Tape Files
  7438. * Tarcat:: Concatenate Volumes into a Single Archive
  7439. @end menu
  7440. @node Multi-Volume Archives
  7441. @subsection Archives Longer than One Tape or Disk
  7442. @cindex Multi-volume archives
  7443. @UNREVISED
  7444. @opindex multi-volume
  7445. To create an archive that is larger than will fit on a single unit of
  7446. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7447. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7448. archive can be manipulated like any other archive (provided the
  7449. @option{--multi-volume} option is specified), but is stored on more
  7450. than one tape or disk.
  7451. When you specify @option{--multi-volume}, @command{tar} does not report an
  7452. error when it comes to the end of an archive volume (when reading), or
  7453. the end of the media (when writing). Instead, it prompts you to load
  7454. a new storage volume. If the archive is on a magnetic tape, you
  7455. should change tapes when you see the prompt; if the archive is on a
  7456. floppy disk, you should change disks; etc.
  7457. You can read each individual volume of a multi-volume archive as if it
  7458. were an archive by itself. For example, to list the contents of one
  7459. volume, use @option{--list}, without @option{--multi-volume} specified.
  7460. To extract an archive member from one volume (assuming it is described
  7461. that volume), use @option{--extract}, again without
  7462. @option{--multi-volume}.
  7463. If an archive member is split across volumes (ie. its entry begins on
  7464. one volume of the media and ends on another), you need to specify
  7465. @option{--multi-volume} to extract it successfully. In this case, you
  7466. should load the volume where the archive member starts, and use
  7467. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7468. volumes as it needs them. @xref{extracting archives}, for more
  7469. information about extracting archives.
  7470. @option{--info-script=@var{script-name}}
  7471. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7472. @var{script-name}}) (@pxref{info-script}) is like
  7473. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7474. not prompt you directly to change media volumes when a volume is
  7475. full---instead, @command{tar} runs commands you have stored in
  7476. @var{script-name}. For example, this option can be used to eject
  7477. cassettes, or to broadcast messages such as @samp{Someone please come
  7478. change my tape} when performing unattended backups. When
  7479. @var{script-name} is done, @command{tar} will assume that the media
  7480. has been changed.
  7481. Multi-volume archives can be modified like any other archive. To add
  7482. files to a multi-volume archive, you need to only mount the last
  7483. volume of the archive media (and new volumes, if needed). For all
  7484. other operations, you need to use the entire archive.
  7485. If a multi-volume archive was labeled using
  7486. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7487. (@pxref{label}) when it was created, @command{tar} will not
  7488. automatically label volumes which are added later. To label
  7489. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7490. in conjunction with the @option{--append}, @option{--update} or
  7491. @option{--concatenate} operation.
  7492. @cindex Labeling multi-volume archives
  7493. @FIXME{example}
  7494. @FIXME{There should be a sample program here, including an exit
  7495. before end. Is the exit status even checked in tar? :-(}
  7496. @table @option
  7497. @item --multi-volume
  7498. @itemx -M
  7499. Creates a multi-volume archive, when used in conjunction with
  7500. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7501. archive, specify @option{--multi-volume} in conjunction with that
  7502. operation.
  7503. @item --info-script=@var{program-file}
  7504. @itemx --new-volume-script=@var{program-file}
  7505. @itemx -F @var{program-file}
  7506. Creates a multi-volume archive via a script. Used in conjunction with
  7507. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7508. @end table
  7509. Beware that there is @emph{no} real standard about the proper way, for
  7510. a @command{tar} archive, to span volume boundaries. If you have a
  7511. multi-volume created by some vendor's @command{tar}, there is almost
  7512. no chance you could read all the volumes with @GNUTAR{}.
  7513. The converse is also true: you may not expect
  7514. multi-volume archives created by @GNUTAR{} to be
  7515. fully recovered by vendor's @command{tar}. Since there is little
  7516. chance that, in mixed system configurations, some vendor's
  7517. @command{tar} will work on another vendor's machine, and there is a
  7518. great chance that @GNUTAR{} will work on most of
  7519. them, your best bet is to install @GNUTAR{} on all
  7520. machines between which you know exchange of files is possible.
  7521. @node Tape Files
  7522. @subsection Tape Files
  7523. @UNREVISED
  7524. To give the archive a name which will be recorded in it, use the
  7525. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7526. option. This will write a special block identifying
  7527. @var{volume-label} as the name of the archive to the front of the
  7528. archive which will be displayed when the archive is listed with
  7529. @option{--list}. If you are creating a multi-volume archive with
  7530. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7531. volume label will have @samp{Volume @var{nnn}} appended to the name
  7532. you give, where @var{nnn} is the number of the volume of the archive.
  7533. (If you use the @option{--label=@var{volume-label}}) option when
  7534. reading an archive, it checks to make sure the label on the tape
  7535. matches the one you give. @xref{label}.
  7536. When @command{tar} writes an archive to tape, it creates a single
  7537. tape file. If multiple archives are written to the same tape, one
  7538. after the other, they each get written as separate tape files. When
  7539. extracting, it is necessary to position the tape at the right place
  7540. before running @command{tar}. To do this, use the @command{mt} command.
  7541. For more information on the @command{mt} command and on the organization
  7542. of tapes into a sequence of tape files, see @ref{mt}.
  7543. People seem to often do:
  7544. @smallexample
  7545. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7546. @end smallexample
  7547. or such, for pushing a common date in all volumes or an archive set.
  7548. @node Tarcat
  7549. @subsection Concatenate Volumes into a Single Archive
  7550. @pindex tarcat
  7551. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7552. archive to a single @command{tar} archive. Simply concatenating all
  7553. volumes into one will not work, since each volume carries an additional
  7554. information at the beginning. @GNUTAR{} is shipped with the shell
  7555. script @command{tarcat} designed for this purpose.
  7556. The script takes a list of files comprising a multi-volume archive
  7557. and creates the resulting archive at the standard output. For example:
  7558. @smallexample
  7559. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  7560. @end smallexample
  7561. The script implements a simple heuristics to determine the format of
  7562. the first volume file and to decide how to process the rest of the
  7563. files. However, it makes no attempt to verify whether the files are
  7564. given in order or even if they are valid @command{tar} archives.
  7565. It uses @command{dd} and does not filter its standard error, so you
  7566. will usually see lots of spurious messages.
  7567. @FIXME{The script is not installed. Should we install it?}
  7568. @node label
  7569. @section Including a Label in the Archive
  7570. @cindex Labeling an archive
  7571. @cindex Labels on the archive media
  7572. @UNREVISED
  7573. @opindex label
  7574. To avoid problems caused by misplaced paper labels on the archive
  7575. media, you can include a @dfn{label} entry---an archive member which
  7576. contains the name of the archive---in the archive itself. Use the
  7577. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7578. option in conjunction with the @option{--create} operation to include
  7579. a label entry in the archive as it is being created.
  7580. @table @option
  7581. @item --label=@var{archive-label}
  7582. @itemx -V @var{archive-label}
  7583. Includes an @dfn{archive-label} at the beginning of the archive when
  7584. the archive is being created, when used in conjunction with the
  7585. @option{--create} operation. Checks to make sure the archive label
  7586. matches the one specified (when used in conjunction with any other
  7587. operation.
  7588. @end table
  7589. If you create an archive using both
  7590. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7591. and @option{--multi-volume} (@option{-M}), each volume of the archive
  7592. will have an archive label of the form @samp{@var{archive-label}
  7593. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7594. next, and so on. @xref{Using Multiple Tapes}, for information on
  7595. creating multiple volume archives.
  7596. @cindex Volume label, listing
  7597. @cindex Listing volume label
  7598. The volume label will be displayed by @option{--list} along with
  7599. the file contents. If verbose display is requested, it will also be
  7600. explicitely marked as in the example below:
  7601. @smallexample
  7602. @group
  7603. $ @kbd{tar --verbose --list --file=iamanarchive}
  7604. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7605. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  7606. @end group
  7607. @end smallexample
  7608. @opindex test-label
  7609. @anchor{--test-label option}
  7610. However, @option{--list} option will cause listing entire
  7611. contents of the archive, which may be undesirable (for example, if the
  7612. archive is stored on a tape). You can request checking only the volume
  7613. by specifying @option{--test-label} option. This option reads only the
  7614. first block of an archive, so it can be used with slow storage
  7615. devices. For example:
  7616. @smallexample
  7617. @group
  7618. $ @kbd{tar --test-label --file=iamanarchive}
  7619. iamalabel
  7620. @end group
  7621. @end smallexample
  7622. If @option{--test-label} is used with a single command line
  7623. argument, @command{tar} compares the volume label with the
  7624. argument. It exits with code 0 if the two strings match, and with code
  7625. 2 otherwise. In this case no output is displayed. For example:
  7626. @smallexample
  7627. @group
  7628. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  7629. @result{} 0
  7630. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  7631. @result{} 1
  7632. @end group
  7633. @end smallexample
  7634. If you request any operation, other than @option{--create}, along
  7635. with using @option{--label} option, @command{tar} will first check if
  7636. the archive label matches the one specified and will refuse to proceed
  7637. if it does not. Use this as a safety precaution to avoid accidentally
  7638. overwriting existing archives. For example, if you wish to add files
  7639. to @file{archive}, presumably labelled with string @samp{My volume},
  7640. you will get:
  7641. @smallexample
  7642. @group
  7643. $ @kbd{tar -rf archive --label 'My volume' .}
  7644. tar: Archive not labeled to match `My volume'
  7645. @end group
  7646. @end smallexample
  7647. @noindent
  7648. in case its label does not match. This will work even if
  7649. @file{archive} is not labelled at all.
  7650. Similarly, @command{tar} will refuse to list or extract the
  7651. archive if its label doesn't match the @var{archive-label}
  7652. specified. In those cases, @var{archive-label} argument is interpreted
  7653. as a globbing-style pattern which must match the actual magnetic
  7654. volume label. @xref{exclude}, for a precise description of how match
  7655. is attempted@footnote{Previous versions of @command{tar} used full
  7656. regular expression matching, or before that, only exact string
  7657. matching, instead of wildcard matchers. We decided for the sake of
  7658. simplicity to use a uniform matching device through
  7659. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  7660. the volume label matcher will also suffix @var{archive-label} by
  7661. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  7662. up. Since the volume numbering is automatically added in labels at
  7663. creation time, it sounded logical to equally help the user taking care
  7664. of it when the archive is being read.
  7665. The @option{--label} was once called @option{--volume}, but is not
  7666. available under that name anymore.
  7667. You can also use @option{--label} to get a common information on
  7668. all tapes of a series. For having this information different in each
  7669. series created through a single script used on a regular basis, just
  7670. manage to get some date string as part of the label. For example:
  7671. @smallexample
  7672. @group
  7673. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7674. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7675. --volume="Daily backup for `date +%Y-%m-%d`"}
  7676. @end group
  7677. @end smallexample
  7678. Also note that each label has its own date and time, which corresponds
  7679. to when @GNUTAR{} initially attempted to write it,
  7680. often soon after the operator launches @command{tar} or types the
  7681. carriage return telling that the next tape is ready. Comparing date
  7682. labels does give an idea of tape throughput only if the delays for
  7683. rewinding tapes and the operator switching them were negligible, which
  7684. is usually not the case.
  7685. @node verify
  7686. @section Verifying Data as It is Stored
  7687. @cindex Verifying a write operation
  7688. @cindex Double-checking a write operation
  7689. @table @option
  7690. @item -W
  7691. @itemx --verify
  7692. @opindex verify, short description
  7693. Attempt to verify the archive after writing.
  7694. @end table
  7695. This option causes @command{tar} to verify the archive after writing it.
  7696. Each volume is checked after it is written, and any discrepancies
  7697. are recorded on the standard error output.
  7698. Verification requires that the archive be on a back-space-able medium.
  7699. This means pipes, some cartridge tape drives, and some other devices
  7700. cannot be verified.
  7701. You can insure the accuracy of an archive by comparing files in the
  7702. system with archive members. @command{tar} can compare an archive to the
  7703. file system as the archive is being written, to verify a write
  7704. operation, or can compare a previously written archive, to insure that
  7705. it is up to date.
  7706. @opindex verify, using with @option{--create}
  7707. @opindex create, using with @option{--verify}
  7708. To check for discrepancies in an archive immediately after it is
  7709. written, use the @option{--verify} (@option{-W}) option in conjunction with
  7710. the @option{--create} operation. When this option is
  7711. specified, @command{tar} checks archive members against their counterparts
  7712. in the file system, and reports discrepancies on the standard error.
  7713. To verify an archive, you must be able to read it from before the end
  7714. of the last written entry. This option is useful for detecting data
  7715. errors on some tapes. Archives written to pipes, some cartridge tape
  7716. drives, and some other devices cannot be verified.
  7717. One can explicitly compare an already made archive with the file
  7718. system by using the @option{--compare} (@option{--diff}, @option{-d})
  7719. option, instead of using the more automatic @option{--verify} option.
  7720. @xref{compare}.
  7721. Note that these two options have a slightly different intent. The
  7722. @option{--compare} option checks how identical are the logical contents of some
  7723. archive with what is on your disks, while the @option{--verify} option is
  7724. really for checking if the physical contents agree and if the recording
  7725. media itself is of dependable quality. So, for the @option{--verify}
  7726. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7727. the archive, while it lets the speed optimization undisturbed for the
  7728. @option{--compare} option. If you nevertheless use @option{--compare} for
  7729. media verification, you may have to defeat the in-memory cache yourself,
  7730. maybe by opening and reclosing the door latch of your recording unit,
  7731. forcing some doubt in your operating system about the fact this is really
  7732. the same volume as the one just written or read.
  7733. The @option{--verify} option would not be necessary if drivers were indeed
  7734. able to detect dependably all write failures. This sometimes require many
  7735. magnetic heads, some able to read after the writes occurred. One would
  7736. not say that drivers unable to detect all cases are necessarily flawed,
  7737. as long as programming is concerned.
  7738. The @option{--verify} (@option{-W}) option will not work in
  7739. conjunction with the @option{--multi-volume} (@option{-M}) option or
  7740. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  7741. and @option{--delete} operations. @xref{Operations}, for more
  7742. information on these operations.
  7743. Also, since @command{tar} normally strips leading @samp{/} from file
  7744. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  7745. /tmp/foo.tar /etc} will work as desired only if the working directory is
  7746. @file{/}, as @command{tar} uses the archive's relative member names
  7747. (e.g., @file{etc/motd}) when verifying the archive.
  7748. @node Write Protection
  7749. @section Write Protection
  7750. Almost all tapes and diskettes, and in a few rare cases, even disks can
  7751. be @dfn{write protected}, to protect data on them from being changed.
  7752. Once an archive is written, you should write protect the media to prevent
  7753. the archive from being accidentally overwritten or deleted. (This will
  7754. protect the archive from being changed with a tape or floppy drive---it
  7755. will not protect it from magnet fields or other physical hazards).
  7756. The write protection device itself is usually an integral part of the
  7757. physical media, and can be a two position (write enabled/write
  7758. disabled) switch, a notch which can be popped out or covered, a ring
  7759. which can be removed from the center of a tape reel, or some other
  7760. changeable feature.
  7761. @node Changes
  7762. @appendix Changes
  7763. This appendix lists some important user-visible changes between
  7764. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  7765. version of this document is available at
  7766. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  7767. @GNUTAR{} documentation page}.
  7768. @table @asis
  7769. @item Use of globbing patterns when listing and extracting.
  7770. Previous versions of GNU tar assumed shell-style globbing when
  7771. extracting from or listing an archive. For example:
  7772. @smallexample
  7773. $ @kbd{tar xf foo.tar '*.c'}
  7774. @end smallexample
  7775. would extract all files whose names end in @samp{.c}. This behavior
  7776. was not documented and was incompatible with traditional tar
  7777. implementations. Therefore, starting from version 1.15.91, GNU tar
  7778. no longer uses globbing by default. For example, the above invocation
  7779. is now interpreted as a request to extract from the archive the file
  7780. named @file{*.c}.
  7781. To facilitate transition to the new behavior for those users who got
  7782. used to the previous incorrect one, @command{tar} will print a warning
  7783. if it finds out that a requested member was not found in the archive
  7784. and its name looks like a globbing pattern. For example:
  7785. @smallexample
  7786. $ @kbd{tar xf foo.tar '*.c'}
  7787. tar: Pattern matching characters used in file names. Please,
  7788. tar: use --wildcards to enable pattern matching, or --no-wildcards to
  7789. tar: suppress this warning.
  7790. tar: *.c: Not found in archive
  7791. tar: Error exit delayed from previous errors
  7792. @end smallexample
  7793. To treat member names as globbing patterns, use --wildcards option.
  7794. If you want to tar to mimic the behavior of versions prior to 1.15.91,
  7795. add this option to your @env{TAR_OPTIONS} variable.
  7796. @xref{Wildcards}, for the detailed discussion of the use of globbing
  7797. patterns by @GNUTAR{}.
  7798. @item Use of short option @option{-o}.
  7799. Earlier versions of @GNUTAR{} understood @option{-o} command line
  7800. option as a synonym for @option{--old-archive}.
  7801. @GNUTAR{} starting from version 1.13.90 understands this option as
  7802. a synonym for @option{--no-same-owner}. This is compatible with
  7803. UNIX98 @command{tar} implementations.
  7804. However, to facilitate transition, @option{-o} option retains its
  7805. old semantics when it is used with one of archive-creation commands.
  7806. Users are encouraged to use @option{--format=oldgnu} instead.
  7807. It is especially important, since versions of @acronym{GNU} Automake
  7808. up to and including 1.8.4 invoke tar with this option to produce
  7809. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  7810. of this issue and its implications.
  7811. @FIXME{Change the first argument to tar-formats if and when Automake
  7812. people accept my patch to the documentation, and the new Automake is
  7813. out --Sergey 2006-05-25}.
  7814. @xref{Options, tar-v7, Changing Automake's Behavior,
  7815. automake, GNU Automake}, for a description on how to use various
  7816. archive formats with @command{automake}.
  7817. Future versions of @GNUTAR{} will understand @option{-o} only as a
  7818. synonym for @option{--no-same-owner}.
  7819. @item Use of short option @option{-l}
  7820. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  7821. synonym for @option{--one-file-system}. Since such usage contradicted
  7822. to UNIX98 specification and harmed compatibility with other
  7823. implementation, it was declared deprecated in version 1.14. However,
  7824. to facilitate transition to its new semantics, it was supported by
  7825. versions 1.15 and 1.15.90. The present use of @option{-l} as a short
  7826. variant of @option{--check-links} was introduced in version 1.15.91.
  7827. @item Use of options @option{--portability} and @option{--old-archive}
  7828. These options are deprecated. Please use @option{--format=v7} instead.
  7829. @item Use of option @option{--posix}
  7830. This option is deprecated. Please use @option{--format=posix} instead.
  7831. @end table
  7832. @node Configuring Help Summary
  7833. @appendix Configuring Help Summary
  7834. Running @kbd{tar --help} displays the short @command{tar} option
  7835. summary (@pxref{help}). This summary is organised by @dfn{groups} of
  7836. semantically close options. The options within each group are printed
  7837. in the following order: a short option, eventually followed by a list
  7838. of corresponding long option names, followed by a short description of
  7839. the option. For example, here is an excerpt from the actual @kbd{tar
  7840. --help} output:
  7841. @verbatim
  7842. Main operation mode:
  7843. -A, --catenate, --concatenate append tar files to an archive
  7844. -c, --create create a new archive
  7845. -d, --diff, --compare find differences between archive and
  7846. file system
  7847. --delete delete from the archive
  7848. @end verbatim
  7849. @vrindex ARGP_HELP_FMT, environment variable
  7850. The exact visual representation of the help output is configurable via
  7851. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  7852. is a comma-separated list of @dfn{format variable} assignments. There
  7853. are two kinds of format variables. An @dfn{offset variable} keeps the
  7854. offset of some part of help output text from the leftmost column on
  7855. the screen. A @dfn{boolean} variable is a flag that toggles some
  7856. output feature on or off. Depending on the type of the corresponding
  7857. variable, there are two kinds of assignments:
  7858. @table @asis
  7859. @item Offset assignment
  7860. The assignment to an offset variable has the following syntax:
  7861. @smallexample
  7862. @var{variable}=@var{value}
  7863. @end smallexample
  7864. @noindent
  7865. where @var{variable} is the variable name, and @var{value} is a
  7866. numeric value to be assigned to the variable.
  7867. @item Boolean assignment
  7868. To assign @code{true} value to a variable, simply put this variable name. To
  7869. assign @code{false} value, prefix the variable name with @samp{no-}. For
  7870. example:
  7871. @smallexample
  7872. @group
  7873. # Assign @code{true} value:
  7874. dup-args
  7875. # Assign @code{false} value:
  7876. no-dup-args
  7877. @end group
  7878. @end smallexample
  7879. @end table
  7880. Following variables are declared:
  7881. @deftypevr {Help Output} boolean dup-args
  7882. If true, arguments for an option are shown with both short and long
  7883. options, even when a given option has both forms, for example:
  7884. @smallexample
  7885. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  7886. @end smallexample
  7887. If false, then if an option has both short and long forms, the
  7888. argument is only shown with the long one, for example:
  7889. @smallexample
  7890. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7891. @end smallexample
  7892. @noindent
  7893. and a message indicating that the argument is applicable to both
  7894. forms is printed below the options. This message can be disabled
  7895. using @code{dup-args-note} (see below).
  7896. The default is false.
  7897. @end deftypevr
  7898. @deftypevr {Help Output} boolean dup-args-note
  7899. If this variable is true, which is the default, the following notice
  7900. is displayed at the end of the help output:
  7901. @quotation
  7902. Mandatory or optional arguments to long options are also mandatory or
  7903. optional for any corresponding short options.
  7904. @end quotation
  7905. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  7906. variables @code{dup-args} or @code{dup-args-note} should be set.
  7907. @end deftypevr
  7908. @deftypevr {Help Output} offset short-opt-col
  7909. Column in which short options start. Default is 2.
  7910. @smallexample
  7911. @group
  7912. $ @kbd{tar --help|grep ARCHIVE}
  7913. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7914. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  7915. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7916. @end group
  7917. @end smallexample
  7918. @end deftypevr
  7919. @deftypevr {Help Output} offset long-opt-col
  7920. Column in which long options start. Default is 6. For example:
  7921. @smallexample
  7922. @group
  7923. $ @kbd{tar --help|grep ARCHIVE}
  7924. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7925. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  7926. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7927. @end group
  7928. @end smallexample
  7929. @end deftypevr
  7930. @deftypevr {Help Output} offset doc-opt-col
  7931. Column in which @dfn{doc options} start. A doc option isn't actually
  7932. an option, but rather an arbitrary piece of documentation that is
  7933. displayed in much the same manner as the options. For example, in
  7934. the description of @option{--format} option:
  7935. @smallexample
  7936. @group
  7937. -H, --format=FORMAT create archive of the given format.
  7938. FORMAT is one of the following:
  7939. gnu GNU tar 1.13.x format
  7940. oldgnu GNU format as per tar <= 1.12
  7941. pax POSIX 1003.1-2001 (pax) format
  7942. posix same as pax
  7943. ustar POSIX 1003.1-1988 (ustar) format
  7944. v7 old V7 tar format
  7945. @end group
  7946. @end smallexample
  7947. @noindent
  7948. the format names are doc options. Thus, if you set
  7949. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  7950. will look as follows:
  7951. @smallexample
  7952. @group
  7953. -H, --format=FORMAT create archive of the given format.
  7954. FORMAT is one of the following:
  7955. gnu GNU tar 1.13.x format
  7956. oldgnu GNU format as per tar <= 1.12
  7957. pax POSIX 1003.1-2001 (pax) format
  7958. posix same as pax
  7959. ustar POSIX 1003.1-1988 (ustar) format
  7960. v7 old V7 tar format
  7961. @end group
  7962. @end smallexample
  7963. @end deftypevr
  7964. @deftypevr {Help Output} offset opt-doc-col
  7965. Column in which option description starts. Default is 29.
  7966. @smallexample
  7967. @group
  7968. $ @kbd{tar --help|grep ARCHIVE}
  7969. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7970. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  7971. -f, --file=ARCHIVE use archive file or device ARCHIVE
  7972. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  7973. -f, --file=ARCHIVE
  7974. use archive file or device ARCHIVE
  7975. @end group
  7976. @end smallexample
  7977. @noindent
  7978. Notice, that the description starts on a separate line if
  7979. @code{opt-doc-col} value is too small.
  7980. @end deftypevr
  7981. @deftypevr {Help Output} offset header-col
  7982. Column in which @dfn{group headers} are printed. A group header is a
  7983. descriptive text preceding an option group. For example, in the
  7984. following text:
  7985. @verbatim
  7986. Main operation mode:
  7987. -A, --catenate, --concatenate append tar files to
  7988. an archive
  7989. -c, --create create a new archive
  7990. @end verbatim
  7991. @noindent
  7992. @samp{Main operation mode:} is the group header.
  7993. The default value is 1.
  7994. @end deftypevr
  7995. @deftypevr {Help Output} offset usage-indent
  7996. Indentation of wrapped usage lines. Affects @option{--usage}
  7997. output. Default is 12.
  7998. @end deftypevr
  7999. @deftypevr {Help Output} offset rmargin
  8000. Right margin of the text output. Used for wrapping.
  8001. @end deftypevr
  8002. @node Genfile
  8003. @appendix Genfile
  8004. @include genfile.texi
  8005. @node Snapshot Files
  8006. @appendix Format of the Incremental Snapshot Files
  8007. @include snapshot.texi
  8008. @node Free Software Needs Free Documentation
  8009. @appendix Free Software Needs Free Documentation
  8010. @include freemanuals.texi
  8011. @node Copying This Manual
  8012. @appendix Copying This Manual
  8013. @menu
  8014. * GNU Free Documentation License:: License for copying this manual
  8015. @end menu
  8016. @include fdl.texi
  8017. @node Index of Command Line Options
  8018. @appendix Index of Command Line Options
  8019. This appendix contains an index of all @GNUTAR{} long command line
  8020. options. The options are listed without the preceeding double-dash.
  8021. @FIXME{@itemize
  8022. @item Make sure @emph{all} options are indexed.
  8023. @item Provide an index of short options
  8024. @end itemize}
  8025. @printindex op
  8026. @node Index
  8027. @appendix Index
  8028. @printindex cp
  8029. @summarycontents
  8030. @contents
  8031. @bye
  8032. @c Local variables:
  8033. @c texinfo-column-for-description: 32
  8034. @c End: