tar.texi 379 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055
  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. * quoting styles::
  153. How to Add Files to Existing Archives: @option{--append}
  154. * appending files:: Appending Files to an Archive
  155. * multiple::
  156. Updating an Archive
  157. * how to update::
  158. Options Used by @option{--create}
  159. * Ignore Failed Read::
  160. Options Used by @option{--extract}
  161. * Reading:: Options to Help Read Archives
  162. * Writing:: Changing How @command{tar} Writes Files
  163. * Scarce:: Coping with Scarce Resources
  164. Options to Help Read Archives
  165. * read full records::
  166. * Ignore Zeros::
  167. Changing How @command{tar} Writes Files
  168. * Dealing with Old Files::
  169. * Overwrite Old Files::
  170. * Keep Old Files::
  171. * Keep Newer Files::
  172. * Unlink First::
  173. * Recursive Unlink::
  174. * Data Modification Times::
  175. * Setting Access Permissions::
  176. * Writing to Standard Output::
  177. * remove files::
  178. Coping with Scarce Resources
  179. * Starting File::
  180. * Same Order::
  181. Performing Backups and Restoring Files
  182. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  183. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  184. * Backup Levels:: Levels of Backups
  185. * Backup Parameters:: Setting Parameters for Backups and Restoration
  186. * Scripted Backups:: Using the Backup Scripts
  187. * Scripted Restoration:: Using the Restore Script
  188. Setting Parameters for Backups and Restoration
  189. * General-Purpose Variables::
  190. * Magnetic Tape Control::
  191. * User Hooks::
  192. * backup-specs example:: An Example Text of @file{Backup-specs}
  193. Choosing Files and Names for @command{tar}
  194. * file:: Choosing the Archive's Name
  195. * Selecting Archive Members::
  196. * files:: Reading Names from a File
  197. * exclude:: Excluding Some Files
  198. * Wildcards:: Wildcards Patterns and Matching
  199. * after:: Operating Only on New Files
  200. * recurse:: Descending into Directories
  201. * one:: Crossing File System Boundaries
  202. Reading Names from a File
  203. * nul::
  204. Excluding Some Files
  205. * problems with exclude::
  206. Crossing File System Boundaries
  207. * directory:: Changing Directory
  208. * absolute:: Absolute File Names
  209. Date input formats
  210. * General date syntax:: Common rules.
  211. * Calendar date items:: 19 Dec 1994.
  212. * Time of day items:: 9:20pm.
  213. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  214. * Day of week items:: Monday and others.
  215. * Relative items in date strings:: next tuesday, 2 years ago.
  216. * Pure numbers in date strings:: 19931219, 1440.
  217. * Seconds since the Epoch:: @@1078100502.
  218. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  219. Controlling the Archive Format
  220. * Portability:: Making @command{tar} Archives More Portable
  221. * Compression:: Using Less Space through Compression
  222. * Attributes:: Handling File Attributes
  223. * Standard:: The Standard Format
  224. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  225. * cpio:: Comparison of @command{tar} and @command{cpio}
  226. Making @command{tar} Archives More Portable
  227. * Portable Names:: Portable Names
  228. * dereference:: Symbolic Links
  229. * old:: Old V7 Archives
  230. * posix:: @acronym{POSIX} archives
  231. * Checksumming:: Checksumming Problems
  232. * Large or Negative Values:: Large files, negative time stamps, etc.
  233. Using Less Space through Compression
  234. * gzip:: Creating and Reading Compressed Archives
  235. * sparse:: Archiving Sparse Files
  236. Tapes and Other Archive Media
  237. * Device:: Device selection and switching
  238. * Remote Tape Server::
  239. * Common Problems and Solutions::
  240. * Blocking:: Blocking
  241. * Many:: Many archives on one tape
  242. * Using Multiple Tapes:: Using Multiple Tapes
  243. * label:: Including a Label in the Archive
  244. * verify::
  245. * Write Protection::
  246. Blocking
  247. * Format Variations:: Format Variations
  248. * Blocking Factor:: The Blocking Factor of an Archive
  249. Many Archives on One Tape
  250. * Tape Positioning:: Tape Positions and Tape Marks
  251. * mt:: The @command{mt} Utility
  252. Using Multiple Tapes
  253. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  254. * Tape Files:: Tape Files
  255. * Tarcat:: Concatenate Volumes into a Single Archive
  256. GNU tar internals and development
  257. * Genfile::
  258. * Snapshot Files::
  259. Copying This Manual
  260. * Free Software Needs Free Documentation::
  261. * GNU Free Documentation License:: License for copying this manual
  262. @end detailmenu
  263. @end menu
  264. @node Introduction
  265. @chapter Introduction
  266. @GNUTAR{} creates
  267. and manipulates @dfn{archives} which are actually collections of
  268. many other files; the program provides users with an organized and
  269. systematic method for controlling a large amount of data.
  270. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  271. archives need not (and these days, typically do not) reside on tapes.
  272. @menu
  273. * Book Contents:: What this Book Contains
  274. * Definitions:: Some Definitions
  275. * What tar Does:: What @command{tar} Does
  276. * Naming tar Archives:: How @command{tar} Archives are Named
  277. * Authors:: @GNUTAR{} Authors
  278. * Reports:: Reporting bugs or suggestions
  279. @end menu
  280. @node Book Contents
  281. @section What this Book Contains
  282. The first part of this chapter introduces you to various terms that will
  283. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  284. and its documentation, and where you should send bug reports
  285. or comments.
  286. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  287. gentle introduction for people who are new to using @command{tar}. It is
  288. meant to be self contained, not requiring any reading from subsequent
  289. chapters to make sense. It moves from topic to topic in a logical,
  290. progressive order, building on information already explained.
  291. Although the tutorial is paced and structured to allow beginners to
  292. learn how to use @command{tar}, it is not intended solely for beginners.
  293. The tutorial explains how to use the three most frequently used
  294. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  295. two frequently used options (@samp{file} and @samp{verbose}). The other
  296. chapters do not refer to the tutorial frequently; however, if a section
  297. discusses something which is a complex variant of a basic concept, there
  298. may be a cross reference to that basic concept. (The entire book,
  299. including the tutorial, assumes that the reader understands some basic
  300. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  301. The third chapter presents the remaining five operations, and
  302. information about using @command{tar} options and option syntax.
  303. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  304. than the reality. should think about whether this makes sense to say
  305. here, or not.} The other chapters are meant to be used as a
  306. reference. Each chapter presents everything that needs to be said
  307. about a specific topic.
  308. One of the chapters (@pxref{Date input formats}) exists in its
  309. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  310. In addition, one section of this manual (@pxref{Standard}) contains a
  311. big quote which is taken directly from @command{tar} sources.
  312. In general, we give both long and short (abbreviated) option names
  313. at least once in each section where the relevant option is covered, so
  314. that novice readers will become familiar with both styles. (A few
  315. options have no short versions, and the relevant sections will
  316. indicate this.)
  317. @node Definitions
  318. @section Some Definitions
  319. @cindex archive
  320. @cindex tar archive
  321. The @command{tar} program is used to create and manipulate @command{tar}
  322. archives. An @dfn{archive} is a single file which contains the contents
  323. of many files, while still identifying the names of the files, their
  324. owner(s), and so forth. (In addition, archives record access
  325. permissions, user and group, size in bytes, and data modification time.
  326. Some archives also record the file names in each archived directory, as
  327. well as other file and directory information.) You can use @command{tar}
  328. to @dfn{create} a new archive in a specified directory.
  329. @cindex member
  330. @cindex archive member
  331. @cindex file name
  332. @cindex member name
  333. The files inside an archive are called @dfn{members}. Within this
  334. manual, we use the term @dfn{file} to refer only to files accessible in
  335. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  336. @dfn{member} to refer only to the members of an archive. Similarly, a
  337. @dfn{file name} is the name of a file, as it resides in the file system,
  338. and a @dfn{member name} is the name of an archive member within the
  339. archive.
  340. @cindex extraction
  341. @cindex unpacking
  342. The term @dfn{extraction} refers to the process of copying an archive
  343. member (or multiple members) into a file in the file system. Extracting
  344. all the members of an archive is often called @dfn{extracting the
  345. archive}. The term @dfn{unpack} can also be used to refer to the
  346. extraction of many or all the members of an archive. Extracting an
  347. archive does not destroy the archive's structure, just as creating an
  348. archive does not destroy the copies of the files that exist outside of
  349. the archive. You may also @dfn{list} the members in a given archive
  350. (this is often thought of as ``printing'' them to the standard output,
  351. or the command line), or @dfn{append} members to a pre-existing archive.
  352. All of these operations can be performed using @command{tar}.
  353. @node What tar Does
  354. @section What @command{tar} Does
  355. @cindex tar
  356. The @command{tar} program provides the ability to create @command{tar}
  357. archives, as well as various other kinds of manipulation. For example,
  358. you can use @command{tar} on previously created archives to extract files,
  359. to store additional files, or to update or list files which were already
  360. stored.
  361. Initially, @command{tar} archives were used to store files conveniently on
  362. magnetic tape. The name @command{tar} comes from this use; it stands for
  363. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  364. direct its output to available devices, files, or other programs (using
  365. pipes). @command{tar} may even access remote devices or files (as archives).
  366. You can use @command{tar} archives in many ways. We want to stress a few
  367. of them: storage, backup, and transportation.
  368. @FIXME{the following table entries need a bit of work..}
  369. @table @asis
  370. @item Storage
  371. Often, @command{tar} archives are used to store related files for
  372. convenient file transfer over a network. For example, the
  373. @acronym{GNU} Project distributes its software bundled into
  374. @command{tar} archives, so that all the files relating to a particular
  375. program (or set of related programs) can be transferred as a single
  376. unit.
  377. A magnetic tape can store several files in sequence. However, the tape
  378. has no names for these files; it only knows their relative position on
  379. the tape. One way to store several files on one tape and retain their
  380. names is by creating a @command{tar} archive. Even when the basic transfer
  381. mechanism can keep track of names, as FTP can, the nuisance of handling
  382. multiple files, directories, and multiple links makes @command{tar}
  383. archives useful.
  384. Archive files are also used for long-term storage. You can think of
  385. this as transportation from the present into the future. (It is a
  386. science-fiction idiom that you can move through time as well as in
  387. space; the idea here is that @command{tar} can be used to move archives in
  388. all dimensions, even time!)
  389. @item Backup
  390. Because the archive created by @command{tar} is capable of preserving
  391. file information and directory structure, @command{tar} is commonly
  392. used for performing full and incremental backups of disks. A backup
  393. puts a collection of files (possibly pertaining to many users and
  394. projects) together on a disk or a tape. This guards against
  395. accidental destruction of the information in those files.
  396. @GNUTAR{} has special features that allow it to be
  397. used to make incremental and full dumps of all the files in a
  398. file system.
  399. @item Transportation
  400. You can create an archive on one system, transfer it to another system,
  401. and extract the contents there. This allows you to transport a group of
  402. files from one system to another.
  403. @end table
  404. @node Naming tar Archives
  405. @section How @command{tar} Archives are Named
  406. Conventionally, @command{tar} archives are given names ending with
  407. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  408. but this manual follows that convention in order to accustom readers to
  409. it and to make examples more clear.
  410. @cindex tar file
  411. @cindex entry
  412. @cindex tar entry
  413. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  414. archive members as ``files'' or ``entries''. For people familiar with
  415. the operation of @command{tar}, this causes no difficulty. However, in
  416. this manual, we consistently refer to ``archives'' and ``archive
  417. members'' to make learning to use @command{tar} easier for novice users.
  418. @node Authors
  419. @section @GNUTAR{} Authors
  420. @GNUTAR{} was originally written by John Gilmore,
  421. and modified by many people. The @acronym{GNU} enhancements were
  422. written by Jay Fenlason, then Joy Kendall, and the whole package has
  423. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  424. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  425. numerous and kind users.
  426. We wish to stress that @command{tar} is a collective work, and owes much to
  427. all those people who reported problems, offered solutions and other
  428. insights, or shared their thoughts and suggestions. An impressive, yet
  429. partial list of those contributors can be found in the @file{THANKS}
  430. file from the @GNUTAR{} distribution.
  431. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  432. sure i want to spell out the history in this detail, at least not for
  433. the printed book. i'm just not sure it needs to be said this way.
  434. i'll think about it.}
  435. @FIXME{History is more important, and surely more interesting, than
  436. actual names. Quoting names without history would be meaningless. FP}
  437. Jay Fenlason put together a draft of a @GNUTAR{}
  438. manual, borrowing notes from the original man page from John Gilmore.
  439. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  440. Gorin worked on a tutorial and manual for @GNUTAR{}.
  441. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  442. taking information from all these sources and merging them. Melissa
  443. Weisshaus finally edited and redesigned the book to create version
  444. 1.12. @FIXME{update version number as necessary; i'm being
  445. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  446. maybe melissa? maybe julie sussman?] needs to properly index the
  447. thing.}
  448. For version 1.12, Daniel Hagerty contributed a great deal of technical
  449. consulting. In particular, he is the primary author of @ref{Backups}.
  450. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  451. (see @url{http://savannah.gnu.org/projects/tar}), and
  452. active development and maintenance work has started
  453. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  454. Poznyakoff and Jeff Bailey.
  455. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  456. @node Reports
  457. @section Reporting bugs or suggestions
  458. @cindex bug reports
  459. @cindex reporting bugs
  460. If you find problems or have suggestions about this program or manual,
  461. please report them to @file{bug-tar@@gnu.org}.
  462. When reporting a bug, please be sure to include as much detail as
  463. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  464. like to make this node as detailed as 'Bug reporting' node in Emacs
  465. manual}.
  466. @node Tutorial
  467. @chapter Tutorial Introduction to @command{tar}
  468. This chapter guides you through some basic examples of three @command{tar}
  469. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  470. you already know how to use some other version of @command{tar}, then you
  471. may not need to read this chapter. This chapter omits most complicated
  472. details about how @command{tar} works.
  473. @menu
  474. * assumptions::
  475. * stylistic conventions::
  476. * basic tar options:: Basic @command{tar} Operations and Options
  477. * frequent operations::
  478. * Two Frequent Options::
  479. * create:: How to Create Archives
  480. * list:: How to List Archives
  481. * extract:: How to Extract Members from an Archive
  482. * going further::
  483. @end menu
  484. @node assumptions
  485. @section Assumptions this Tutorial Makes
  486. This chapter is paced to allow beginners to learn about @command{tar}
  487. slowly. At the same time, we will try to cover all the basic aspects of
  488. these three operations. In order to accomplish both of these tasks, we
  489. have made certain assumptions about your knowledge before reading this
  490. manual, and the hardware you will be using:
  491. @itemize @bullet
  492. @item
  493. Before you start to work through this tutorial, you should understand
  494. what the terms ``archive'' and ``archive member'' mean
  495. (@pxref{Definitions}). In addition, you should understand something
  496. about how Unix-type operating systems work, and you should know how to
  497. use some basic utilities. For example, you should know how to create,
  498. list, copy, rename, edit, and delete files and directories; how to
  499. change between directories; and how to figure out where you are in the
  500. file system. You should have some basic understanding of directory
  501. structure and how files are named according to which directory they are
  502. in. You should understand concepts such as standard output and standard
  503. input, what various definitions of the term ``argument'' mean, and the
  504. differences between relative and absolute path names. @FIXME{and what
  505. else?}
  506. @item
  507. This manual assumes that you are working from your own home directory
  508. (unless we state otherwise). In this tutorial, you will create a
  509. directory to practice @command{tar} commands in. When we show path names,
  510. we will assume that those paths are relative to your home directory.
  511. For example, my home directory path is @file{/home/fsf/melissa}. All of
  512. my examples are in a subdirectory of the directory named by that path
  513. name; the subdirectory is called @file{practice}.
  514. @item
  515. In general, we show examples of archives which exist on (or can be
  516. written to, or worked with from) a directory on a hard disk. In most
  517. cases, you could write those archives to, or work with them on any other
  518. device, such as a tape drive. However, some of the later examples in
  519. the tutorial and next chapter will not work on tape drives.
  520. Additionally, working with tapes is much more complicated than working
  521. with hard disks. For these reasons, the tutorial does not cover working
  522. with tape drives. @xref{Media}, for complete information on using
  523. @command{tar} archives with tape drives.
  524. @FIXME{this is a cop out. need to add some simple tape drive info.}
  525. @end itemize
  526. @node stylistic conventions
  527. @section Stylistic Conventions
  528. In the examples, @samp{$} represents a typical shell prompt. It
  529. precedes lines you should type; to make this more clear, those lines are
  530. shown in @kbd{this font}, as opposed to lines which represent the
  531. computer's response; those lines are shown in @code{this font}, or
  532. sometimes @samp{like this}.
  533. @c When we have lines which are too long to be
  534. @c displayed in any other way, we will show them like this:
  535. @node basic tar options
  536. @section Basic @command{tar} Operations and Options
  537. @command{tar} can take a wide variety of arguments which specify and define
  538. the actions it will have on the particular set of files or the archive.
  539. The main types of arguments to @command{tar} fall into one of two classes:
  540. operations, and options.
  541. Some arguments fall into a class called @dfn{operations}; exactly one of
  542. these is both allowed and required for any instance of using @command{tar};
  543. you may @emph{not} specify more than one. People sometimes speak of
  544. @dfn{operating modes}. You are in a particular operating mode when you
  545. have specified the operation which specifies it; there are eight
  546. operations in total, and thus there are eight operating modes.
  547. The other arguments fall into the class known as @dfn{options}. You are
  548. not required to specify any options, and you are allowed to specify more
  549. than one at a time (depending on the way you are using @command{tar} at
  550. that time). Some options are used so frequently, and are so useful for
  551. helping you type commands more carefully that they are effectively
  552. ``required''. We will discuss them in this chapter.
  553. You can write most of the @command{tar} operations and options in any
  554. of three forms: long (mnemonic) form, short form, and old style. Some
  555. of the operations and options have no short or ``old'' forms; however,
  556. the operations and options which we will cover in this tutorial have
  557. corresponding abbreviations. @FIXME{make sure this is still the case,
  558. at the end}We will indicate those abbreviations appropriately to get
  559. you used to seeing them. (Note that the ``old style'' option forms
  560. exist in @GNUTAR{} for compatibility with Unix
  561. @command{tar}. In this book we present a full discussion of this way
  562. of writing options and operations (@pxref{Old Options}), and we discuss
  563. the other two styles of writing options (@xref{Mnemonic Options}, and
  564. @pxref{Short Options}).
  565. In the examples and in the text of this tutorial, we usually use the
  566. long forms of operations and options; but the ``short'' forms produce
  567. the same result and can make typing long @command{tar} commands easier.
  568. For example, instead of typing
  569. @smallexample
  570. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  571. @end smallexample
  572. @noindent
  573. you can type
  574. @smallexample
  575. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  576. @end smallexample
  577. @noindent
  578. or even
  579. @smallexample
  580. @kbd{tar -cvf afiles.tar apple angst aspic}
  581. @end smallexample
  582. @noindent
  583. For more information on option syntax, see @ref{Advanced tar}. In
  584. discussions in the text, when we name an option by its long form, we
  585. also give the corresponding short option in parentheses.
  586. The term, ``option'', can be confusing at times, since ``operations''
  587. are often lumped in with the actual, @emph{optional} ``options'' in certain
  588. general class statements. For example, we just talked about ``short and
  589. long forms of options and operations''. However, experienced @command{tar}
  590. users often refer to these by shorthand terms such as, ``short and long
  591. options''. This term assumes that the ``operations'' are included, also.
  592. Context will help you determine which definition of ``options'' to use.
  593. Similarly, the term ``command'' can be confusing, as it is often used in
  594. two different ways. People sometimes refer to @command{tar} ``commands''.
  595. A @command{tar} @dfn{command} is the entire command line of user input
  596. which tells @command{tar} what to do --- including the operation, options,
  597. and any arguments (file names, pipes, other commands, etc). However,
  598. you will also sometimes hear the term ``the @command{tar} command''. When
  599. the word ``command'' is used specifically like this, a person is usually
  600. referring to the @command{tar} @emph{operation}, not the whole line.
  601. Again, use context to figure out which of the meanings the speaker
  602. intends.
  603. @node frequent operations
  604. @section The Three Most Frequently Used Operations
  605. Here are the three most frequently used operations (both short and long
  606. forms), as well as a brief description of their meanings. The rest of
  607. this chapter will cover how to use these operations in detail. We will
  608. present the rest of the operations in the next chapter.
  609. @table @option
  610. @item --create
  611. @itemx -c
  612. Create a new @command{tar} archive.
  613. @item --list
  614. @itemx -t
  615. List the contents of an archive.
  616. @item --extract
  617. @itemx -x
  618. Extract one or more members from an archive.
  619. @end table
  620. @node Two Frequent Options
  621. @section Two Frequently Used Options
  622. To understand how to run @command{tar} in the three operating modes listed
  623. previously, you also need to understand how to use two of the options to
  624. @command{tar}: @option{--file} (which takes an archive file as an argument)
  625. and @option{--verbose}. (You are usually not @emph{required} to specify
  626. either of these options when you run @command{tar}, but they can be very
  627. useful in making things more clear and helping you avoid errors.)
  628. @menu
  629. * file tutorial::
  630. * verbose tutorial::
  631. * help tutorial::
  632. @end menu
  633. @node file tutorial
  634. @unnumberedsubsec The @option{--file} Option
  635. @table @option
  636. @opindex file, tutorial
  637. @item --file=@var{archive-name}
  638. @itemx -f @var{archive-name}
  639. Specify the name of an archive file.
  640. @end table
  641. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  642. use @command{tar}; this option determines the name of the archive file
  643. that @command{tar} will work on.
  644. @vrindex TAPE
  645. If you don't specify this argument, then @command{tar} will examine
  646. the environment variable @env{TAPE}. If it is set, its value will be
  647. used as the archive name. Otherwise, @command{tar} will use the
  648. default archive, determined at the compile time. Usually it is
  649. standard output or some physical tape drive attached to your machine
  650. (you can verify what the default is by running @kbd{tar
  651. --show-defaults}, @pxref{defaults}). If there is no tape drive
  652. attached, or the default is not meaningful, then @command{tar} will
  653. print an error message. The error message might look roughly like one
  654. of the following:
  655. @smallexample
  656. tar: can't open /dev/rmt8 : No such device or address
  657. tar: can't open /dev/rsmt0 : I/O error
  658. @end smallexample
  659. @noindent
  660. To avoid confusion, we recommend that you always specify an archive file
  661. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  662. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  663. @ref{file}.
  664. @node verbose tutorial
  665. @unnumberedsubsec The @option{--verbose} Option
  666. @table @option
  667. @opindex verbose, introduced
  668. @item --verbose
  669. @itemx -v
  670. Show the files being worked on as @command{tar} is running.
  671. @end table
  672. @option{--verbose} (@option{-v}) shows details about the results of running
  673. @command{tar}. This can be especially useful when the results might not be
  674. obvious. For example, if you want to see the progress of @command{tar} as
  675. it writes files into the archive, you can use the @option{--verbose}
  676. option. In the beginning, you may find it useful to use
  677. @option{--verbose} at all times; when you are more accustomed to
  678. @command{tar}, you will likely want to use it at certain times but not at
  679. others. We will use @option{--verbose} at times to help make something
  680. clear, and we will give many examples both using and not using
  681. @option{--verbose} to show the differences.
  682. Sometimes, a single instance of @option{--verbose} on the command line
  683. will show a full, @samp{ls} style listing of an archive or files,
  684. giving sizes, owners, and similar information. @FIXME{Describe the
  685. exact output format, e.g., how hard links are displayed.}
  686. Other times, @option{--verbose} will only show files or members that the particular
  687. operation is operating on at the time. In the latter case, you can
  688. use @option{--verbose} twice in a command to get a listing such as that
  689. in the former case. For example, instead of saying
  690. @smallexample
  691. @kbd{tar -cvf afiles.tar apple angst aspic}
  692. @end smallexample
  693. @noindent
  694. above, you might say
  695. @smallexample
  696. @kbd{tar -cvvf afiles.tar apple angst aspic}
  697. @end smallexample
  698. @noindent
  699. This works equally well using short or long forms of options. Using
  700. long forms, you would simply write out the mnemonic form of the option
  701. twice, like this:
  702. @smallexample
  703. $ @kbd{tar --create --verbose --verbose @dots{}}
  704. @end smallexample
  705. @noindent
  706. Note that you must double the hyphens properly each time.
  707. Later in the tutorial, we will give examples using @w{@option{--verbose
  708. --verbose}}.
  709. @node help tutorial
  710. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  711. @table @option
  712. @opindex help
  713. @item --help
  714. The @option{--help} option to @command{tar} prints out a very brief list of
  715. all operations and option available for the current version of
  716. @command{tar} available on your system.
  717. @end table
  718. @node create
  719. @section How to Create Archives
  720. @UNREVISED
  721. @cindex Creation of the archive
  722. @cindex Archive, creation of
  723. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  724. you use to create a @command{tar} archive. We will explain
  725. @option{--create} first because, in order to learn about the other
  726. operations, you will find it useful to have an archive available to
  727. practice on.
  728. To make this easier, in this section you will first create a directory
  729. containing three files. Then, we will show you how to create an
  730. @emph{archive} (inside the new directory). Both the directory, and
  731. the archive are specifically for you to practice on. The rest of this
  732. chapter and the next chapter will show many examples using this
  733. directory and the files you will create: some of those files may be
  734. other directories and other archives.
  735. The three files you will archive in this example are called
  736. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  737. @file{collection.tar}.
  738. This section will proceed slowly, detailing how to use @option{--create}
  739. in @code{verbose} mode, and showing examples using both short and long
  740. forms. In the rest of the tutorial, and in the examples in the next
  741. chapter, we will proceed at a slightly quicker pace. This section
  742. moves more slowly to allow beginning users to understand how
  743. @command{tar} works.
  744. @menu
  745. * prepare for examples::
  746. * Creating the archive::
  747. * create verbose::
  748. * short create::
  749. * create dir::
  750. @end menu
  751. @node prepare for examples
  752. @subsection Preparing a Practice Directory for Examples
  753. To follow along with this and future examples, create a new directory
  754. called @file{practice} containing files called @file{blues}, @file{folk}
  755. and @file{jazz}. The files can contain any information you like:
  756. ideally, they should contain information which relates to their names,
  757. and be of different lengths. Our examples assume that @file{practice}
  758. is a subdirectory of your home directory.
  759. Now @command{cd} to the directory named @file{practice}; @file{practice}
  760. is now your @dfn{working directory}. (@emph{Please note}: Although
  761. the full path name of this directory is
  762. @file{/@var{homedir}/practice}, in our examples we will refer to
  763. this directory as @file{practice}; the @var{homedir} is presumed.
  764. In general, you should check that the files to be archived exist where
  765. you think they do (in the working directory) by running @command{ls}.
  766. Because you just created the directory and the files and have changed to
  767. that directory, you probably don't need to do that this time.
  768. It is very important to make sure there isn't already a file in the
  769. working directory with the archive name you intend to use (in this case,
  770. @samp{collection.tar}), or that you don't care about its contents.
  771. Whenever you use @samp{create}, @command{tar} will erase the current
  772. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  773. will not tell you if you are about to overwrite an archive unless you
  774. specify an option which does this (@pxref{backup}, for the
  775. information on how to do so). To add files to an existing archive,
  776. you need to use a different option, such as @option{--append} (@option{-r}); see
  777. @ref{append} for information on how to do this.
  778. @node Creating the archive
  779. @subsection Creating the Archive
  780. @opindex create, introduced
  781. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  782. archive named @file{collection.tar}, use the following command:
  783. @smallexample
  784. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  785. @end smallexample
  786. The order of the arguments is not very important, @emph{when using long
  787. option forms}. You could also say:
  788. @smallexample
  789. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  790. @end smallexample
  791. @noindent
  792. However, you can see that this order is harder to understand; this is
  793. why we will list the arguments in the order that makes the commands
  794. easiest to understand (and we encourage you to do the same when you use
  795. @command{tar}, to avoid errors).
  796. Note that the part of the command which says,
  797. @w{@option{--file=collection.tar}} is considered to be @emph{one} argument.
  798. If you substituted any other string of characters for
  799. @kbd{collection.tar}, then that string would become the name of the
  800. archive file you create.
  801. The order of the options becomes more important when you begin to use
  802. short forms. With short forms, if you type commands in the wrong order
  803. (even if you type them correctly in all other ways), you may end up with
  804. results you don't expect. For this reason, it is a good idea to get
  805. into the habit of typing options in the order that makes inherent sense.
  806. @xref{short create}, for more information on this.
  807. In this example, you type the command as shown above: @option{--create}
  808. is the operation which creates the new archive
  809. (@file{collection.tar}), and @option{--file} is the option which lets
  810. you give it the name you chose. The files, @file{blues}, @file{folk},
  811. and @file{jazz}, are now members of the archive, @file{collection.tar}
  812. (they are @dfn{file name arguments} to the @option{--create} operation).
  813. @FIXME{xref here to the discussion of file name args?}Now that they are
  814. in the archive, they are called @emph{archive members}, not files.
  815. (@pxref{Definitions,members}).
  816. When you create an archive, you @emph{must} specify which files you
  817. want placed in the archive. If you do not specify any archive
  818. members, @GNUTAR{} will complain.
  819. If you now list the contents of the working directory (@command{ls}), you will
  820. find the archive file listed as well as the files you saw previously:
  821. @smallexample
  822. blues folk jazz collection.tar
  823. @end smallexample
  824. @noindent
  825. Creating the archive @samp{collection.tar} did not destroy the copies of
  826. the files in the directory.
  827. Keep in mind that if you don't indicate an operation, @command{tar} will not
  828. run and will prompt you for one. If you don't name any files, @command{tar}
  829. will complain. You must have write access to the working directory,
  830. or else you will not be able to create an archive in that directory.
  831. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  832. an existing archive; it will delete the archive and write a new one.
  833. Use @option{--append} (@option{-r}) instead. @xref{append}.
  834. @node create verbose
  835. @subsection Running @option{--create} with @option{--verbose}
  836. @opindex create, using with @option{--verbose}
  837. @opindex verbose, using with @option{--create}
  838. If you include the @option{--verbose} (@option{-v}) option on the command line,
  839. @command{tar} will list the files it is acting on as it is working. In
  840. verbose mode, the @code{create} example above would appear as:
  841. @smallexample
  842. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  843. blues
  844. folk
  845. jazz
  846. @end smallexample
  847. This example is just like the example we showed which did not use
  848. @option{--verbose}, except that @command{tar} generated the remaining lines
  849. @iftex
  850. (note the different font styles).
  851. @end iftex
  852. @ifinfo
  853. .
  854. @end ifinfo
  855. In the rest of the examples in this chapter, we will frequently use
  856. @code{verbose} mode so we can show actions or @command{tar} responses that
  857. you would otherwise not see, and which are important for you to
  858. understand.
  859. @node short create
  860. @subsection Short Forms with @samp{create}
  861. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  862. basic uses of @command{tar}, and you will use it countless times.
  863. Eventually, you will probably want to use abbreviated (or ``short'')
  864. forms of options. A full discussion of the three different forms that
  865. options can take appears in @ref{Styles}; for now, here is what the
  866. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  867. using short option forms:
  868. @smallexample
  869. $ @kbd{tar -cvf collection.tar blues folk jazz}
  870. blues
  871. folk
  872. jazz
  873. @end smallexample
  874. @noindent
  875. As you can see, the system responds the same no matter whether you use
  876. long or short option forms.
  877. @FIXME{i don't like how this is worded:} One difference between using
  878. short and long option forms is that, although the exact placement of
  879. arguments following options is no more specific when using short forms,
  880. it is easier to become confused and make a mistake when using short
  881. forms. For example, suppose you attempted the above example in the
  882. following way:
  883. @smallexample
  884. $ @kbd{tar -cfv collection.tar blues folk jazz}
  885. @end smallexample
  886. @noindent
  887. In this case, @command{tar} will make an archive file called @file{v},
  888. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  889. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  890. is thus taken to be the chosen archive file name. @command{tar} will try
  891. to add a file called @file{collection.tar} to the @file{v} archive file;
  892. if the file @file{collection.tar} did not already exist, @command{tar} will
  893. report an error indicating that this file does not exist. If the file
  894. @file{collection.tar} does already exist (e.g., from a previous command
  895. you may have run), then @command{tar} will add this file to the archive.
  896. Because the @option{-v} option did not get registered, @command{tar} will not
  897. run under @samp{verbose} mode, and will not report its progress.
  898. The end result is that you may be quite confused about what happened,
  899. and possibly overwrite a file. To illustrate this further, we will show
  900. you how an example we showed previously would look using short forms.
  901. This example,
  902. @smallexample
  903. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  904. @end smallexample
  905. @noindent
  906. is confusing as it is. When shown using short forms, however, it
  907. becomes much more so:
  908. @smallexample
  909. $ @kbd{tar blues -c folk -f collection.tar jazz}
  910. @end smallexample
  911. @noindent
  912. It would be very easy to put the wrong string of characters
  913. immediately following the @option{-f}, but doing that could sacrifice
  914. valuable data.
  915. For this reason, we recommend that you pay very careful attention to
  916. the order of options and placement of file and archive names,
  917. especially when using short option forms. Not having the option name
  918. written out mnemonically can affect how well you remember which option
  919. does what, and therefore where different names have to be placed.
  920. @node create dir
  921. @subsection Archiving Directories
  922. @cindex Archiving Directories
  923. @cindex Directories, Archiving
  924. You can archive a directory by specifying its directory name as a
  925. file name argument to @command{tar}. The files in the directory will be
  926. archived relative to the working directory, and the directory will be
  927. re-created along with its contents when the archive is extracted.
  928. To archive a directory, first move to its superior directory. If you
  929. have followed the previous instructions in this tutorial, you should
  930. type:
  931. @smallexample
  932. $ @kbd{cd ..}
  933. $
  934. @end smallexample
  935. @noindent
  936. This will put you into the directory which contains @file{practice},
  937. i.e., your home directory. Once in the superior directory, you can
  938. specify the subdirectory, @file{practice}, as a file name argument. To
  939. store @file{practice} in the new archive file @file{music.tar}, type:
  940. @smallexample
  941. $ @kbd{tar --create --verbose --file=music.tar practice}
  942. @end smallexample
  943. @noindent
  944. @command{tar} should output:
  945. @smallexample
  946. practice/
  947. practice/blues
  948. practice/folk
  949. practice/jazz
  950. practice/collection.tar
  951. @end smallexample
  952. Note that the archive thus created is not in the subdirectory
  953. @file{practice}, but rather in the current working directory---the
  954. directory from which @command{tar} was invoked. Before trying to archive a
  955. directory from its superior directory, you should make sure you have
  956. write access to the superior directory itself, not only the directory
  957. you are trying archive with @command{tar}. For example, you will probably
  958. not be able to store your home directory in an archive by invoking
  959. @command{tar} from the root directory; @xref{absolute}. (Note
  960. also that @file{collection.tar}, the original archive file, has itself
  961. been archived. @command{tar} will accept any file as a file to be
  962. archived, regardless of its content. When @file{music.tar} is
  963. extracted, the archive file @file{collection.tar} will be re-written
  964. into the file system).
  965. If you give @command{tar} a command such as
  966. @smallexample
  967. $ @kbd{tar --create --file=foo.tar .}
  968. @end smallexample
  969. @noindent
  970. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  971. dumped}. This happens because @command{tar} creates the archive
  972. @file{foo.tar} in the current directory before putting any files into
  973. it. Then, when @command{tar} attempts to add all the files in the
  974. directory @file{.} to the archive, it notices that the file
  975. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  976. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  977. will continue in this case, and create the archive
  978. normally, except for the exclusion of that one file. (@emph{Please
  979. note:} Other implementations of @command{tar} may not be so clever;
  980. they will enter an infinite loop when this happens, so you should not
  981. depend on this behavior unless you are certain you are running
  982. @GNUTAR{}. In general, it is wise to always place the archive outside
  983. of the directory being dumped.
  984. @node list
  985. @section How to List Archives
  986. @opindex list
  987. Frequently, you will find yourself wanting to determine exactly what a
  988. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  989. to get the member names as they currently appear in the archive, as well
  990. as various attributes of the files at the time they were archived. For
  991. example, you can examine the archive @file{collection.tar} that you
  992. created in the last section with the command,
  993. @smallexample
  994. $ @kbd{tar --list --file=collection.tar}
  995. @end smallexample
  996. @noindent
  997. The output of @command{tar} would then be:
  998. @smallexample
  999. blues
  1000. folk
  1001. jazz
  1002. @end smallexample
  1003. @noindent
  1004. The archive @file{bfiles.tar} would list as follows:
  1005. @smallexample
  1006. ./birds
  1007. baboon
  1008. ./box
  1009. @end smallexample
  1010. @noindent
  1011. Be sure to use a @option{--file=@var{archive-name}} (@option{-f
  1012. @var{archive-name}}) option just as with @option{--create}
  1013. (@option{-c}) to specify the name of the archive.
  1014. @opindex list, using with @option{--verbose}
  1015. @opindex verbose, using with @option{--list}
  1016. If you use the @option{--verbose} (@option{-v}) option with
  1017. @option{--list}, then @command{tar} will print out a listing
  1018. reminiscent of @w{@samp{ls -l}}, showing owner, file size, and so forth.
  1019. If you had used @option{--verbose} (@option{-v}) mode, the example
  1020. above would look like:
  1021. @smallexample
  1022. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1023. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1024. @end smallexample
  1025. @cindex listing member and file names
  1026. @anchor{listing member and file names}
  1027. It is important to notice that the output of @kbd{tar --list
  1028. --verbose} does not necessarily match that produced by @kbd{tar
  1029. --create --verbose} while creating the archive. It is because
  1030. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1031. prefixes from file names before storing them in the archive
  1032. (@xref{absolute}, for more information). In other
  1033. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1034. an archive and @dfn{member names} when listing it. Consider this
  1035. example:
  1036. @smallexample
  1037. @group
  1038. $ @kbd{tar cfv archive /etc/mail}
  1039. tar: Removing leading `/' from member names
  1040. /etc/mail/
  1041. /etc/mail/sendmail.cf
  1042. /etc/mail/aliases
  1043. $ @kbd{tar tf archive}
  1044. etc/mail/
  1045. etc/mail/sendmail.cf
  1046. etc/mail/aliases
  1047. @end group
  1048. @end smallexample
  1049. @opindex show-stored-names
  1050. This default behavior can sometimes be inconvenient. You can force
  1051. @GNUTAR{} show member names when creating archive by supplying
  1052. @option{--show-stored-names} option.
  1053. @table @option
  1054. @item --show-stored-names
  1055. Print member (as opposed to @emph{file}) names when creating the archive.
  1056. @end table
  1057. @cindex File name arguments, using @option{--list} with
  1058. @opindex list, using with file name arguments
  1059. You can specify one or more individual member names as arguments when
  1060. using @samp{list}. In this case, @command{tar} will only list the
  1061. names of members you identify. For example, @w{@kbd{tar --list
  1062. --file=afiles.tar apple}} would only print @file{apple}.
  1063. Because @command{tar} preserves paths, file names must be specified as
  1064. they appear in the archive (ie., relative to the directory from which
  1065. the archive was created). Therefore, it is essential when specifying
  1066. member names to @command{tar} that you give the exact member names.
  1067. For example, @w{@kbd{tar --list --file=bfiles.tar birds}} would produce an
  1068. error message something like @samp{tar: birds: Not found in archive},
  1069. because there is no member named @file{birds}, only one named
  1070. @file{./birds}. While the names @file{birds} and @file{./birds} name
  1071. the same file, @emph{member} names by default are compared verbatim.
  1072. However, @w{@kbd{tar --list --file=bfiles.tar baboon}} would respond
  1073. with @file{baboon}, because this exact member name is in the archive file
  1074. @file{bfiles.tar}. If you are not sure of the exact file name,
  1075. use @dfn{globbing patterns}, for example:
  1076. @smallexample
  1077. $ @kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
  1078. @end smallexample
  1079. @noindent
  1080. will list all members whose name contains @samp{b}. @xref{Wildcards},
  1081. for a detailed discussion of globbing patterns and related
  1082. @command{tar} command line options.
  1083. @menu
  1084. * list dir::
  1085. @end menu
  1086. @node list dir
  1087. @unnumberedsubsec Listing the Contents of a Stored Directory
  1088. To get information about the contents of an archived directory,
  1089. use the directory name as a file name argument in conjunction with
  1090. @option{--list} (@option{-t}). To find out file attributes, include the
  1091. @option{--verbose} (@option{-v}) option.
  1092. For example, to find out about files in the directory @file{practice}, in
  1093. the archive file @file{music.tar}, type:
  1094. @smallexample
  1095. $ @kbd{tar --list --verbose --file=music.tar practice}
  1096. @end smallexample
  1097. @command{tar} responds:
  1098. @smallexample
  1099. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1100. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1101. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1102. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1103. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1104. @end smallexample
  1105. When you use a directory name as a file name argument, @command{tar} acts on
  1106. all the files (including sub-directories) in that directory.
  1107. @node extract
  1108. @section How to Extract Members from an Archive
  1109. @UNREVISED
  1110. @cindex Extraction
  1111. @cindex Retrieving files from an archive
  1112. @cindex Resurrecting files from an archive
  1113. @opindex extract
  1114. Creating an archive is only half the job---there is no point in storing
  1115. files in an archive if you can't retrieve them. The act of retrieving
  1116. members from an archive so they can be used and manipulated as
  1117. unarchived files again is called @dfn{extraction}. To extract files
  1118. from an archive, use the @option{--extract} (@option{--get} or
  1119. @option{-x}) operation. As with @option{--create}, specify the name
  1120. of the archive with @option{--file} (@option{-f}) option. Extracting
  1121. an archive does not modify the archive in any way; you can extract it
  1122. multiple times if you want or need to.
  1123. Using @option{--extract}, you can extract an entire archive, or specific
  1124. files. The files can be directories containing other files, or not. As
  1125. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1126. long form of the operation without affecting the performance.
  1127. @menu
  1128. * extracting archives::
  1129. * extracting files::
  1130. * extract dir::
  1131. * extracting untrusted archives::
  1132. * failing commands::
  1133. @end menu
  1134. @node extracting archives
  1135. @subsection Extracting an Entire Archive
  1136. To extract an entire archive, specify the archive file name only, with
  1137. no individual file names as arguments. For example,
  1138. @smallexample
  1139. $ @kbd{tar -xvf collection.tar}
  1140. @end smallexample
  1141. @noindent
  1142. produces this:
  1143. @smallexample
  1144. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1145. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1146. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1147. @end smallexample
  1148. @node extracting files
  1149. @subsection Extracting Specific Files
  1150. To extract specific archive members, give their exact member names as
  1151. arguments, as printed by @option{--list} (@option{-t}). If you had
  1152. mistakenly deleted one of the files you had placed in the archive
  1153. @file{collection.tar} earlier (say, @file{blues}), you can extract it
  1154. from the archive without changing the archive's structure. Its
  1155. contents will be identical to the original file @file{blues} that you
  1156. deleted.
  1157. First, make sure you are in the @file{practice} directory, and list the
  1158. files in the directory. Now, delete the file, @samp{blues}, and list
  1159. the files in the directory again.
  1160. You can now extract the member @file{blues} from the archive file
  1161. @file{collection.tar} like this:
  1162. @smallexample
  1163. $ @kbd{tar --extract --file=collection.tar blues}
  1164. @end smallexample
  1165. @noindent
  1166. If you list the files in the directory again, you will see that the file
  1167. @file{blues} has been restored, with its original permissions, data
  1168. modification times, and owner.@footnote{This is only accidentally
  1169. true, but not in general. Whereas modification times are always
  1170. restored, in most cases, one has to be root for restoring the owner,
  1171. and use a special option for restoring permissions. Here, it just
  1172. happens that the restoring user is also the owner of the archived
  1173. members, and that the current @code{umask} is compatible with original
  1174. permissions.} (These parameters will be identical to those which
  1175. the file had when you originally placed it in the archive; any changes
  1176. you may have made before deleting the file from the file system,
  1177. however, will @emph{not} have been made to the archive member.) The
  1178. archive file, @samp{collection.tar}, is the same as it was before you
  1179. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1180. @option{--list} (@option{-t}).
  1181. Remember that as with other operations, specifying the exact member
  1182. name is important. @w{@kbd{tar --extract --file=bfiles.tar birds}}
  1183. will fail, because there is no member named @file{birds}. To extract
  1184. the member named @file{./birds}, you must specify @w{@kbd{tar
  1185. --extract --file=bfiles.tar ./birds}}. If you don't remember the
  1186. exact member names, use @option{--list} (@option{-t}) option
  1187. (@pxref{list}). You can also extract those members that match a
  1188. specific @dfn{globbing pattern}. For example, to extract from
  1189. @file{bfiles.tar} all files that begin with @samp{b}, no matter their
  1190. directory prefix, you could type:
  1191. @smallexample
  1192. $ @kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
  1193. @end smallexample
  1194. @noindent
  1195. Here, @option{--wildcards} instructs @command{tar} to treat
  1196. command line arguments as globbing patterns and @option{--no-anchored}
  1197. informs it that the patterns apply to member names after any @samp{/}
  1198. delimiter. The use of globbing patterns is discussed in detail in
  1199. @xref{Wildcards}.
  1200. You can extract a file to standard output by combining the above options
  1201. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1202. Output}).
  1203. If you give the @option{--verbose} option, then @option{--extract}
  1204. will print the names of the archive members as it extracts them.
  1205. @node extract dir
  1206. @subsection Extracting Files that are Directories
  1207. Extracting directories which are members of an archive is similar to
  1208. extracting other files. The main difference to be aware of is that if
  1209. the extracted directory has the same name as any directory already in
  1210. the working directory, then files in the extracted directory will be
  1211. placed into the directory of the same name. Likewise, if there are
  1212. files in the pre-existing directory with the same names as the members
  1213. which you extract, the files from the extracted archive will replace
  1214. the files already in the working directory (and possible
  1215. subdirectories). This will happen regardless of whether or not the
  1216. files in the working directory were more recent than those extracted
  1217. (there exist, however, special options that alter this behavior
  1218. @pxref{Writing}).
  1219. However, if a file was stored with a directory name as part of its file
  1220. name, and that directory does not exist under the working directory when
  1221. the file is extracted, @command{tar} will create the directory.
  1222. We can demonstrate how to use @option{--extract} to extract a directory
  1223. file with an example. Change to the @file{practice} directory if you
  1224. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1225. go back to the parent directory and extract the archive
  1226. @file{music.tar}. You may either extract the entire archive, or you may
  1227. extract only the files you just deleted. To extract the entire archive,
  1228. don't give any file names as arguments after the archive name
  1229. @file{music.tar}. To extract only the files you deleted, use the
  1230. following command:
  1231. @smallexample
  1232. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1233. practice/folk
  1234. practice/jazz
  1235. @end smallexample
  1236. @noindent
  1237. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1238. would have displayed more detail about the extracted files, as shown
  1239. in the example below:
  1240. @smallexample
  1241. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1242. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1243. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1244. @end smallexample
  1245. @noindent
  1246. Because you created the directory with @file{practice} as part of the
  1247. file names of each of the files by archiving the @file{practice}
  1248. directory as @file{practice}, you must give @file{practice} as part
  1249. of the file names when you extract those files from the archive.
  1250. @node extracting untrusted archives
  1251. @subsection Extracting Archives from Untrusted Sources
  1252. Extracting files from archives can overwrite files that already exist.
  1253. If you receive an archive from an untrusted source, you should make a
  1254. new directory and extract into that directory, so that you don't have
  1255. to worry about the extraction overwriting one of your existing files.
  1256. For example, if @file{untrusted.tar} came from somewhere else on the
  1257. Internet, and you don't necessarily trust its contents, you can
  1258. extract it as follows:
  1259. @smallexample
  1260. $ @kbd{mkdir newdir}
  1261. $ @kbd{cd newdir}
  1262. $ @kbd{tar -xvf ../untrusted.tar}
  1263. @end smallexample
  1264. It is also a good practice to examine contents of the archive
  1265. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1266. with @option{--verbose} (@option{-v}).
  1267. @node failing commands
  1268. @subsection Commands That Will Fail
  1269. Here are some sample commands you might try which will not work, and why
  1270. they won't work.
  1271. If you try to use this command,
  1272. @smallexample
  1273. $ @kbd{tar -xvf music.tar folk jazz}
  1274. @end smallexample
  1275. @noindent
  1276. you will get the following response:
  1277. @smallexample
  1278. tar: folk: Not found in archive
  1279. tar: jazz: Not found in archive
  1280. $
  1281. @end smallexample
  1282. @noindent
  1283. This is because these files were not originally @emph{in} the parent
  1284. directory @file{..}, where the archive is located; they were in the
  1285. @file{practice} directory, and their file names reflect this:
  1286. @smallexample
  1287. $ @kbd{tar -tvf music.tar}
  1288. practice/folk
  1289. practice/jazz
  1290. practice/rock
  1291. @end smallexample
  1292. @FIXME{make sure the above works when going through the examples in
  1293. order...}
  1294. @noindent
  1295. Likewise, if you try to use this command,
  1296. @smallexample
  1297. $ @kbd{tar -tvf music.tar folk jazz}
  1298. @end smallexample
  1299. @noindent
  1300. you would get a similar response. Members with those names are not in the
  1301. archive. You must use the correct member names, or wildcards, in order
  1302. to extract the files from the archive.
  1303. If you have forgotten the correct names of the files in the archive,
  1304. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1305. @FIXME{more examples, here? hag thinks it's a good idea.}
  1306. @node going further
  1307. @section Going Further Ahead in this Manual
  1308. @FIXME{need to write up a node here about the things that are going to
  1309. be in the rest of the manual.}
  1310. @node tar invocation
  1311. @chapter Invoking @GNUTAR{}
  1312. @UNREVISED
  1313. This chapter is about how one invokes the @GNUTAR{}
  1314. command, from the command synopsis (@pxref{Synopsis}). There are
  1315. numerous options, and many styles for writing them. One mandatory
  1316. option specifies the operation @command{tar} should perform
  1317. (@pxref{Operation Summary}), other options are meant to detail how
  1318. this operation should be performed (@pxref{Option Summary}).
  1319. Non-option arguments are not always interpreted the same way,
  1320. depending on what the operation is.
  1321. You will find in this chapter everything about option styles and rules for
  1322. writing them (@pxref{Styles}). On the other hand, operations and options
  1323. are fully described elsewhere, in other chapters. Here, you will find
  1324. only synthetic descriptions for operations and options, together with
  1325. pointers to other parts of the @command{tar} manual.
  1326. Some options are so special they are fully described right in this
  1327. chapter. They have the effect of inhibiting the normal operation of
  1328. @command{tar} or else, they globally alter the amount of feedback the user
  1329. receives about what is going on. These are the @option{--help} and
  1330. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1331. and @option{--interactive} options (@pxref{interactive}).
  1332. @menu
  1333. * Synopsis::
  1334. * using tar options::
  1335. * Styles::
  1336. * All Options::
  1337. * help::
  1338. * defaults::
  1339. * verbose::
  1340. * interactive::
  1341. @end menu
  1342. @node Synopsis
  1343. @section General Synopsis of @command{tar}
  1344. The @GNUTAR{} program is invoked as either one of:
  1345. @smallexample
  1346. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1347. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1348. @end smallexample
  1349. The second form is for when old options are being used.
  1350. You can use @command{tar} to store files in an archive, to extract them from
  1351. an archive, and to do other types of archive manipulation. The primary
  1352. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1353. which action to take. The other arguments to @command{tar} are either
  1354. @dfn{options}, which change the way @command{tar} performs an operation,
  1355. or file names or archive members, which specify the files or members
  1356. @command{tar} is to act on.
  1357. You can actually type in arguments in any order, even if in this manual
  1358. the options always precede the other arguments, to make examples easier
  1359. to understand. Further, the option stating the main operation mode
  1360. (the @command{tar} main command) is usually given first.
  1361. Each @var{name} in the synopsis above is interpreted as an archive member
  1362. name when the main command is one of @option{--compare}
  1363. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1364. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1365. @option{--update} (@option{-u}). When naming archive members, you
  1366. must give the exact name of the member in the archive, as it is
  1367. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1368. @option{--create} (@option{-c}), these @var{name} arguments specify
  1369. the names of either files or directory hierarchies to place in the archive.
  1370. These files or hierarchies should already exist in the file system,
  1371. prior to the execution of the @command{tar} command.
  1372. @command{tar} interprets relative file names as being relative to the
  1373. working directory. @command{tar} will make all file names relative
  1374. (by removing leading slashes when archiving or restoring files),
  1375. unless you specify otherwise (using the @option{--absolute-names}
  1376. option). @xref{absolute}, for more information about
  1377. @option{--absolute-names}.
  1378. If you give the name of a directory as either a file name or a member
  1379. name, then @command{tar} acts recursively on all the files and directories
  1380. beneath that directory. For example, the name @file{/} identifies all
  1381. the files in the file system to @command{tar}.
  1382. The distinction between file names and archive member names is especially
  1383. important when shell globbing is used, and sometimes a source of confusion
  1384. for newcomers. @xref{Wildcards}, for more information about globbing.
  1385. The problem is that shells may only glob using existing files in the
  1386. file system. Only @command{tar} itself may glob on archive members, so when
  1387. needed, you must ensure that wildcard characters reach @command{tar} without
  1388. being interpreted by the shell first. Using a backslash before @samp{*}
  1389. or @samp{?}, or putting the whole argument between quotes, is usually
  1390. sufficient for this.
  1391. Even if @var{name}s are often specified on the command line, they
  1392. can also be read from a text file in the file system, using the
  1393. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1394. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1395. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1396. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1397. will usually yield a diagnostic and inhibit @command{tar} execution.
  1398. The other operations of @command{tar} (@option{--list},
  1399. @option{--extract}, @option{--compare}, and @option{--update})
  1400. will act on the entire contents of the archive.
  1401. @cindex exit status
  1402. @cindex return status
  1403. Besides successful exits, @GNUTAR{} may fail for
  1404. many reasons. Some reasons correspond to bad usage, that is, when the
  1405. @command{tar} command is improperly written. Errors may be
  1406. encountered later, while encountering an error processing the archive
  1407. or the files. Some errors are recoverable, in which case the failure
  1408. is delayed until @command{tar} has completed all its work. Some
  1409. errors are such that it would not meaningful, or at least risky, to
  1410. continue processing: @command{tar} then aborts processing immediately.
  1411. All abnormal exits, whether immediate or delayed, should always be
  1412. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1413. the error.
  1414. @GNUTAR{} returns only a few exit statuses. I'm really
  1415. aiming simplicity in that area, for now. If you are not using the
  1416. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1417. that everything went well, besides maybe innocuous warnings. Nonzero
  1418. means that something went wrong. Right now, as of today, ``nonzero''
  1419. is almost always 2, except for remote operations, where it may be
  1420. 128.
  1421. @node using tar options
  1422. @section Using @command{tar} Options
  1423. @GNUTAR{} has a total of eight operating modes which
  1424. allow you to perform a variety of tasks. You are required to choose
  1425. one operating mode each time you employ the @command{tar} program by
  1426. specifying one, and only one operation as an argument to the
  1427. @command{tar} command (two lists of four operations each may be found
  1428. at @ref{frequent operations} and @ref{Operations}). Depending on
  1429. circumstances, you may also wish to customize how the chosen operating
  1430. mode behaves. For example, you may wish to change the way the output
  1431. looks, or the format of the files that you wish to archive may require
  1432. you to do something special in order to make the archive look right.
  1433. You can customize and control @command{tar}'s performance by running
  1434. @command{tar} with one or more options (such as @option{--verbose}
  1435. (@option{-v}), which we used in the tutorial). As we said in the
  1436. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1437. their name suggests) optional. Depending on the operating mode, you
  1438. may specify one or more options. Different options will have different
  1439. effects, but in general they all change details of the operation, such
  1440. as archive format, archive name, or level of user interaction. Some
  1441. options make sense with all operating modes, while others are
  1442. meaningful only with particular modes. You will likely use some
  1443. options frequently, while you will only use others infrequently, or
  1444. not at all. (A full list of options is available in @pxref{All Options}.)
  1445. @vrindex TAR_OPTIONS, environment variable
  1446. @anchor{TAR_OPTIONS}
  1447. The @env{TAR_OPTIONS} environment variable specifies default options to
  1448. be placed in front of any explicit options. For example, if
  1449. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1450. if the two options @option{-v} and @option{--unlink-first} had been
  1451. specified before any explicit options. Option specifications are
  1452. separated by whitespace. A backslash escapes the next character, so it
  1453. can be used to specify an option containing whitespace or a backslash.
  1454. Note that @command{tar} options are case sensitive. For example, the
  1455. options @option{-T} and @option{-t} are different; the first requires an
  1456. argument for stating the name of a file providing a list of @var{name}s,
  1457. while the second does not require an argument and is another way to
  1458. write @option{--list} (@option{-t}).
  1459. In addition to the eight operations, there are many options to
  1460. @command{tar}, and three different styles for writing both: long (mnemonic)
  1461. form, short form, and old style. These styles are discussed below.
  1462. Both the options and the operations can be written in any of these three
  1463. styles.
  1464. @FIXME{menu at end of this node. need to think of an actual outline
  1465. for this chapter; probably do that after stuff from chapter 4 is
  1466. incorporated.}
  1467. @node Styles
  1468. @section The Three Option Styles
  1469. There are three styles for writing operations and options to the command
  1470. line invoking @command{tar}. The different styles were developed at
  1471. different times during the history of @command{tar}. These styles will be
  1472. presented below, from the most recent to the oldest.
  1473. Some options must take an argument. (For example, @option{--file}
  1474. (@option{-f})) takes the name of an archive file as an argument. If
  1475. you do not supply an archive file name, @command{tar} will use a
  1476. default, but this can be confusing; thus, we recommend that you always
  1477. supply a specific archive file name.) Where you @emph{place} the
  1478. arguments generally depends on which style of options you choose. We
  1479. will detail specific information relevant to each option style in the
  1480. sections on the different option styles, below. The differences are
  1481. subtle, yet can often be very important; incorrect option placement
  1482. can cause you to overwrite a number of important files. We urge you
  1483. to note these differences, and only use the option style(s) which
  1484. makes the most sense to you until you feel comfortable with the others.
  1485. Some options @emph{may} take an argument (currently, there are
  1486. two such options: @option{--backup} and @option{--occurrence}). Such
  1487. options may have at most long and short forms, they do not have old style
  1488. equivalent. The rules for specifying an argument for such options
  1489. are stricter than those for specifying mandatory arguments. Please,
  1490. pay special attention to them.
  1491. @menu
  1492. * Mnemonic Options:: Mnemonic Option Style
  1493. * Short Options:: Short Option Style
  1494. * Old Options:: Old Option Style
  1495. * Mixing:: Mixing Option Styles
  1496. @end menu
  1497. @node Mnemonic Options
  1498. @subsection Mnemonic Option Style
  1499. @FIXME{have to decide whether or not to replace other occurrences of
  1500. "mnemonic" with "long", or *ugh* vice versa.}
  1501. Each option has at least one long (or mnemonic) name starting with two
  1502. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1503. their corresponding short or old names. It sometimes happens that a
  1504. single mnemonic option has many different different names which are
  1505. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1506. long option names can be given unique abbreviations. For example,
  1507. @option{--cre} can be used in place of @option{--create} because there is no
  1508. other mnemonic option which begins with @samp{cre}. (One way to find
  1509. this out is by trying it and seeing what happens; if a particular
  1510. abbreviation could represent more than one option, @command{tar} will tell
  1511. you that that abbreviation is ambiguous and you'll know that that
  1512. abbreviation won't work. You may also choose to run @samp{tar --help}
  1513. to see a list of options. Be aware that if you run @command{tar} with a
  1514. unique abbreviation for the long name of an option you didn't want to
  1515. use, you are stuck; @command{tar} will perform the command as ordered.)
  1516. Mnemonic options are meant to be obvious and easy to remember, and their
  1517. meanings are generally easier to discern than those of their
  1518. corresponding short options (see below). For example:
  1519. @smallexample
  1520. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1521. @end smallexample
  1522. @noindent
  1523. gives a fairly good set of hints about what the command does, even
  1524. for those not fully acquainted with @command{tar}.
  1525. Mnemonic options which require arguments take those arguments
  1526. immediately following the option name. There are two ways of
  1527. specifying a mandatory argument. It can be separated from the
  1528. option name either by an equal sign, or by any amount of
  1529. white space characters. For example, the @option{--file} option (which
  1530. tells the name of the @command{tar} archive) is given a file such as
  1531. @file{archive.tar} as argument by using any of the following notations:
  1532. @option{--file=archive.tar} or @option{--file archive.tar}.
  1533. In contrast, optional arguments must always be introduced using
  1534. an equal sign. For example, the @option{--backup} option takes
  1535. an optional argument specifying backup type. It must be used
  1536. as @option{--backup=@var{backup-type}}.
  1537. @node Short Options
  1538. @subsection Short Option Style
  1539. Most options also have a short option name. Short options start with
  1540. a single dash, and are followed by a single character, e.g., @option{-t}
  1541. (which is equivalent to @option{--list}). The forms are absolutely
  1542. identical in function; they are interchangeable.
  1543. The short option names are faster to type than long option names.
  1544. Short options which require arguments take their arguments immediately
  1545. following the option, usually separated by white space. It is also
  1546. possible to stick the argument right after the short option name, using
  1547. no intervening space. For example, you might write @w{@option{-f
  1548. archive.tar}} or @option{-farchive.tar} instead of using
  1549. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1550. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1551. specific archive, here named @file{archive.tar}.
  1552. Short options which take optional arguments take their arguments
  1553. immediately following the option letter, @emph{without any intervening
  1554. white space characters}.
  1555. Short options' letters may be clumped together, but you are not
  1556. required to do this (as compared to old options; see below). When
  1557. short options are clumped as a set, use one (single) dash for them
  1558. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1559. such a set is allowed to have an argument@footnote{Clustering many
  1560. options, the last of which has an argument, is a rather opaque way to
  1561. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1562. even be made helpful enough for considering such usages as invalid.}.
  1563. When the options are separated, the argument for each option which requires
  1564. an argument directly follows that option, as is usual for Unix programs.
  1565. For example:
  1566. @smallexample
  1567. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1568. @end smallexample
  1569. If you reorder short options' locations, be sure to move any arguments
  1570. that belong to them. If you do not move the arguments properly, you may
  1571. end up overwriting files.
  1572. @node Old Options
  1573. @subsection Old Option Style
  1574. @UNREVISED
  1575. Like short options, old options are single letters. However, old options
  1576. must be written together as a single clumped set, without spaces separating
  1577. them or dashes preceding them@footnote{Beware that if you precede options
  1578. with a dash, you are announcing the short option style instead of the
  1579. old option style; short options are decoded differently.}. This set
  1580. of letters must be the first to appear on the command line, after the
  1581. @command{tar} program name and some white space; old options cannot appear
  1582. anywhere else. The letter of an old option is exactly the same letter as
  1583. the corresponding short option. For example, the old option @samp{t} is
  1584. the same as the short option @option{-t}, and consequently, the same as the
  1585. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1586. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1587. When options that need arguments are given together with the command,
  1588. all the associated arguments follow, in the same order as the options.
  1589. Thus, the example given previously could also be written in the old
  1590. style as follows:
  1591. @smallexample
  1592. $ @kbd{tar cvbf 20 /dev/rmt0}
  1593. @end smallexample
  1594. @noindent
  1595. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1596. the argument of @option{-f}.
  1597. On the other hand, this old style syntax makes it difficult to match
  1598. option letters with their corresponding arguments, and is often
  1599. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1600. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1601. argument for @option{-f}, and @option{-v} does not have a corresponding
  1602. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1603. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1604. pertain to.
  1605. If you want to reorder the letters in the old option argument, be
  1606. sure to reorder any corresponding argument appropriately.
  1607. This old way of writing @command{tar} options can surprise even experienced
  1608. users. For example, the two commands:
  1609. @smallexample
  1610. @kbd{tar cfz archive.tar.gz file}
  1611. @kbd{tar -cfz archive.tar.gz file}
  1612. @end smallexample
  1613. @noindent
  1614. are quite different. The first example uses @file{archive.tar.gz} as
  1615. the value for option @samp{f} and recognizes the option @samp{z}. The
  1616. second example, however, uses @file{z} as the value for option
  1617. @samp{f} --- probably not what was intended.
  1618. Old options are kept for compatibility with old versions of @command{tar}.
  1619. This second example could be corrected in many ways, among which the
  1620. following are equivalent:
  1621. @smallexample
  1622. @kbd{tar -czf archive.tar.gz file}
  1623. @kbd{tar -cf archive.tar.gz -z file}
  1624. @kbd{tar cf archive.tar.gz -z file}
  1625. @end smallexample
  1626. @cindex option syntax, traditional
  1627. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1628. non-@acronym{GNU}, support old options. @GNUTAR{}
  1629. supports them not only for historical reasons, but also because many
  1630. people are used to them. For compatibility with Unix @command{tar},
  1631. the first argument is always treated as containing command and option
  1632. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1633. equivalent to @w{@samp{tar -c}:} both of them specify the
  1634. @option{--create} (@option{-c}) command to create an archive.
  1635. @node Mixing
  1636. @subsection Mixing Option Styles
  1637. All three styles may be intermixed in a single @command{tar} command,
  1638. so long as the rules for each style are fully
  1639. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1640. a bug prevented intermixing old style options with mnemonic options in
  1641. some cases.}. Old style options and either of the modern styles of
  1642. options may be mixed within a single @command{tar} command. However,
  1643. old style options must be introduced as the first arguments only,
  1644. following the rule for old options (old options must appear directly
  1645. after the @command{tar} command and some white space). Modern options
  1646. may be given only after all arguments to the old options have been
  1647. collected. If this rule is not respected, a modern option might be
  1648. falsely interpreted as the value of the argument to one of the old
  1649. style options.
  1650. For example, all the following commands are wholly equivalent, and
  1651. illustrate the many combinations and orderings of option styles.
  1652. @smallexample
  1653. @kbd{tar --create --file=archive.tar}
  1654. @kbd{tar --create -f archive.tar}
  1655. @kbd{tar --create -farchive.tar}
  1656. @kbd{tar --file=archive.tar --create}
  1657. @kbd{tar --file=archive.tar -c}
  1658. @kbd{tar -c --file=archive.tar}
  1659. @kbd{tar -c -f archive.tar}
  1660. @kbd{tar -c -farchive.tar}
  1661. @kbd{tar -cf archive.tar}
  1662. @kbd{tar -cfarchive.tar}
  1663. @kbd{tar -f archive.tar --create}
  1664. @kbd{tar -f archive.tar -c}
  1665. @kbd{tar -farchive.tar --create}
  1666. @kbd{tar -farchive.tar -c}
  1667. @kbd{tar c --file=archive.tar}
  1668. @kbd{tar c -f archive.tar}
  1669. @kbd{tar c -farchive.tar}
  1670. @kbd{tar cf archive.tar}
  1671. @kbd{tar f archive.tar --create}
  1672. @kbd{tar f archive.tar -c}
  1673. @kbd{tar fc archive.tar}
  1674. @end smallexample
  1675. On the other hand, the following commands are @emph{not} equivalent to
  1676. the previous set:
  1677. @smallexample
  1678. @kbd{tar -f -c archive.tar}
  1679. @kbd{tar -fc archive.tar}
  1680. @kbd{tar -fcarchive.tar}
  1681. @kbd{tar -farchive.tarc}
  1682. @kbd{tar cfarchive.tar}
  1683. @end smallexample
  1684. @noindent
  1685. These last examples mean something completely different from what the
  1686. user intended (judging based on the example in the previous set which
  1687. uses long options, whose intent is therefore very clear). The first
  1688. four specify that the @command{tar} archive would be a file named
  1689. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1690. respectively. The first two examples also specify a single non-option,
  1691. @var{name} argument having the value @samp{archive.tar}. The last
  1692. example contains only old style option letters (repeating option
  1693. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1694. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1695. the first sentence of this paragraph..}
  1696. @node All Options
  1697. @section All @command{tar} Options
  1698. The coming manual sections contain an alphabetical listing of all
  1699. @command{tar} operations and options, with brief descriptions and cross
  1700. references to more in-depth explanations in the body of the manual.
  1701. They also contain an alphabetically arranged table of the short option
  1702. forms with their corresponding long option. You can use this table as
  1703. a reference for deciphering @command{tar} commands in scripts.
  1704. @menu
  1705. * Operation Summary::
  1706. * Option Summary::
  1707. * Short Option Summary::
  1708. @end menu
  1709. @node Operation Summary
  1710. @subsection Operations
  1711. @table @option
  1712. @opindex append, summary
  1713. @item --append
  1714. @itemx -r
  1715. Appends files to the end of the archive. @xref{append}.
  1716. @opindex catenate, summary
  1717. @item --catenate
  1718. @itemx -A
  1719. Same as @option{--concatenate}. @xref{concatenate}.
  1720. @opindex compare, summary
  1721. @item --compare
  1722. @itemx -d
  1723. Compares archive members with their counterparts in the file
  1724. system, and reports differences in file size, mode, owner,
  1725. modification date and contents. @xref{compare}.
  1726. @opindex concatenate, summary
  1727. @item --concatenate
  1728. @itemx -A
  1729. Appends other @command{tar} archives to the end of the archive.
  1730. @xref{concatenate}.
  1731. @opindex create, summary
  1732. @item --create
  1733. @itemx -c
  1734. Creates a new @command{tar} archive. @xref{create}.
  1735. @opindex delete, summary
  1736. @item --delete
  1737. Deletes members from the archive. Don't try this on a archive on a
  1738. tape! @xref{delete}.
  1739. @opindex diff, summary
  1740. @item --diff
  1741. @itemx -d
  1742. Same @option{--compare}. @xref{compare}.
  1743. @opindex extract, summary
  1744. @item --extract
  1745. @itemx -x
  1746. Extracts members from the archive into the file system. @xref{extract}.
  1747. @opindex get, summary
  1748. @item --get
  1749. @itemx -x
  1750. Same as @option{--extract}. @xref{extract}.
  1751. @opindex list, summary
  1752. @item --list
  1753. @itemx -t
  1754. Lists the members in an archive. @xref{list}.
  1755. @opindex update, summary
  1756. @item --update
  1757. @itemx -u
  1758. Adds files to the end of the archive, but only if they are newer than
  1759. their counterparts already in the archive, or if they do not already
  1760. exist in the archive. @xref{update}.
  1761. @end table
  1762. @node Option Summary
  1763. @subsection @command{tar} Options
  1764. @table @option
  1765. @opindex absolute-names, summary
  1766. @item --absolute-names
  1767. @itemx -P
  1768. Normally when creating an archive, @command{tar} strips an initial
  1769. @samp{/} from member names. This option disables that behavior.
  1770. @xref{absolute}.
  1771. @opindex after-date, summary
  1772. @item --after-date
  1773. (See @option{--newer}, @pxref{after})
  1774. @opindex anchored, summary
  1775. @item --anchored
  1776. A pattern must match an initial subsequence of the name's components.
  1777. @xref{controlling pattern-matching}.
  1778. @opindex atime-preserve, summary
  1779. @item --atime-preserve
  1780. @itemx --atime-preserve=replace
  1781. @itemx --atime-preserve=system
  1782. Attempt to preserve the access time of files when reading them. This
  1783. option currently is effective only on files that you own, unless you
  1784. have superuser privileges.
  1785. @option{--atime-preserve=replace} remembers the access time of a file
  1786. before reading it, and then restores the access time afterwards. This
  1787. may cause problems if other programs are reading the file at the same
  1788. time, as the times of their accesses will be lost. On most platforms
  1789. restoring the access time also requires @command{tar} to restore the
  1790. data modification time too, so this option may also cause problems if
  1791. other programs are writing the file at the same time. (Tar attempts
  1792. to detect this situation, but cannot do so reliably due to race
  1793. conditions.) Worse, on most platforms restoring the access time also
  1794. updates the status change time, which means that this option is
  1795. incompatible with incremental backups.
  1796. @option{--atime-preserve=system} avoids changing time stamps on files,
  1797. without interfering with time stamp updates
  1798. caused by other programs, so it works better with incremental backups.
  1799. However, it requires a special @code{O_NOATIME} option from the
  1800. underlying operating and file system implementation, and it also requires
  1801. that searching directories does not update their access times. As of
  1802. this writing (November 2005) this works only with Linux, and only with
  1803. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1804. way to know whether this feature actually works. Sometimes
  1805. @command{tar} knows that it does not work, and if you use
  1806. @option{--atime-preserve=system} then @command{tar} complains and
  1807. exits right away. But other times @command{tar} might think that the
  1808. option works when it actually does not.
  1809. Currently @option{--atime-preserve} with no operand defaults to
  1810. @option{--atime-preserve=replace}, but this may change in the future
  1811. as support for @option{--atime-preserve=system} improves.
  1812. If your operating system does not support
  1813. @option{--atime-preserve=system}, you might be able to preserve access
  1814. times reliably by by using the @command{mount} command. For example,
  1815. you can mount the file system read-only, or access the file system via
  1816. a read-only loopback mount, or use the @samp{noatime} mount option
  1817. available on some systems. However, mounting typically requires
  1818. superuser privileges and can be a pain to manage.
  1819. @opindex backup, summary
  1820. @item --backup=@var{backup-type}
  1821. Rather than deleting files from the file system, @command{tar} will
  1822. back them up using simple or numbered backups, depending upon
  1823. @var{backup-type}. @xref{backup}.
  1824. @opindex block-number, summary
  1825. @item --block-number
  1826. @itemx -R
  1827. With this option present, @command{tar} prints error messages for read errors
  1828. with the block number in the archive file. @xref{block-number}.
  1829. @opindex blocking-factor, summary
  1830. @item --blocking-factor=@var{blocking}
  1831. @itemx -b @var{blocking}
  1832. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1833. record. @xref{Blocking Factor}.
  1834. @opindex bzip2, summary
  1835. @item --bzip2
  1836. @itemx -j
  1837. This option tells @command{tar} to read or write archives through
  1838. @code{bzip2}. @xref{gzip}.
  1839. @opindex checkpoint, summary
  1840. @item --checkpoint
  1841. This option directs @command{tar} to print periodic checkpoint messages as it
  1842. reads through the archive. It is intended for when you want a visual
  1843. indication that @command{tar} is still running, but don't want to see
  1844. @option{--verbose} output. @FIXME-xref{}
  1845. @opindex check-links, summary
  1846. @item --check-links
  1847. @itemx -l
  1848. If this option was given, @command{tar} will check the number of links
  1849. dumped for each processed file. If this number does not match the
  1850. total number of hard links for the file, a warning message will be
  1851. output @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  1852. synonym for @option{--one-file-system}. The current semantics, wich
  1853. complies to UNIX98, was introduced with version
  1854. 1.15.91. @xref{Changes}, for more information.}.
  1855. @opindex compress, summary
  1856. @opindex uncompress, summary
  1857. @item --compress
  1858. @itemx --uncompress
  1859. @itemx -Z
  1860. @command{tar} will use the @command{compress} program when reading or
  1861. writing the archive. This allows you to directly act on archives
  1862. while saving space. @xref{gzip}.
  1863. @opindex confirmation, summary
  1864. @item --confirmation
  1865. (See @option{--interactive}.) @xref{interactive}.
  1866. @opindex delay-directory-restore, summary
  1867. @item --delay-directory-restore
  1868. Delay setting modification times and permissions of extracted
  1869. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  1870. @opindex dereference, summary
  1871. @item --dereference
  1872. @itemx -h
  1873. When creating a @command{tar} archive, @command{tar} will archive the
  1874. file that a symbolic link points to, rather than archiving the
  1875. symlink. @xref{dereference}.
  1876. @opindex directory, summary
  1877. @item --directory=@var{dir}
  1878. @itemx -C @var{dir}
  1879. When this option is specified, @command{tar} will change its current directory
  1880. to @var{dir} before performing any operations. When this option is used
  1881. during archive creation, it is order sensitive. @xref{directory}.
  1882. @opindex exclude, summary
  1883. @item --exclude=@var{pattern}
  1884. When performing operations, @command{tar} will skip files that match
  1885. @var{pattern}. @xref{exclude}.
  1886. @opindex exclude-from, summary
  1887. @item --exclude-from=@var{file}
  1888. @itemx -X @var{file}
  1889. Similar to @option{--exclude}, except @command{tar} will use the list of
  1890. patterns in the file @var{file}. @xref{exclude}.
  1891. @opindex exclude-caches, summary
  1892. @item --exclude-caches
  1893. Automatically excludes all directories
  1894. containing a cache directory tag. @xref{exclude}.
  1895. @opindex file, summary
  1896. @item --file=@var{archive}
  1897. @itemx -f @var{archive}
  1898. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1899. performs operations on, rather than @command{tar}'s compilation dependent
  1900. default. @xref{file tutorial}.
  1901. @opindex files-from, summary
  1902. @item --files-from=@var{file}
  1903. @itemx -T @var{file}
  1904. @command{tar} will use the contents of @var{file} as a list of archive members
  1905. or files to operate on, in addition to those specified on the
  1906. command-line. @xref{files}.
  1907. @opindex force-local, summary
  1908. @item --force-local
  1909. Forces @command{tar} to interpret the filename given to @option{--file}
  1910. as a local file, even if it looks like a remote tape drive name.
  1911. @xref{local and remote archives}.
  1912. @opindex format, summary
  1913. @item --format=@var{format}
  1914. Selects output archive format. @var{Format} may be one of the
  1915. following:
  1916. @table @samp
  1917. @item v7
  1918. Creates an archive that is compatible with Unix V7 @command{tar}.
  1919. @item oldgnu
  1920. Creates an archive that is compatible with GNU @command{tar} version
  1921. 1.12 or earlier.
  1922. @item gnu
  1923. Creates archive in GNU tar 1.13 format. Basically it is the same as
  1924. @samp{oldgnu} with the only difference in the way it handles long
  1925. numeric fields.
  1926. @item ustar
  1927. Creates a @acronym{POSIX.1-1988} compatible archive.
  1928. @item posix
  1929. Creates a @acronym{POSIX.1-2001 archive}.
  1930. @end table
  1931. @xref{Formats}, for a detailed discussion of these formats.
  1932. @opindex group, summary
  1933. @item --group=@var{group}
  1934. Files added to the @command{tar} archive will have a group id of @var{group},
  1935. rather than the group from the source file. @var{group} is first decoded
  1936. as a group symbolic name, but if this interpretation fails, it has to be
  1937. a decimal numeric group ID. @FIXME-xref{}
  1938. Also see the comments for the @option{--owner=@var{user}} option.
  1939. @opindex gzip, summary
  1940. @opindex gunzip, summary
  1941. @opindex ungzip, summary
  1942. @item --gzip
  1943. @itemx --gunzip
  1944. @itemx --ungzip
  1945. @itemx -z
  1946. This option tells @command{tar} to read or write archives through
  1947. @command{gzip}, allowing @command{tar} to directly operate on several
  1948. kinds of compressed archives transparently. @xref{gzip}.
  1949. @opindex help, summary
  1950. @item --help
  1951. @command{tar} will print out a short message summarizing the operations and
  1952. options to @command{tar} and exit. @xref{help}.
  1953. @opindex ignore-case, summary
  1954. @item --ignore-case
  1955. Ignore case when matching member or file names with
  1956. patterns. @xref{controlling pattern-matching}.
  1957. @opindex ignore-command-error, summary
  1958. @item --ignore-command-error
  1959. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  1960. @opindex ignore-failed-read, summary
  1961. @item --ignore-failed-read
  1962. Do not exit unsuccessfully merely because an unreadable file was encountered.
  1963. @xref{Reading}.
  1964. @opindex ignore-zeros, summary
  1965. @item --ignore-zeros
  1966. @itemx -i
  1967. With this option, @command{tar} will ignore zeroed blocks in the
  1968. archive, which normally signals EOF. @xref{Reading}.
  1969. @opindex incremental, summary
  1970. @item --incremental
  1971. @itemx -G
  1972. Used to inform @command{tar} that it is working with an old
  1973. @acronym{GNU}-format incremental backup archive. It is intended
  1974. primarily for backwards compatibility only. @xref{Incremental Dumps},
  1975. for a detailed discussion of incremental archives.
  1976. @opindex index-file, summary
  1977. @item --index-file=@var{file}
  1978. Send verbose output to @var{file} instead of to standard output.
  1979. @opindex info-script, summary
  1980. @opindex new-volume-script, summary
  1981. @item --info-script=@var{script-file}
  1982. @itemx --new-volume-script=@var{script-file}
  1983. @itemx -F @var{script-file}
  1984. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  1985. at the end of each tape. If @var{script-file} exits with nonzero status,
  1986. @command{tar} fails immediately. @xref{info-script}, for a detailed
  1987. discussion of @var{script-file}.
  1988. @opindex interactive, summary
  1989. @item --interactive
  1990. @itemx --confirmation
  1991. @itemx -w
  1992. Specifies that @command{tar} should ask the user for confirmation before
  1993. performing potentially destructive options, such as overwriting files.
  1994. @xref{interactive}.
  1995. @opindex keep-newer-files, summary
  1996. @item --keep-newer-files
  1997. Do not replace existing files that are newer than their archive copies
  1998. when extracting files from an archive.
  1999. @opindex keep-old-files, summary
  2000. @item --keep-old-files
  2001. @itemx -k
  2002. Do not overwrite existing files when extracting files from an archive.
  2003. @xref{Keep Old Files}.
  2004. @opindex label, summary
  2005. @item --label=@var{name}
  2006. @itemx -V @var{name}
  2007. When creating an archive, instructs @command{tar} to write @var{name}
  2008. as a name record in the archive. When extracting or listing archives,
  2009. @command{tar} will only operate on archives that have a label matching
  2010. the pattern specified in @var{name}. @xref{Tape Files}.
  2011. @opindex listed-incremental, summary
  2012. @item --listed-incremental=@var{snapshot-file}
  2013. @itemx -g @var{snapshot-file}
  2014. During a @option{--create} operation, specifies that the archive that
  2015. @command{tar} creates is a new @acronym{GNU}-format incremental
  2016. backup, using @var{snapshot-file} to determine which files to backup.
  2017. With other operations, informs @command{tar} that the archive is in
  2018. incremental format. @xref{Incremental Dumps}.
  2019. @opindex mode, summary
  2020. @item --mode=@var{permissions}
  2021. When adding files to an archive, @command{tar} will use
  2022. @var{permissions} for the archive members, rather than the permissions
  2023. from the files. The program @command{chmod} and this @command{tar}
  2024. option share the same syntax for what @var{permissions} might be.
  2025. @xref{File permissions, Permissions, File permissions, fileutils,
  2026. @acronym{GNU} file utilities}. This reference also has useful
  2027. information for those not being overly familiar with the Unix
  2028. permission system.
  2029. Of course, @var{permissions} might be plainly specified as an octal number.
  2030. However, by using generic symbolic modifications to mode bits, this allows
  2031. more flexibility. For example, the value @samp{a+rw} adds read and write
  2032. permissions for everybody, while retaining executable bits on directories
  2033. or on any other file already marked as executable.
  2034. @opindex multi-volume, summary
  2035. @item --multi-volume
  2036. @itemx -M
  2037. Informs @command{tar} that it should create or otherwise operate on a
  2038. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2039. @opindex new-volume-script, summary
  2040. @item --new-volume-script
  2041. (see --info-script)
  2042. @opindex seek, summary
  2043. @item --seek
  2044. @itemx -n
  2045. Assume that the archive media supports seeks to arbitrary
  2046. locations. Usually @command{tar} determines automatically whether
  2047. the archive can be seeked or not. This option is intended for use
  2048. in cases when such recognition fails.
  2049. @opindex newer, summary
  2050. @item --newer=@var{date}
  2051. @itemx --after-date=@var{date}
  2052. @itemx -N
  2053. When creating an archive, @command{tar} will only add files that have changed
  2054. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2055. is taken to be the name of a file whose data modification time specifies
  2056. the date. @xref{after}.
  2057. @opindex newer-mtime, summary
  2058. @item --newer-mtime=@var{date}
  2059. Like @option{--newer}, but add only files whose
  2060. contents have changed (as opposed to just @option{--newer}, which will
  2061. also back up files for which any status information has changed).
  2062. @opindex no-anchored, summary
  2063. @item --no-anchored
  2064. An exclude pattern can match any subsequence of the name's components.
  2065. @xref{controlling pattern-matching}.
  2066. @opindex no-delay-directory-restore, summary
  2067. @item --no-delay-directory-restore
  2068. Setting modification times and permissions of extracted
  2069. directories when all files from this directory has been
  2070. extracted. This is the default. @xref{Directory Modification Times and Permissions}.
  2071. @opindex no-ignore-case, summary
  2072. @item --no-ignore-case
  2073. Use case-sensitive matching.
  2074. @xref{controlling pattern-matching}.
  2075. @opindex no-ignore-command-error, summary
  2076. @item --no-ignore-command-error
  2077. Print warnings about subprocesses terminated with a non-zero exit
  2078. code. @xref{Writing to an External Program}.
  2079. @opindex no-quote-chars, summary
  2080. @item --no-quote-chars=@var{string}
  2081. Do not quote characters from @var{string}, even if the selected
  2082. quoting style implies they should be quoted (@pxref{quoting styles}).
  2083. @opindex no-recursion, summary
  2084. @item --no-recursion
  2085. With this option, @command{tar} will not recurse into directories.
  2086. @xref{recurse}.
  2087. @opindex no-same-owner, summary
  2088. @item --no-same-owner
  2089. @itemx -o
  2090. When extracting an archive, do not attempt to preserve the owner
  2091. specified in the @command{tar} archive. This the default behavior
  2092. for ordinary users.
  2093. @opindex no-same-permissions, summary
  2094. @item --no-same-permissions
  2095. When extracting an archive, subtract the user's umask from files from
  2096. the permissions specified in the archive. This is the default behavior
  2097. for ordinary users.
  2098. @opindex no-wildcards, summary
  2099. @item --no-wildcards
  2100. Do not use wildcards.
  2101. @xref{controlling pattern-matching}.
  2102. @opindex no-wildcards-match-slash, summary
  2103. @item --no-wildcards-match-slash
  2104. Wildcards do not match @samp{/}.
  2105. @xref{controlling pattern-matching}.
  2106. @opindex null, summary
  2107. @item --null
  2108. When @command{tar} is using the @option{--files-from} option, this option
  2109. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2110. @command{tar} can correctly work with file names that contain newlines.
  2111. @xref{nul}.
  2112. @opindex numeric-owner, summary
  2113. @item --numeric-owner
  2114. This option will notify @command{tar} that it should use numeric user
  2115. and group IDs when creating a @command{tar} file, rather than names.
  2116. @xref{Attributes}.
  2117. @item -o
  2118. When extracting files, this option is a synonym for
  2119. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2120. restoring ownership of files being extracted.
  2121. When creating an archive, @option{-o} is a synonym for
  2122. @option{--old-archive}. This behavior is for compatibility
  2123. with previous versions of @GNUTAR{}, and will be
  2124. removed in the future releases.
  2125. @xref{Changes}, for more information.
  2126. @opindex occurrence, summary
  2127. @item --occurrence[=@var{number}]
  2128. This option can be used in conjunction with one of the subcommands
  2129. @option{--delete}, @option{--diff}, @option{--extract} or
  2130. @option{--list} when a list of files is given either on the command
  2131. line or via @option{-T} option.
  2132. This option instructs @command{tar} to process only the @var{number}th
  2133. occurrence of each named file. @var{Number} defaults to 1, so
  2134. @smallexample
  2135. tar -x -f archive.tar --occurrence filename
  2136. @end smallexample
  2137. @noindent
  2138. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2139. and will terminate without scanning to the end of the archive.
  2140. @opindex old-archive, summary
  2141. @item --old-archive
  2142. Synonym for @option{--format=v7}.
  2143. @opindex one-file-system, summary
  2144. @item --one-file-system
  2145. Used when creating an archive. Prevents @command{tar} from recursing into
  2146. directories that are on different file systems from the current
  2147. directory @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  2148. synonym for @option{--one-file-system}. This has changed in version
  2149. 1.15.91. @xref{Changes}, for more information.}.
  2150. @opindex overwrite, summary
  2151. @item --overwrite
  2152. Overwrite existing files and directory metadata when extracting files
  2153. from an archive. @xref{Overwrite Old Files}.
  2154. @opindex overwrite-dir, summary
  2155. @item --overwrite-dir
  2156. Overwrite the metadata of existing directories when extracting files
  2157. from an archive. @xref{Overwrite Old Files}.
  2158. @opindex owner, summary
  2159. @item --owner=@var{user}
  2160. Specifies that @command{tar} should use @var{user} as the owner of members
  2161. when creating archives, instead of the user associated with the source
  2162. file. @var{user} is first decoded as a user symbolic name, but if
  2163. this interpretation fails, it has to be a decimal numeric user ID.
  2164. @FIXME-xref{}
  2165. There is no value indicating a missing number, and @samp{0} usually means
  2166. @code{root}. Some people like to force @samp{0} as the value to offer in
  2167. their distributions for the owner of files, because the @code{root} user is
  2168. anonymous anyway, so that might as well be the owner of anonymous archives.
  2169. This option does not affect extraction from archives.
  2170. @opindex quote-chars, summary
  2171. @item --quote-chars=@var{string}
  2172. Always quote characters from @var{string}, even if the selected
  2173. quoting style would not quote them (@pxref{quoting styles}).
  2174. @opindex quoting-style, summary
  2175. @item --quoting-style=@var{style}
  2176. Set quoting style to use when printing member and file names
  2177. (@pxref{quoting styles}). Valid @var{style} values are:
  2178. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2179. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2180. style is @code{escape}, unless overridden while configuring the
  2181. package.
  2182. @opindex pax-option, summary
  2183. @item --pax-option=@var{keyword-list}
  2184. @FIXME{Such a detailed description does not belong there, move it elsewhere.}
  2185. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2186. (@pxref{posix}). It modifies the way @command{tar} handles the
  2187. extended header keywords. @var{Keyword-list} is a comma-separated
  2188. list of keyword options, each keyword option taking one of
  2189. the following forms:
  2190. @table @asis
  2191. @item delete=@var{pattern}
  2192. When used with one of archive-creation commands,
  2193. this option instructs @command{tar} to omit from extended header records
  2194. that it produces any keywords matching the string @var{pattern}.
  2195. When used in extract or list mode, this option instructs tar
  2196. to ignore any keywords matching the given @var{pattern} in the extended
  2197. header records. In both cases, matching is performed using the pattern
  2198. matching notation described in @acronym{POSIX 1003.2}, 3.13
  2199. (See @cite{glob(7)}). For example:
  2200. @smallexample
  2201. --pax-option delete=security.*
  2202. @end smallexample
  2203. would suppress security-related information.
  2204. @item exthdr.name=@var{string}
  2205. This keyword allows user control over the name that is written into the
  2206. ustar header blocks for the extended headers. The name is obtained
  2207. from @var{string} after making the following substitutions:
  2208. @multitable @columnfractions .30 .70
  2209. @headitem Meta-character @tab Replaced By
  2210. @item %d @tab The directory name of the file, equivalent to the
  2211. result of the @command{dirname} utility on the translated pathname.
  2212. @item %f @tab The filename of the file, equivalent to the result
  2213. of the @command{basename} utility on the translated pathname.
  2214. @item %p @tab The process ID of the @command{tar} process.
  2215. @item %% @tab A @samp{%} character.
  2216. @end multitable
  2217. Any other @samp{%} characters in @var{string} produce undefined
  2218. results.
  2219. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2220. will use the following default value:
  2221. @smallexample
  2222. %d/PaxHeaders.%p/%f
  2223. @end smallexample
  2224. @item globexthdr.name=@var{string}
  2225. This keyword allows user control over the name that is written into
  2226. the ustar header blocks for global extended header records. The name
  2227. is obtained from the contents of @var{string}, after making
  2228. the following substitutions:
  2229. @multitable @columnfractions .30 .70
  2230. @headitem Meta-character @tab Replaced By
  2231. @item %n @tab An integer that represents the
  2232. sequence number of the global extended header record in the archive,
  2233. starting at 1.
  2234. @item %p @tab The process ID of the @command{tar} process.
  2235. @item %% @tab A @samp{%} character.
  2236. @end multitable
  2237. Any other @samp{%} characters in @var{string} produce undefined results.
  2238. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2239. will use the following default value:
  2240. @smallexample
  2241. $TMPDIR/GlobalHead.%p.%n
  2242. @end smallexample
  2243. @noindent
  2244. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2245. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2246. uses @samp{/tmp}.
  2247. @item @var{keyword}=@var{value}
  2248. When used with one of archive-creation commands, these keyword/value pairs
  2249. will be included at the beginning of the archive in a global extended
  2250. header record. When used with one of archive-reading commands,
  2251. @command{tar} will behave as if it has encountered these keyword/value
  2252. pairs at the beginning of the archive in a global extended header
  2253. record.
  2254. @item @var{keyword}:=@var{value}
  2255. When used with one of archive-creation commands, these keyword/value pairs
  2256. will be included as records at the beginning of an extended header for
  2257. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2258. form except that it creates no global extended header records.
  2259. When used with one of archive-reading commands, @command{tar} will
  2260. behave as if these keyword/value pairs were included as records at the
  2261. end of each extended header; thus, they will override any global or
  2262. file-specific extended header record keywords of the same names.
  2263. For example, in the command:
  2264. @smallexample
  2265. tar --format=posix --create \
  2266. --file archive --pax-option gname:=user .
  2267. @end smallexample
  2268. the group name will be forced to a new value for all files
  2269. stored in the archive.
  2270. @end table
  2271. @opindex portability, summary
  2272. @item --portability
  2273. @itemx --old-archive
  2274. Synonym for @option{--format=v7}.
  2275. @opindex posix, summary
  2276. @item --posix
  2277. Same as @option{--format=posix}.
  2278. @opindex preserve, summary
  2279. @item --preserve
  2280. Synonymous with specifying both @option{--preserve-permissions} and
  2281. @option{--same-order}. @xref{Setting Access Permissions}.
  2282. @opindex preserve-order, summary
  2283. @item --preserve-order
  2284. (See @option{--same-order}; @pxref{Reading}.)
  2285. @opindex preserve-permissions, summary
  2286. @opindex same-permissions, summary
  2287. @item --preserve-permissions
  2288. @itemx --same-permissions
  2289. @itemx -p
  2290. When @command{tar} is extracting an archive, it normally subtracts the
  2291. users' umask from the permissions specified in the archive and uses
  2292. that number as the permissions to create the destination file.
  2293. Specifying this option instructs @command{tar} that it should use the
  2294. permissions directly from the archive. @xref{Setting Access Permissions}.
  2295. @opindex read-full-records, summary
  2296. @item --read-full-records
  2297. @itemx -B
  2298. Specifies that @command{tar} should reblock its input, for reading
  2299. from pipes on systems with buggy implementations. @xref{Reading}.
  2300. @opindex record-size, summary
  2301. @item --record-size=@var{size}
  2302. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2303. archive. @xref{Blocking Factor}.
  2304. @opindex recursion, summary
  2305. @item --recursion
  2306. With this option, @command{tar} recurses into directories.
  2307. @xref{recurse}.
  2308. @opindex recursive-unlink, summary
  2309. @item --recursive-unlink
  2310. Remove existing
  2311. directory hierarchies before extracting directories of the same name
  2312. from the archive. @xref{Recursive Unlink}.
  2313. @opindex remove-files, summary
  2314. @item --remove-files
  2315. Directs @command{tar} to remove the source file from the file system after
  2316. appending it to an archive. @xref{remove files}.
  2317. @opindex restrict, summary
  2318. @item --restrict
  2319. Disable use of some potentially harmful @command{tar} options.
  2320. Currently this option disables shell invocaton from multi-volume menu
  2321. (@pxref{Using Multiple Tapes}).
  2322. @opindex rmt-command, summary
  2323. @item --rmt-command=@var{cmd}
  2324. Notifies @command{tar} that it should use @var{cmd} instead of
  2325. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2326. @opindex rsh-command, summary
  2327. @item --rsh-command=@var{cmd}
  2328. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2329. devices. @xref{Device}.
  2330. @opindex same-order, summary
  2331. @item --same-order
  2332. @itemx --preserve-order
  2333. @itemx -s
  2334. This option is an optimization for @command{tar} when running on machines with
  2335. small amounts of memory. It informs @command{tar} that the list of file
  2336. arguments has already been sorted to match the order of files in the
  2337. archive. @xref{Reading}.
  2338. @opindex same-owner, summary
  2339. @item --same-owner
  2340. When extracting an archive, @command{tar} will attempt to preserve the owner
  2341. specified in the @command{tar} archive with this option present.
  2342. This is the default behavior for the superuser; this option has an
  2343. effect only for ordinary users. @xref{Attributes}.
  2344. @opindex same-permissions, summary
  2345. @item --same-permissions
  2346. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2347. @opindex show-defaults, summary
  2348. @item --show-defaults
  2349. Displays the default options used by @command{tar} and exits
  2350. successfully. This option is intended for use in shell scripts.
  2351. Here is an example of what you can see using this option:
  2352. @smallexample
  2353. $ tar --show-defaults
  2354. --format=gnu -f- -b20 --quoting-style=escape \
  2355. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2356. @end smallexample
  2357. @opindex show-omitted-dirs, summary
  2358. @item --show-omitted-dirs
  2359. Instructs @command{tar} to mention directories its skipping over when
  2360. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2361. @opindex show-stored-names, summary
  2362. @item --show-stored-names
  2363. This option has effect only when used in conjunction with one of
  2364. archive creation operations. It instructs tar to list the member names
  2365. stored in the archive, as opposed to the actual file
  2366. names. @xref{listing member and file names}.
  2367. @opindex sparse, summary
  2368. @item --sparse
  2369. @itemx -S
  2370. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2371. sparse files efficiently. @xref{sparse}.
  2372. @opindex starting-file, summary
  2373. @item --starting-file=@var{name}
  2374. @itemx -K @var{name}
  2375. This option affects extraction only; @command{tar} will skip extracting
  2376. files in the archive until it finds one that matches @var{name}.
  2377. @xref{Scarce}.
  2378. @opindex strip-components, summary
  2379. @item --strip-components=@var{number}
  2380. Strip given @var{number} of leading components from file names before
  2381. extraction.@footnote{This option was called @option{--strip-path} in
  2382. version 1.14.} For example, if archive @file{archive.tar} contained
  2383. @file{/some/file/name}, then running
  2384. @smallexample
  2385. tar --extract --file archive.tar --strip-components=2
  2386. @end smallexample
  2387. @noindent
  2388. would extracted this file to file @file{name}.
  2389. @opindex suffix, summary
  2390. @item --suffix=@var{suffix}
  2391. Alters the suffix @command{tar} uses when backing up files from the default
  2392. @samp{~}. @xref{backup}.
  2393. @opindex tape-length, summary
  2394. @item --tape-length=@var{num}
  2395. @itemx -L @var{num}
  2396. Specifies the length of tapes that @command{tar} is writing as being
  2397. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2398. @opindex test-label, summary
  2399. @item --test-label
  2400. Reads the volume label. If an argument is specified, test whether it
  2401. matches the volume label. @xref{--test-label option}.
  2402. @opindex to-command, summary
  2403. @item --to-command=@var{command}
  2404. During extraction @command{tar} will pipe extracted files to the
  2405. standard input of @var{command}. @xref{Writing to an External Program}.
  2406. @opindex to-stdout, summary
  2407. @item --to-stdout
  2408. @itemx -O
  2409. During extraction, @command{tar} will extract files to stdout rather
  2410. than to the file system. @xref{Writing to Standard Output}.
  2411. @opindex totals, summary
  2412. @item --totals
  2413. Displays the total number of bytes written after creating an archive.
  2414. @xref{verbose}.
  2415. @opindex touch, summary
  2416. @item --touch
  2417. @itemx -m
  2418. Sets the data modification time of extracted files to the extraction time,
  2419. rather than the data modification time stored in the archive.
  2420. @xref{Data Modification Times}.
  2421. @opindex uncompress, summary
  2422. @item --uncompress
  2423. (See @option{--compress}. @pxref{gzip})
  2424. @opindex ungzip, summary
  2425. @item --ungzip
  2426. (See @option{--gzip}. @pxref{gzip})
  2427. @opindex unlink-first, summary
  2428. @item --unlink-first
  2429. @itemx -U
  2430. Directs @command{tar} to remove the corresponding file from the file
  2431. system before extracting it from the archive. @xref{Unlink First}.
  2432. @opindex use-compress-program, summary
  2433. @item --use-compress-program=@var{prog}
  2434. Instructs @command{tar} to access the archive through @var{prog}, which is
  2435. presumed to be a compression program of some sort. @xref{gzip}.
  2436. @opindex utc, summary
  2437. @item --utc
  2438. Display file modification dates in @acronym{UTC}. This option implies
  2439. @option{--verbose}.
  2440. @opindex verbose, summary
  2441. @item --verbose
  2442. @itemx -v
  2443. Specifies that @command{tar} should be more verbose about the operations its
  2444. performing. This option can be specified multiple times for some
  2445. operations to increase the amount of information displayed.
  2446. @xref{verbose}.
  2447. @opindex verify, summary
  2448. @item --verify
  2449. @itemx -W
  2450. Verifies that the archive was correctly written when creating an
  2451. archive. @xref{verify}.
  2452. @opindex version, summary
  2453. @item --version
  2454. Print information about the program's name, version, origin and legal
  2455. status, all on standard output, and then exit successfully.
  2456. @xref{help}.
  2457. @opindex volno-file, summary
  2458. @item --volno-file=@var{file}
  2459. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2460. of which volume of a multi-volume archive its working in @var{file}.
  2461. @xref{volno-file}.
  2462. @opindex wildcards, summary
  2463. @item --wildcards
  2464. Use wildcards when matching member names with patterns.
  2465. @xref{controlling pattern-matching}.
  2466. @opindex wildcards-match-slash, summary
  2467. @item --wildcards-match-slash
  2468. Wildcards match @samp{/}.
  2469. @xref{controlling pattern-matching}.
  2470. @end table
  2471. @node Short Option Summary
  2472. @subsection Short Options Cross Reference
  2473. Here is an alphabetized list of all of the short option forms, matching
  2474. them with the equivalent long option.
  2475. @table @option
  2476. @item -A
  2477. @option{--concatenate}
  2478. @item -B
  2479. @option{--read-full-records}
  2480. @item -C
  2481. @option{--directory}
  2482. @item -F
  2483. @option{--info-script}
  2484. @item -G
  2485. @option{--incremental}
  2486. @item -K
  2487. @option{--starting-file}
  2488. @item -L
  2489. @option{--tape-length}
  2490. @item -M
  2491. @option{--multi-volume}
  2492. @item -N
  2493. @option{--newer}
  2494. @item -O
  2495. @option{--to-stdout}
  2496. @item -P
  2497. @option{--absolute-names}
  2498. @item -R
  2499. @option{--block-number}
  2500. @item -S
  2501. @option{--sparse}
  2502. @item -T
  2503. @option{--files-from}
  2504. @item -U
  2505. @option{--unlink-first}
  2506. @item -V
  2507. @option{--label}
  2508. @item -W
  2509. @option{--verify}
  2510. @item -X
  2511. @option{--exclude-from}
  2512. @item -Z
  2513. @option{--compress}
  2514. @item -b
  2515. @option{--blocking-factor}
  2516. @item -c
  2517. @option{--create}
  2518. @item -d
  2519. @option{--compare}
  2520. @item -f
  2521. @option{--file}
  2522. @item -g
  2523. @option{--listed-incremental}
  2524. @item -h
  2525. @option{--dereference}
  2526. @item -i
  2527. @option{--ignore-zeros}
  2528. @item -j
  2529. @option{--bzip2}
  2530. @item -k
  2531. @option{--keep-old-files}
  2532. @item -l
  2533. @option{--one-file-system}. Use of this short option is deprecated. It
  2534. is retained for compatibility with the earlier versions of GNU
  2535. @command{tar}, and will be changed in future releases.
  2536. @xref{Changes}, for more information.
  2537. @item -m
  2538. @option{--touch}
  2539. @item -o
  2540. When creating --- @option{--no-same-owner}, when extracting ---
  2541. @option{--portability}.
  2542. The later usage is deprecated. It is retained for compatibility with
  2543. the earlier versions of @GNUTAR{}. In the future releases
  2544. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2545. @item -p
  2546. @option{--preserve-permissions}
  2547. @item -r
  2548. @option{--append}
  2549. @item -s
  2550. @option{--same-order}
  2551. @item -t
  2552. @option{--list}
  2553. @item -u
  2554. @option{--update}
  2555. @item -v
  2556. @option{--verbose}
  2557. @item -w
  2558. @option{--interactive}
  2559. @item -x
  2560. @option{--extract}
  2561. @item -z
  2562. @option{--gzip}
  2563. @end table
  2564. @node help
  2565. @section @GNUTAR{} documentation
  2566. @cindex Getting program version number
  2567. @opindex version
  2568. @cindex Version of the @command{tar} program
  2569. Being careful, the first thing is really checking that you are using
  2570. @GNUTAR{}, indeed. The @option{--version} option
  2571. causes @command{tar} to print information about its name, version,
  2572. origin and legal status, all on standard output, and then exit
  2573. successfully. For example, @w{@samp{tar --version}} might print:
  2574. @smallexample
  2575. tar (GNU tar) 1.15.2
  2576. Copyright (C) 2006 Free Software Foundation, Inc.
  2577. This is free software. You may redistribute copies of it under the terms of
  2578. the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  2579. There is NO WARRANTY, to the extent permitted by law.
  2580. Written by John Gilmore and Jay Fenlason.
  2581. @end smallexample
  2582. @noindent
  2583. The first occurrence of @samp{tar} in the result above is the program
  2584. name in the package (for example, @command{rmt} is another program),
  2585. while the second occurrence of @samp{tar} is the name of the package
  2586. itself, containing possibly many programs. The package is currently
  2587. named @samp{tar}, after the name of the main program it
  2588. contains@footnote{There are plans to merge the @command{cpio} and
  2589. @command{tar} packages into a single one which would be called
  2590. @code{paxutils}. So, who knows if, one of this days, the
  2591. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2592. paxutils) 3.2}}}.
  2593. @cindex Obtaining help
  2594. @cindex Listing all @command{tar} options
  2595. @opindex help, introduction
  2596. Another thing you might want to do is checking the spelling or meaning
  2597. of some particular @command{tar} option, without resorting to this
  2598. manual, for once you have carefully read it. @GNUTAR{}
  2599. has a short help feature, triggerable through the
  2600. @option{--help} option. By using this option, @command{tar} will
  2601. print a usage message listing all available options on standard
  2602. output, then exit successfully, without doing anything else and
  2603. ignoring all other options. Even if this is only a brief summary, it
  2604. may be several screens long. So, if you are not using some kind of
  2605. scrollable window, you might prefer to use something like:
  2606. @smallexample
  2607. $ @kbd{tar --help | less}
  2608. @end smallexample
  2609. @noindent
  2610. presuming, here, that you like using @command{less} for a pager. Other
  2611. popular pagers are @command{more} and @command{pg}. If you know about some
  2612. @var{keyword} which interests you and do not want to read all the
  2613. @option{--help} output, another common idiom is doing:
  2614. @smallexample
  2615. tar --help | grep @var{keyword}
  2616. @end smallexample
  2617. @noindent
  2618. for getting only the pertinent lines. Notice, however, that some
  2619. @command{tar} options have long description lines and the above
  2620. command will list only the first of them.
  2621. The exact look of the option summary displayed by @kbd{tar --help} is
  2622. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2623. @opindex usage
  2624. If you only wish to check the spelling of an option, running @kbd{tar
  2625. --usage} may be a better choice. This will display a terse list of
  2626. @command{tar} option without accompanying explanations.
  2627. The short help output is quite succinct, and you might have to get
  2628. back to the full documentation for precise points. If you are reading
  2629. this paragraph, you already have the @command{tar} manual in some
  2630. form. This manual is available in a variety of forms from
  2631. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2632. distribution, provided you have @TeX{} already installed somewhere,
  2633. and a laser printer around. Just configure the distribution, execute
  2634. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2635. usual way (contact your local guru to know how). If @GNUTAR{}
  2636. has been conveniently installed at your place, this
  2637. manual is also available in interactive, hypertextual form as an Info
  2638. file. Just call @w{@samp{info tar}} or, if you do not have the
  2639. @command{info} program handy, use the Info reader provided within
  2640. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2641. There is currently no @code{man} page for @GNUTAR{}.
  2642. If you observe such a @code{man} page on the system you are running,
  2643. either it does not belong to @GNUTAR{}, or it has not
  2644. been produced by @acronym{GNU}. Some package maintainers convert
  2645. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2646. any case, please bear in mind that the authoritative source of
  2647. information about @GNUTAR{} is this Texinfo documentation.
  2648. @node defaults
  2649. @section Obtaining @GNUTAR{} default values
  2650. @opindex show-defaults
  2651. @GNUTAR{} has some predefined defaults that are used when you do not
  2652. explicitely specify another values. To obtain a list of such
  2653. defaults, use @option{--show-defaults} option. This will output the
  2654. values in the form of @command{tar} command line options:
  2655. @smallexample
  2656. @group
  2657. @kbd{tar --show-defaults}
  2658. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2659. @end group
  2660. @end smallexample
  2661. @noindent
  2662. The above output shows that this version of @GNUTAR{} defaults to
  2663. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2664. output as the archive, if no @option{--file} option has been given
  2665. (@pxref{file tutorial}), the default blocking factor is 20
  2666. (@pxref{Blocking Factor}). It also shows the default locations where
  2667. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2668. @node verbose
  2669. @section Checking @command{tar} progress
  2670. Typically, @command{tar} performs most operations without reporting any
  2671. information to the user except error messages. When using @command{tar}
  2672. with many options, particularly ones with complicated or
  2673. difficult-to-predict behavior, it is possible to make serious mistakes.
  2674. @command{tar} provides several options that make observing @command{tar}
  2675. easier. These options cause @command{tar} to print information as it
  2676. progresses in its job, and you might want to use them just for being
  2677. more careful about what is going on, or merely for entertaining
  2678. yourself. If you have encountered a problem when operating on an
  2679. archive, however, you may need more information than just an error
  2680. message in order to solve the problem. The following options can be
  2681. helpful diagnostic tools.
  2682. @cindex Verbose operation
  2683. @opindex verbose
  2684. Normally, the @option{--list} (@option{-t}) command to list an archive
  2685. prints just the file names (one per line) and the other commands are
  2686. silent. When used with most operations, the @option{--verbose}
  2687. (@option{-v}) option causes @command{tar} to print the name of each
  2688. file or archive member as it is processed. This and the other options
  2689. which make @command{tar} print status information can be useful in
  2690. monitoring @command{tar}.
  2691. With @option{--create} or @option{--extract}, @option{--verbose} used
  2692. once just prints the names of the files or members as they are processed.
  2693. Using it twice causes @command{tar} to print a longer listing
  2694. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2695. already prints the names of the members, @option{--verbose} used once
  2696. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2697. type listing of the files in the archive. The following examples both
  2698. extract members with long list output:
  2699. @smallexample
  2700. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2701. $ @kbd{tar xvvf archive.tar}
  2702. @end smallexample
  2703. Verbose output appears on the standard output except when an archive is
  2704. being written to the standard output, as with @samp{tar --create
  2705. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2706. installer let standard output be the default archive). In that case
  2707. @command{tar} writes verbose output to the standard error stream.
  2708. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2709. verbose output to @var{file} rather than to standard output or standard
  2710. error.
  2711. @cindex Obtaining total status information
  2712. @opindex totals
  2713. The @option{--totals} option---which is only meaningful when used with
  2714. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2715. amount written to the archive, after it has been fully created.
  2716. @cindex Progress information
  2717. @opindex checkpoint
  2718. The @option{--checkpoint} option prints an occasional message
  2719. as @command{tar} reads or writes the archive. In fact, it prints
  2720. a message each 10 records read or written. It is designed for
  2721. those who don't need the more detailed (and voluminous) output of
  2722. @option{--block-number} (@option{-R}), but do want visual confirmation
  2723. that @command{tar} is actually making forward progress.
  2724. @FIXME{There is some confusion here. It seems that -R once wrote a
  2725. message at @samp{every} record read or written.}
  2726. @opindex show-omitted-dirs
  2727. @anchor{show-omitted-dirs}
  2728. The @option{--show-omitted-dirs} option, when reading an archive---with
  2729. @option{--list} or @option{--extract}, for example---causes a message
  2730. to be printed for each directory in the archive which is skipped.
  2731. This happens regardless of the reason for skipping: the directory might
  2732. not have been named on the command line (implicitly or explicitly),
  2733. it might be excluded by the use of the @option{--exclude=@var{pattern}} option, or
  2734. some other reason.
  2735. @opindex block-number
  2736. @cindex Block number where error occurred
  2737. @anchor{block-number}
  2738. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2739. every message it would normally produce, the block number within the
  2740. archive where the message was triggered. Also, supplementary messages
  2741. are triggered when reading blocks full of NULs, or when hitting end of
  2742. file on the archive. As of now, if the archive if properly terminated
  2743. with a NUL block, the reading of the file may stop before end of file
  2744. is met, so the position of end of file will not usually show when
  2745. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2746. drains the archive before exiting when reading the
  2747. archive from a pipe.
  2748. @cindex Error message, block number of
  2749. This option is especially useful when reading damaged archives, since
  2750. it helps pinpoint the damaged sections. It can also be used with
  2751. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2752. choose among several backup tapes when retrieving a file later, in
  2753. favor of the tape where the file appears earliest (closest to the
  2754. front of the tape). @xref{backup}.
  2755. @node interactive
  2756. @section Asking for Confirmation During Operations
  2757. @cindex Interactive operation
  2758. Typically, @command{tar} carries out a command without stopping for
  2759. further instructions. In some situations however, you may want to
  2760. exclude some files and archive members from the operation (for instance
  2761. if disk or storage space is tight). You can do this by excluding
  2762. certain files automatically (@pxref{Choosing}), or by performing
  2763. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2764. @command{tar} also accepts @option{--confirmation} for this option.
  2765. @opindex interactive
  2766. When the @option{--interactive} (@option{-w}) option is specified, before
  2767. reading, writing, or deleting files, @command{tar} first prints a message
  2768. for each such file, telling what operation it intends to take, then asks
  2769. for confirmation on the terminal. The actions which require
  2770. confirmation include adding a file to the archive, extracting a file
  2771. from the archive, deleting a file from the archive, and deleting a file
  2772. from disk. To confirm the action, you must type a line of input
  2773. beginning with @samp{y}. If your input line begins with anything other
  2774. than @samp{y}, @command{tar} skips that file.
  2775. If @command{tar} is reading the archive from the standard input,
  2776. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2777. communications.
  2778. Verbose output is normally sent to standard output, separate from
  2779. other error messages. However, if the archive is produced directly
  2780. on standard output, then verbose output is mixed with errors on
  2781. @code{stderr}. Producing the archive on standard output may be used
  2782. as a way to avoid using disk space, when the archive is soon to be
  2783. consumed by another process reading it, say. Some people felt the need
  2784. of producing an archive on stdout, still willing to segregate between
  2785. verbose output and error output. A possible approach would be using a
  2786. named pipe to receive the archive, and having the consumer process to
  2787. read from that named pipe. This has the advantage of letting standard
  2788. output free to receive verbose output, all separate from errors.
  2789. @node operations
  2790. @chapter @GNUTAR{} Operations
  2791. @menu
  2792. * Basic tar::
  2793. * Advanced tar::
  2794. * create options::
  2795. * extract options::
  2796. * backup::
  2797. * Applications::
  2798. * looking ahead::
  2799. @end menu
  2800. @node Basic tar
  2801. @section Basic @GNUTAR{} Operations
  2802. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2803. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2804. @option{-x}), are currently presented and described in the tutorial
  2805. chapter of this manual. This section provides some complementary notes
  2806. for these operations.
  2807. @table @option
  2808. @opindex create, complementary notes
  2809. @item --create
  2810. @itemx -c
  2811. Creating an empty archive would have some kind of elegance. One can
  2812. initialize an empty archive and later use @option{--append}
  2813. (@option{-r}) for adding all members. Some applications would not
  2814. welcome making an exception in the way of adding the first archive
  2815. member. On the other hand, many people reported that it is
  2816. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2817. an empty archive@footnote{This is well described in @cite{Unix-haters
  2818. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2819. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2820. @enumerate
  2821. @item
  2822. Mistakingly using @code{create} instead of @code{extract}, when the
  2823. intent was to extract the full contents of an archive. This error
  2824. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2825. the QWERTY keyboard. Instead of being unpacked, the archive then
  2826. gets wholly destroyed. When users speak about @dfn{exploding} an
  2827. archive, they usually mean something else :-).
  2828. @item
  2829. Forgetting the argument to @code{file}, when the intent was to create
  2830. an archive with a single file in it. This error is likely because a
  2831. tired user can easily add the @kbd{f} key to the cluster of option
  2832. letters, by the mere force of habit, without realizing the full
  2833. consequence of doing so. The usual consequence is that the single
  2834. file, which was meant to be saved, is rather destroyed.
  2835. @end enumerate
  2836. So, recognizing the likelihood and the catastrophical nature of these
  2837. errors, @GNUTAR{} now takes some distance from elegance, and
  2838. cowardly refuses to create an archive when @option{--create} option is
  2839. given, there are no arguments besides options, and
  2840. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2841. around the cautiousness of @GNUTAR{} and nevertheless create an
  2842. archive with nothing in it, one may still use, as the value for the
  2843. @option{--files-from} option, a file with no names in it, as shown in
  2844. the following commands:
  2845. @smallexample
  2846. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2847. @kbd{tar cfT empty-archive.tar /dev/null}
  2848. @end smallexample
  2849. @opindex extract, complementary notes
  2850. @item --extract
  2851. @itemx --get
  2852. @itemx -x
  2853. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2854. @item @option{--list} (@option{-t})
  2855. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2856. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2857. people should get used to ISO 8601 dates. Local American dates should
  2858. be made available again with full date localization support, once
  2859. ready. In the meantime, programs not being localizable for dates
  2860. should prefer international dates, that's really the way to go.
  2861. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2862. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2863. @end table
  2864. @node Advanced tar
  2865. @section Advanced @GNUTAR{} Operations
  2866. Now that you have learned the basics of using @GNUTAR{}, you may want
  2867. to learn about further ways in which @command{tar} can help you.
  2868. This chapter presents five, more advanced operations which you probably
  2869. won't use on a daily basis, but which serve more specialized functions.
  2870. We also explain the different styles of options and why you might want
  2871. to use one or another, or a combination of them in your @command{tar}
  2872. commands. Additionally, this chapter includes options which allow you to
  2873. define the output from @command{tar} more carefully, and provide help and
  2874. error correction in special circumstances.
  2875. @FIXME{check this after the chapter is actually revised to make sure
  2876. it still introduces the info in the chapter correctly : ).}
  2877. @menu
  2878. * Operations::
  2879. * append::
  2880. * update::
  2881. * concatenate::
  2882. * delete::
  2883. * compare::
  2884. * quoting styles::
  2885. @end menu
  2886. @node Operations
  2887. @subsection The Five Advanced @command{tar} Operations
  2888. @UNREVISED
  2889. In the last chapter, you learned about the first three operations to
  2890. @command{tar}. This chapter presents the remaining five operations to
  2891. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2892. @option{--delete}, and @option{--compare}.
  2893. You are not likely to use these operations as frequently as those
  2894. covered in the last chapter; however, since they perform specialized
  2895. functions, they are quite useful when you do need to use them. We
  2896. will give examples using the same directory and files that you created
  2897. in the last chapter. As you may recall, the directory is called
  2898. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2899. @samp{rock}, and the two archive files you created are
  2900. @samp{collection.tar} and @samp{music.tar}.
  2901. We will also use the archive files @samp{afiles.tar} and
  2902. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2903. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2904. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2905. Unless we state otherwise, all practicing you do and examples you follow
  2906. in this chapter will take place in the @file{practice} directory that
  2907. you created in the previous chapter; see @ref{prepare for examples}.
  2908. (Below in this section, we will remind you of the state of the examples
  2909. where the last chapter left them.)
  2910. The five operations that we will cover in this chapter are:
  2911. @table @option
  2912. @item --append
  2913. @itemx -r
  2914. Add new entries to an archive that already exists.
  2915. @item --update
  2916. @itemx -r
  2917. Add more recent copies of archive members to the end of an archive, if
  2918. they exist.
  2919. @item --concatenate
  2920. @itemx --catenate
  2921. @itemx -A
  2922. Add one or more pre-existing archives to the end of another archive.
  2923. @item --delete
  2924. Delete items from an archive (does not work on tapes).
  2925. @item --compare
  2926. @itemx --diff
  2927. @itemx -d
  2928. Compare archive members to their counterparts in the file system.
  2929. @end table
  2930. @node append
  2931. @subsection How to Add Files to Existing Archives: @option{--append}
  2932. @UNREVISED
  2933. @opindex append
  2934. If you want to add files to an existing archive, you don't need to
  2935. create a new archive; you can use @option{--append} (@option{-r}).
  2936. The archive must already exist in order to use @option{--append}. (A
  2937. related operation is the @option{--update} operation; you can use this
  2938. to add newer versions of archive members to an existing archive. To learn how to
  2939. do this with @option{--update}, @pxref{update}.)
  2940. If you use @option{--append} to add a file that has the same name as an
  2941. archive member to an archive containing that archive member, then the
  2942. old member is not deleted. What does happen, however, is somewhat
  2943. complex. @command{tar} @emph{allows} you to have infinite number of files
  2944. with the same name. Some operations treat these same-named members no
  2945. differently than any other set of archive members: for example, if you
  2946. view an archive with @option{--list} (@option{-t}), you will see all
  2947. of those members listed, with their data modification times, owners, etc.
  2948. Other operations don't deal with these members as perfectly as you might
  2949. prefer; if you were to use @option{--extract} to extract the archive,
  2950. only the most recently added copy of a member with the same name as four
  2951. other members would end up in the working directory. This is because
  2952. @option{--extract} extracts an archive in the order the members appeared
  2953. in the archive; the most recently archived members will be extracted
  2954. last. Additionally, an extracted member will @emph{replace} a file of
  2955. the same name which existed in the directory already, and @command{tar}
  2956. will not prompt you about this@footnote{Unless you give it
  2957. @option{--keep-old-files} option, or the disk copy is newer than the
  2958. the one in the archive and you invoke @command{tar} with
  2959. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2960. member will end up being extracted, as it will replace the one
  2961. extracted before it, and so on.
  2962. There exists a special option that allows you to get around this
  2963. behavior and extract (or list) only a particular copy of the file.
  2964. This is @option{--occurrence} option. If you run @command{tar} with
  2965. this option, it will extract only the first copy of the file. You
  2966. may also give this option an argument specifying the number of
  2967. copy to be extracted. Thus, for example if the archive
  2968. @file{archive.tar} contained three copies of file @file{myfile}, then
  2969. the command
  2970. @smallexample
  2971. tar --extract --file archive.tar --occurrence=2 myfile
  2972. @end smallexample
  2973. @noindent
  2974. would extract only the second copy. @xref{Option
  2975. Summary,---occurrence}, for the description of @option{--occurrence}
  2976. option.
  2977. @FIXME{ hag -- you might want to incorporate some of the above into the
  2978. MMwtSN node; not sure. i didn't know how to make it simpler...
  2979. There are a few ways to get around this. (maybe xref Multiple Members
  2980. with the Same Name.}
  2981. @cindex Members, replacing with other members
  2982. @cindex Replacing members with other members
  2983. If you want to replace an archive member, use @option{--delete} to
  2984. delete the member you want to remove from the archive, , and then use
  2985. @option{--append} to add the member you want to be in the archive. Note
  2986. that you can not change the order of the archive; the most recently
  2987. added member will still appear last. In this sense, you cannot truly
  2988. ``replace'' one member with another. (Replacing one member with another
  2989. will not work on certain types of media, such as tapes; see @ref{delete}
  2990. and @ref{Media}, for more information.)
  2991. @menu
  2992. * appending files:: Appending Files to an Archive
  2993. * multiple::
  2994. @end menu
  2995. @node appending files
  2996. @subsubsection Appending Files to an Archive
  2997. @UNREVISED
  2998. @cindex Adding files to an Archive
  2999. @cindex Appending files to an Archive
  3000. @cindex Archives, Appending files to
  3001. The simplest way to add a file to an already existing archive is the
  3002. @option{--append} (@option{-r}) operation, which writes specified
  3003. files into the archive whether or not they are already among the
  3004. archived files.
  3005. When you use @option{--append}, you @emph{must} specify file name
  3006. arguments, as there is no default. If you specify a file that already
  3007. exists in the archive, another copy of the file will be added to the
  3008. end of the archive. As with other operations, the member names of the
  3009. newly added files will be exactly the same as their names given on the
  3010. command line. The @option{--verbose} (@option{-v}) option will print
  3011. out the names of the files as they are written into the archive.
  3012. @option{--append} cannot be performed on some tape drives, unfortunately,
  3013. due to deficiencies in the formats those tape drives use. The archive
  3014. must be a valid @command{tar} archive, or else the results of using this
  3015. operation will be unpredictable. @xref{Media}.
  3016. To demonstrate using @option{--append} to add a file to an archive,
  3017. create a file called @file{rock} in the @file{practice} directory.
  3018. Make sure you are in the @file{practice} directory. Then, run the
  3019. following @command{tar} command to add @file{rock} to
  3020. @file{collection.tar}:
  3021. @smallexample
  3022. $ @kbd{tar --append --file=collection.tar rock}
  3023. @end smallexample
  3024. @noindent
  3025. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3026. @file{rock} has been added to the archive:
  3027. @smallexample
  3028. $ @kbd{tar --list --file=collection.tar}
  3029. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3030. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3031. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3032. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3033. @end smallexample
  3034. @node multiple
  3035. @subsubsection Multiple Files with the Same Name
  3036. You can use @option{--append} (@option{-r}) to add copies of files
  3037. which have been updated since the archive was created. (However, we
  3038. do not recommend doing this since there is another @command{tar}
  3039. option called @option{--update}; @xref{update}, for more information.
  3040. We describe this use of @option{--append} here for the sake of
  3041. completeness.) When you extract the archive, the older version will
  3042. be effectively lost. This works because files are extracted from an
  3043. archive in the order in which they were archived. Thus, when the
  3044. archive is extracted, a file archived later in time will replace a
  3045. file of the same name which was archived earlier, even though the
  3046. older version of the file will remain in the archive unless you delete
  3047. all versions of the file.
  3048. Supposing you change the file @file{blues} and then append the changed
  3049. version to @file{collection.tar}. As you saw above, the original
  3050. @file{blues} is in the archive @file{collection.tar}. If you change the
  3051. file and append the new version of the file to the archive, there will
  3052. be two copies in the archive. When you extract the archive, the older
  3053. version of the file will be extracted first, and then replaced by the
  3054. newer version when it is extracted.
  3055. You can append the new, changed copy of the file @file{blues} to the
  3056. archive in this way:
  3057. @smallexample
  3058. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3059. blues
  3060. @end smallexample
  3061. @noindent
  3062. Because you specified the @option{--verbose} option, @command{tar} has
  3063. printed the name of the file being appended as it was acted on. Now
  3064. list the contents of the archive:
  3065. @smallexample
  3066. $ @kbd{tar --list --verbose --file=collection.tar}
  3067. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3068. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3069. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3070. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3071. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3072. @end smallexample
  3073. @noindent
  3074. The newest version of @file{blues} is now at the end of the archive
  3075. (note the different creation dates and file sizes). If you extract
  3076. the archive, the older version of the file @file{blues} will be
  3077. replaced by the newer version. You can confirm this by extracting
  3078. the archive and running @samp{ls} on the directory.
  3079. If you wish to extract the first occurrence of the file @file{blues}
  3080. from the archive, use @option{--occurrence} option, as shown in
  3081. the following example:
  3082. @smallexample
  3083. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3084. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3085. @end smallexample
  3086. @xref{Writing}, for more information on @option{--extract} and
  3087. @xref{Option Summary, --occurrence}, for the description of
  3088. @option{--occurrence} option.
  3089. @node update
  3090. @subsection Updating an Archive
  3091. @UNREVISED
  3092. @cindex Updating an archive
  3093. @opindex update
  3094. In the previous section, you learned how to use @option{--append} to
  3095. add a file to an existing archive. A related operation is
  3096. @option{--update} (@option{-u}). The @option{--update} operation
  3097. updates a @command{tar} archive by comparing the date of the specified
  3098. archive members against the date of the file with the same name. If
  3099. the file has been modified more recently than the archive member, then
  3100. the newer version of the file is added to the archive (as with
  3101. @option{--append}).
  3102. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3103. The operation will fail.
  3104. @FIXME{other examples of media on which --update will fail? need to ask
  3105. charles and/or mib/thomas/dave shevett..}
  3106. Both @option{--update} and @option{--append} work by adding to the end
  3107. of the archive. When you extract a file from the archive, only the
  3108. version stored last will wind up in the file system, unless you use
  3109. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3110. Same Name}
  3111. @menu
  3112. * how to update::
  3113. @end menu
  3114. @node how to update
  3115. @subsubsection How to Update an Archive Using @option{--update}
  3116. You must use file name arguments with the @option{--update}
  3117. (@option{-u}) operation. If you don't specify any files,
  3118. @command{tar} won't act on any files and won't tell you that it didn't
  3119. do anything (which may end up confusing you).
  3120. @c note: the above parenthetical added because in fact, this
  3121. @c behavior just confused the author. :-)
  3122. To see the @option{--update} option at work, create a new file,
  3123. @file{classical}, in your practice directory, and some extra text to the
  3124. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3125. the @samp{update} operation and the @option{--verbose} (@option{-v})
  3126. option specified, using the names of all the files in the practice
  3127. directory as file name arguments:
  3128. @smallexample
  3129. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3130. blues
  3131. classical
  3132. $
  3133. @end smallexample
  3134. @noindent
  3135. Because we have specified verbose mode, @command{tar} prints out the names
  3136. of the files it is working on, which in this case are the names of the
  3137. files that needed to be updated. If you run @samp{tar --list} and look
  3138. at the archive, you will see @file{blues} and @file{classical} at its
  3139. end. There will be a total of two versions of the member @samp{blues};
  3140. the one at the end will be newer and larger, since you added text before
  3141. updating it.
  3142. (The reason @command{tar} does not overwrite the older file when updating
  3143. it is because writing to the middle of a section of tape is a difficult
  3144. process. Tapes are not designed to go backward. @xref{Media}, for more
  3145. information about tapes.
  3146. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3147. reasons: it does not change directory content entries, and it
  3148. lengthens the archive every time it is used. The @GNUTAR{}
  3149. options intended specifically for backups are more
  3150. efficient. If you need to run backups, please consult @ref{Backups}.
  3151. @node concatenate
  3152. @subsection Combining Archives with @option{--concatenate}
  3153. @cindex Adding archives to an archive
  3154. @cindex Concatenating Archives
  3155. @opindex concatenate
  3156. @opindex catenate
  3157. @c @cindex @option{-A} described
  3158. Sometimes it may be convenient to add a second archive onto the end of
  3159. an archive rather than adding individual files to the archive. To add
  3160. one or more archives to the end of another archive, you should use the
  3161. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3162. To use @option{--concatenate}, give the first archive with
  3163. @option{--file} option and name the rest of archives to be
  3164. concatenated on the command line. The members, and their member
  3165. names, will be copied verbatim from those archives to the first one.
  3166. @FIXME-ref{This can cause multiple members to have the same name, for
  3167. information on how this affects reading the archive, Multiple
  3168. Members with the Same Name.}
  3169. The new, concatenated archive will be called by the same name as the
  3170. one given with the @option{--file} option. As usual, if you omit
  3171. @option{--file}, @command{tar} will use the value of the environment
  3172. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3173. @FIXME{There is no way to specify a new name...}
  3174. To demonstrate how @option{--concatenate} works, create two small archives
  3175. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3176. files from @file{practice}:
  3177. @smallexample
  3178. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3179. blues
  3180. rock
  3181. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3182. folk
  3183. jazz
  3184. @end smallexample
  3185. @noindent
  3186. If you like, You can run @samp{tar --list} to make sure the archives
  3187. contain what they are supposed to:
  3188. @smallexample
  3189. $ @kbd{tar -tvf bluesrock.tar}
  3190. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3191. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3192. $ @kbd{tar -tvf jazzfolk.tar}
  3193. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3194. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3195. @end smallexample
  3196. We can concatenate these two archives with @command{tar}:
  3197. @smallexample
  3198. $ @kbd{cd ..}
  3199. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3200. @end smallexample
  3201. If you now list the contents of the @file{bluesrock.tar}, you will see
  3202. that now it also contains the archive members of @file{jazzfolk.tar}:
  3203. @smallexample
  3204. $ @kbd{tar --list --file=bluesrock.tar}
  3205. blues
  3206. rock
  3207. folk
  3208. jazz
  3209. @end smallexample
  3210. When you use @option{--concatenate}, the source and target archives must
  3211. already exist and must have been created using compatible format
  3212. parameters. Notice, that @command{tar} does not check whether the
  3213. archives it concatenates have compatible formats, it does not
  3214. even check if the files are really tar archives.
  3215. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3216. tape drives, due to deficiencies in the formats those tape drives use.
  3217. @cindex @code{concatenate} vs @command{cat}
  3218. @cindex @command{cat} vs @code{concatenate}
  3219. It may seem more intuitive to you to want or try to use @command{cat} to
  3220. concatenate two archives instead of using the @option{--concatenate}
  3221. operation; after all, @command{cat} is the utility for combining files.
  3222. However, @command{tar} archives incorporate an end-of-file marker which
  3223. must be removed if the concatenated archives are to be read properly as
  3224. one archive. @option{--concatenate} removes the end-of-archive marker
  3225. from the target archive before each new archive is appended. If you use
  3226. @command{cat} to combine the archives, the result will not be a valid
  3227. @command{tar} format archive. If you need to retrieve files from an
  3228. archive that was added to using the @command{cat} utility, use the
  3229. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3230. information on dealing with archives improperly combined using the
  3231. @command{cat} shell utility.
  3232. @node delete
  3233. @subsection Removing Archive Members Using @option{--delete}
  3234. @UNREVISED
  3235. @cindex Deleting files from an archive
  3236. @cindex Removing files from an archive
  3237. @opindex delete
  3238. You can remove members from an archive by using the @option{--delete}
  3239. option. Specify the name of the archive with @option{--file}
  3240. (@option{-f}) and then specify the names of the members to be deleted;
  3241. if you list no member names, nothing will be deleted. The
  3242. @option{--verbose} option will cause @command{tar} to print the names
  3243. of the members as they are deleted. As with @option{--extract}, you
  3244. must give the exact member names when using @samp{tar --delete}.
  3245. @option{--delete} will remove all versions of the named file from the
  3246. archive. The @option{--delete} operation can run very slowly.
  3247. Unlike other operations, @option{--delete} has no short form.
  3248. @cindex Tapes, using @option{--delete} and
  3249. @cindex Deleting from tape archives
  3250. This operation will rewrite the archive. You can only use
  3251. @option{--delete} on an archive if the archive device allows you to
  3252. write to any point on the media, such as a disk; because of this, it
  3253. does not work on magnetic tapes. Do not try to delete an archive member
  3254. from a magnetic tape; the action will not succeed, and you will be
  3255. likely to scramble the archive and damage your tape. There is no safe
  3256. way (except by completely re-writing the archive) to delete files from
  3257. most kinds of magnetic tape. @xref{Media}.
  3258. To delete all versions of the file @file{blues} from the archive
  3259. @file{collection.tar} in the @file{practice} directory, make sure you
  3260. are in that directory, and then,
  3261. @smallexample
  3262. $ @kbd{tar --list --file=collection.tar}
  3263. blues
  3264. folk
  3265. jazz
  3266. rock
  3267. $ @kbd{tar --delete --file=collection.tar blues}
  3268. $ @kbd{tar --list --file=collection.tar}
  3269. folk
  3270. jazz
  3271. rock
  3272. $
  3273. @end smallexample
  3274. @FIXME{Check if the above listing is actually produced after running
  3275. all the examples on collection.tar.}
  3276. The @option{--delete} option has been reported to work properly when
  3277. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3278. @node compare
  3279. @subsection Comparing Archive Members with the File System
  3280. @cindex Verifying the currency of an archive
  3281. @UNREVISED
  3282. @opindex compare
  3283. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3284. specified archive members against files with the same names, and then
  3285. reports differences in file size, mode, owner, modification date and
  3286. contents. You should @emph{only} specify archive member names, not file
  3287. names. If you do not name any members, then @command{tar} will compare the
  3288. entire archive. If a file is represented in the archive but does not
  3289. exist in the file system, @command{tar} reports a difference.
  3290. You have to specify the record size of the archive when modifying an
  3291. archive with a non-default record size.
  3292. @command{tar} ignores files in the file system that do not have
  3293. corresponding members in the archive.
  3294. The following example compares the archive members @file{rock},
  3295. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3296. files of the same name in the file system. (Note that there is no file,
  3297. @file{funk}; @command{tar} will report an error message.)
  3298. @smallexample
  3299. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3300. rock
  3301. blues
  3302. tar: funk not found in archive
  3303. @end smallexample
  3304. The spirit behind the @option{--compare} (@option{--diff}, @option{-d}) option is to check whether the
  3305. archive represents the current state of files on disk, more than validating
  3306. the integrity of the archive media. For this later goal, @xref{verify}.
  3307. @node quoting styles
  3308. @subsection Quoting Member Names
  3309. @UNREVISED{}
  3310. @smallexample
  3311. @group
  3312. $ @kbd{ls}
  3313. a\ttab
  3314. a\nnewline
  3315. a\ space
  3316. a"double"quote
  3317. a'single'quote
  3318. a\\backslash
  3319. $ @kbd{tar cf arch .}
  3320. @end group
  3321. @end smallexample
  3322. @smallexample
  3323. @group
  3324. $ @kbd{tar tf arch --quoting-style=literal}
  3325. ./
  3326. ./a space
  3327. ./a'single'quote
  3328. ./a"double"quote
  3329. ./a\backslash
  3330. ./a tab
  3331. ./a
  3332. newline
  3333. @end group
  3334. @end smallexample
  3335. @smallexample
  3336. @group
  3337. $ @kbd{tar tf arch --quoting-style=shell}
  3338. ./
  3339. './a space'
  3340. './a'\''single'\''quote'
  3341. './a"double"quote'
  3342. './a\backslash'
  3343. './a tab'
  3344. './a
  3345. newline'
  3346. @end group
  3347. @end smallexample
  3348. @smallexample
  3349. @group
  3350. $ @kbd{tar tf arch --quoting-style=shell-always}
  3351. './'
  3352. './a space'
  3353. './a'\''single'\''quote'
  3354. './a"double"quote'
  3355. './a\backslash'
  3356. './a tab'
  3357. './a
  3358. newline'
  3359. @end group
  3360. @end smallexample
  3361. @smallexample
  3362. @group
  3363. $ @kbd{tar tf arch --quoting-style=c}
  3364. "./"
  3365. "./a space"
  3366. "./a'single'quote"
  3367. "./a\"double\"quote"
  3368. "./a\\backslash"
  3369. "./a\ttab"
  3370. "./a\nnewline"
  3371. @end group
  3372. @end smallexample
  3373. @smallexample
  3374. @group
  3375. $ @kbd{tar tf arch --quoting-style=escape}
  3376. ./
  3377. ./a space
  3378. ./a'single'quote
  3379. ./a"double"quote
  3380. ./a\\backslash
  3381. ./a\ttab
  3382. ./a\nnewline
  3383. @end group
  3384. @end smallexample
  3385. @smallexample
  3386. @group
  3387. $ @kbd{tar tf arch --quoting-style=locale}
  3388. `./'
  3389. `./a space'
  3390. `./a\'single\'quote'
  3391. `./a"double"quote'
  3392. `./a\\backslash'
  3393. `./a\ttab'
  3394. `./a\nnewline'
  3395. @end group
  3396. @end smallexample
  3397. @smallexample
  3398. @group
  3399. $ @kbd{tar tf arch --quoting-style=clocale}
  3400. "./"
  3401. "./a space"
  3402. "./a'single'quote"
  3403. "./a\"double\"quote"
  3404. "./a\\backslash"
  3405. "./a\ttab"
  3406. "./a\nnewline"
  3407. @end group
  3408. @end smallexample
  3409. @node create options
  3410. @section Options Used by @option{--create}
  3411. @opindex create, additional options
  3412. The previous chapter described the basics of how to use
  3413. @option{--create} (@option{-c}) to create an archive from a set of files.
  3414. @xref{create}. This section described advanced options to be used with
  3415. @option{--create}.
  3416. @menu
  3417. * Ignore Failed Read::
  3418. @end menu
  3419. @node Ignore Failed Read
  3420. @subsection Ignore Fail Read
  3421. @table @option
  3422. @item --ignore-failed-read
  3423. Do not exit with nonzero on unreadable files or directories.
  3424. @end table
  3425. @node extract options
  3426. @section Options Used by @option{--extract}
  3427. @UNREVISED
  3428. @opindex extract, additional options
  3429. The previous chapter showed how to use @option{--extract} to extract
  3430. an archive into the file system. Various options cause @command{tar} to
  3431. extract more information than just file contents, such as the owner,
  3432. the permissions, the modification date, and so forth. This section
  3433. presents options to be used with @option{--extract} when certain special
  3434. considerations arise. You may review the information presented in
  3435. @ref{extract} for more basic information about the
  3436. @option{--extract} operation.
  3437. @menu
  3438. * Reading:: Options to Help Read Archives
  3439. * Writing:: Changing How @command{tar} Writes Files
  3440. * Scarce:: Coping with Scarce Resources
  3441. @end menu
  3442. @node Reading
  3443. @subsection Options to Help Read Archives
  3444. @cindex Options when reading archives
  3445. @UNREVISED
  3446. @cindex Reading incomplete records
  3447. @cindex Records, incomplete
  3448. @opindex read-full-records
  3449. Normally, @command{tar} will request data in full record increments from
  3450. an archive storage device. If the device cannot return a full record,
  3451. @command{tar} will report an error. However, some devices do not always
  3452. return full records, or do not require the last record of an archive to
  3453. be padded out to the next record boundary. To keep reading until you
  3454. obtain a full record, or to accept an incomplete record if it contains
  3455. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3456. in conjunction with the @option{--extract} or @option{--list} operations.
  3457. @xref{Blocking}.
  3458. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3459. @command{tar} reads an archive from standard input, or from a remote
  3460. machine. This is because on BSD Unix systems, attempting to read a
  3461. pipe returns however much happens to be in the pipe, even if it is
  3462. less than was requested. If this option were not enabled, @command{tar}
  3463. would fail as soon as it read an incomplete record from the pipe.
  3464. If you're not sure of the blocking factor of an archive, you can
  3465. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3466. @option{--blocking-factor=@var{512-size}} (@option{-b
  3467. @var{512-size}}), using a blocking factor larger than what the archive
  3468. uses. This lets you avoid having to determine the blocking factor
  3469. of an archive. @xref{Blocking Factor}.
  3470. @menu
  3471. * read full records::
  3472. * Ignore Zeros::
  3473. @end menu
  3474. @node read full records
  3475. @unnumberedsubsubsec Reading Full Records
  3476. @FIXME{need sentence or so of intro here}
  3477. @table @option
  3478. @opindex read-full-records
  3479. @item --read-full-records
  3480. @item -B
  3481. Use in conjunction with @option{--extract} (@option{--get},
  3482. @option{-x}) to read an archive which contains incomplete records, or
  3483. one which has a blocking factor less than the one specified.
  3484. @end table
  3485. @node Ignore Zeros
  3486. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3487. @cindex End-of-archive blocks, ignoring
  3488. @cindex Ignoring end-of-archive blocks
  3489. @opindex ignore-zeros
  3490. Normally, @command{tar} stops reading when it encounters a block of zeros
  3491. between file entries (which usually indicates the end of the archive).
  3492. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3493. completely read an archive which contains a block of zeros before the
  3494. end (i.e., a damaged archive, or one that was created by concatenating
  3495. several archives together).
  3496. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3497. versions of @command{tar} write garbage after the end-of-archive entry,
  3498. since that part of the media is never supposed to be read. @GNUTAR{}
  3499. does not write after the end of an archive, but seeks to
  3500. maintain compatiblity among archiving utilities.
  3501. @table @option
  3502. @item --ignore-zeros
  3503. @itemx -i
  3504. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3505. encountered while reading an archive. Use in conjunction with
  3506. @option{--extract} or @option{--list}.
  3507. @end table
  3508. @node Writing
  3509. @subsection Changing How @command{tar} Writes Files
  3510. @UNREVISED
  3511. @FIXME{Introductory paragraph}
  3512. @menu
  3513. * Dealing with Old Files::
  3514. * Overwrite Old Files::
  3515. * Keep Old Files::
  3516. * Keep Newer Files::
  3517. * Unlink First::
  3518. * Recursive Unlink::
  3519. * Data Modification Times::
  3520. * Setting Access Permissions::
  3521. * Directory Modification Times and Permissions::
  3522. * Writing to Standard Output::
  3523. * Writing to an External Program::
  3524. * remove files::
  3525. @end menu
  3526. @node Dealing with Old Files
  3527. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3528. @opindex overwrite-dir, introduced
  3529. When extracting files, if @command{tar} discovers that the extracted
  3530. file already exists, it normally replaces the file by removing it before
  3531. extracting it, to prevent confusion in the presence of hard or symbolic
  3532. links. (If the existing file is a symbolic link, it is removed, not
  3533. followed.) However, if a directory cannot be removed because it is
  3534. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3535. permission, etc.). The @option{--overwrite-dir} option enables this
  3536. default behavior. To be more cautious and preserve the metadata of
  3537. such a directory, use the @option{--no-overwrite-dir} option.
  3538. @cindex Overwriting old files, prevention
  3539. @opindex keep-old-files, introduced
  3540. To be even more cautious and prevent existing files from being replaced, use
  3541. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3542. to replace or update a file that already exists, i.e., a file with the
  3543. same name as an archive member prevents extraction of that archive
  3544. member. Instead, it reports an error.
  3545. @opindex overwrite, introduced
  3546. To be more aggressive about altering existing files, use the
  3547. @option{--overwrite} option. It causes @command{tar} to overwrite
  3548. existing files and to follow existing symbolic links when extracting.
  3549. @cindex Protecting old files
  3550. Some people argue that @GNUTAR{} should not hesitate
  3551. to overwrite files with other files when extracting. When extracting
  3552. a @command{tar} archive, they expect to see a faithful copy of the
  3553. state of the file system when the archive was created. It is debatable
  3554. that this would always be a proper behavior. For example, suppose one
  3555. has an archive in which @file{usr/local} is a link to
  3556. @file{usr/local2}. Since then, maybe the site removed the link and
  3557. renamed the whole hierarchy from @file{/usr/local2} to
  3558. @file{/usr/local}. Such things happen all the time. I guess it would
  3559. not be welcome at all that @GNUTAR{} removes the
  3560. whole hierarchy just to make room for the link to be reinstated
  3561. (unless it @emph{also} simultaneously restores the full
  3562. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3563. able to remove a whole hierarchy to reestablish a symbolic link, for
  3564. example, but @emph{only if} @option{--recursive-unlink} is specified
  3565. to allow this behavior. In any case, single files are silently
  3566. removed.
  3567. @opindex unlink-first, introduced
  3568. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3569. some cases by causing @command{tar} to remove files unconditionally
  3570. before extracting them.
  3571. @node Overwrite Old Files
  3572. @unnumberedsubsubsec Overwrite Old Files
  3573. @table @option
  3574. @opindex overwrite
  3575. @item --overwrite
  3576. Overwrite existing files and directory metadata when extracting files
  3577. from an archive.
  3578. This causes @command{tar} to write extracted files into the file system without
  3579. regard to the files already on the system; i.e., files with the same
  3580. names as archive members are overwritten when the archive is extracted.
  3581. It also causes @command{tar} to extract the ownership, permissions,
  3582. and time stamps onto any preexisting files or directories.
  3583. If the name of a corresponding file name is a symbolic link, the file
  3584. pointed to by the symbolic link will be overwritten instead of the
  3585. symbolic link itself (if this is possible). Moreover, special devices,
  3586. empty directories and even symbolic links are automatically removed if
  3587. they are in the way of extraction.
  3588. Be careful when using the @option{--overwrite} option, particularly when
  3589. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3590. can change the contents, ownership or permissions of any file on your
  3591. system. Also, many systems do not take kindly to overwriting files that
  3592. are currently being executed.
  3593. @opindex overwrite-dir
  3594. @item --overwrite-dir
  3595. Overwrite the metadata of directories when extracting files from an
  3596. archive, but remove other files before extracting.
  3597. @end table
  3598. @node Keep Old Files
  3599. @unnumberedsubsubsec Keep Old Files
  3600. @table @option
  3601. @opindex keep-old-files
  3602. @item --keep-old-files
  3603. @itemx -k
  3604. Do not replace existing files from archive. The
  3605. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3606. from replacing existing files with files with the same name from the
  3607. archive. The @option{--keep-old-files} option is meaningless with
  3608. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3609. files in the file system during extraction.
  3610. @end table
  3611. @node Keep Newer Files
  3612. @unnumberedsubsubsec Keep Newer Files
  3613. @table @option
  3614. @opindex keep-newer-files
  3615. @item --keep-newer-files
  3616. Do not replace existing files that are newer than their archive
  3617. copies. This option is meaningless with @option{--list} (@option{-t}).
  3618. @end table
  3619. @node Unlink First
  3620. @unnumberedsubsubsec Unlink First
  3621. @table @option
  3622. @opindex unlink-first
  3623. @item --unlink-first
  3624. @itemx -U
  3625. Remove files before extracting over them.
  3626. This can make @command{tar} run a bit faster if you know in advance
  3627. that the extracted files all need to be removed. Normally this option
  3628. slows @command{tar} down slightly, so it is disabled by default.
  3629. @end table
  3630. @node Recursive Unlink
  3631. @unnumberedsubsubsec Recursive Unlink
  3632. @table @option
  3633. @opindex recursive-unlink
  3634. @item --recursive-unlink
  3635. When this option is specified, try removing files and directory hierarchies
  3636. before extracting over them. @emph{This is a dangerous option!}
  3637. @end table
  3638. If you specify the @option{--recursive-unlink} option,
  3639. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3640. as far as current permissions will allow it. This could include removal
  3641. of the contents of a full directory hierarchy.
  3642. @node Data Modification Times
  3643. @unnumberedsubsubsec Setting Data Modification Times
  3644. @cindex Data modification times of extracted files
  3645. @cindex Modification times of extracted files
  3646. Normally, @command{tar} sets the data modification times of extracted
  3647. files to the corresponding times recorded for the files in the archive, but
  3648. limits the permissions of extracted files by the current @code{umask}
  3649. setting.
  3650. To set the data modification times of extracted files to the time when
  3651. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3652. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3653. @table @option
  3654. @opindex touch
  3655. @item --touch
  3656. @itemx -m
  3657. Sets the data modification time of extracted archive members to the time
  3658. they were extracted, not the time recorded for them in the archive.
  3659. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3660. @end table
  3661. @node Setting Access Permissions
  3662. @unnumberedsubsubsec Setting Access Permissions
  3663. @cindex Permissions of extracted files
  3664. @cindex Modes of extracted files
  3665. To set the modes (access permissions) of extracted files to those
  3666. recorded for those files in the archive, use @option{--same-permissions}
  3667. in conjunction with the @option{--extract} (@option{--get},
  3668. @option{-x}) operation.
  3669. @table @option
  3670. @opindex preserve-permission
  3671. @opindex same-permission
  3672. @item --preserve-permission
  3673. @itemx --same-permission
  3674. @c @itemx --ignore-umask
  3675. @itemx -p
  3676. Set modes of extracted archive members to those recorded in the
  3677. archive, instead of current umask settings. Use in conjunction with
  3678. @option{--extract} (@option{--get}, @option{-x}).
  3679. @end table
  3680. @node Directory Modification Times and Permissions
  3681. @unnumberedsubsubsec Directory Modification Times and Permissions
  3682. After sucessfully extracting a file member, @GNUTAR{} normally
  3683. restores its permissions and modification times, as described in the
  3684. previous sections. This cannot be done for directories, because
  3685. after extracting a directory @command{tar} will almost certainly
  3686. extract files into that directory and this will cause the directory
  3687. modification time to be updated. Moreover, restoring that directory
  3688. permissions may not permit file creation within it. Thus, restoring
  3689. directory permissions and modification times must be delayed at least
  3690. until all files have been extracted into that directory. @GNUTAR{}
  3691. restores directories using the following approach.
  3692. The extracted directories are created with the mode specified in the
  3693. archive, as modified by the umask of the user, which gives sufficient
  3694. permissions to allow file creation. The meta-information about the
  3695. directory is recorded in the temporary list of directories. When
  3696. preparing to extract next archive member, @GNUTAR{} checks if the
  3697. directory prefix of this file contains the remembered directory. If
  3698. it does not, the program assumes that all files have been extracted
  3699. into that directory, restores its modification time and permissions
  3700. and removes its entry from the internal list. This approach allows
  3701. to correctly restore directory meta-information in the majority of
  3702. cases, while keeping memory requirements sufficiently small. It is
  3703. based on the fact, that most @command{tar} archives use the predefined
  3704. order of members: first the directory, then all the files and
  3705. subdirectories in that directory.
  3706. However, this is not always true. The most important exception are
  3707. incremental archives (@pxref{Incremental Dumps}). The member order in
  3708. an incremental archive is reversed: first all directory members are
  3709. stored, followed by other (non-directory) members. So, when extracting
  3710. from incremental archives, @GNUTAR{} alters the above procedure. It
  3711. remebers all restored directories, and restores their meta-data
  3712. only after the entire archive has been processed. Notice, that you do
  3713. not need to specity any special options for that, as @GNUTAR{}
  3714. automatically detects archives in incremental format.
  3715. There may be cases, when such processing is required for normal archives
  3716. too. Consider the following example:
  3717. @smallexample
  3718. @group
  3719. $ @kbd{tar --no-recursion -cvf archive \
  3720. foo foo/file1 bar bar/file foo/file2}
  3721. foo/
  3722. foo/file1
  3723. bar/
  3724. bar/file
  3725. foo/file2
  3726. @end group
  3727. @end smallexample
  3728. During the normal operation, after encountering @file{bar}
  3729. @GNUTAR{} will assume that all files from the directory @file{foo}
  3730. were already extracted and will therefore restore its timestamp and
  3731. permission bits. However, after extracting @file{foo/file2} the
  3732. directory timestamp will be offset again.
  3733. To correctly restore directory meta-information in such cases, use
  3734. @option{delay-directory-restore} command line option:
  3735. @table @option
  3736. @opindex delay-directory-restore
  3737. @item --delay-directory-restore
  3738. Delays restoring of the modification times and permissions of extracted
  3739. directories until the end of extraction. This way, correct
  3740. meta-information is restored even if the archive has unusual member
  3741. ordering.
  3742. @opindex no-delay-directory-restore
  3743. @item --no-delay-directory-restore
  3744. Cancel the effect of the previous @option{--delay-directory-restore}.
  3745. Use this option if you have used @option{--delay-directory-restore} in
  3746. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  3747. temporarily disable it.
  3748. @end table
  3749. @node Writing to Standard Output
  3750. @unnumberedsubsubsec Writing to Standard Output
  3751. @cindex Writing extracted files to standard output
  3752. @cindex Standard output, writing extracted files to
  3753. To write the extracted files to the standard output, instead of
  3754. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3755. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3756. extracting files to send them through a pipe, and do not need to
  3757. preserve them in the file system. If you extract multiple members,
  3758. they appear on standard output concatenated, in the order they are
  3759. found in the archive.
  3760. @table @option
  3761. @opindex to-stdout
  3762. @item --to-stdout
  3763. @itemx -O
  3764. Writes files to the standard output. Use only in conjunction with
  3765. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3766. used, instead of creating the files specified, @command{tar} writes
  3767. the contents of the files extracted to its standard output. This may
  3768. be useful if you are only extracting the files in order to send them
  3769. through a pipe. This option is meaningless with @option{--list}
  3770. (@option{-t}).
  3771. @end table
  3772. This can be useful, for example, if you have a tar archive containing
  3773. a big file and don't want to store the file on disk before processing
  3774. it. You can use a command like this:
  3775. @smallexample
  3776. tar -xOzf foo.tgz bigfile | process
  3777. @end smallexample
  3778. or even like this if you want to process the concatenation of the files:
  3779. @smallexample
  3780. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3781. @end smallexample
  3782. Hovewer, @option{--to-command} may be more convenient for use with
  3783. multiple files. See the next section.
  3784. @node Writing to an External Program
  3785. @unnumberedsubsubsec Writing to an External Program
  3786. You can instruct @command{tar} to send the contents of each extracted
  3787. file to the standard input of an external program:
  3788. @table @option
  3789. @opindex to-command
  3790. @item --to-command=@var{command}
  3791. Extract files and pipe their contents to the standard input of
  3792. @var{command}. When this option is used, instead of creating the
  3793. files specified, @command{tar} invokes @var{command} and pipes the
  3794. contents of the files to its standard output. @var{Command} may
  3795. contain command line arguments. The program is executed via
  3796. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3797. extracted. Non-regular files (directories, etc.) are ignored when this
  3798. option is used.
  3799. @end table
  3800. The command can obtain the information about the file it processes
  3801. from the following environment variables:
  3802. @table @var
  3803. @vrindex TAR_FILETYPE, to-command environment
  3804. @item TAR_FILETYPE
  3805. Type of the file. It is a single letter with the following meaning:
  3806. @multitable @columnfractions 0.10 0.90
  3807. @item f @tab Regular file
  3808. @item d @tab Directory
  3809. @item l @tab Symbolic link
  3810. @item h @tab Hard link
  3811. @item b @tab Block device
  3812. @item c @tab Character device
  3813. @end multitable
  3814. Currently only regular files are supported.
  3815. @vrindex TAR_MODE, to-command environment
  3816. @item TAR_MODE
  3817. File mode, an octal number.
  3818. @vrindex TAR_FILENAME, to-command environment
  3819. @item TAR_FILENAME
  3820. The name of the file.
  3821. @vrindex TAR_REALNAME, to-command environment
  3822. @item TAR_REALNAME
  3823. Name of the file as stored in the archive.
  3824. @vrindex TAR_UNAME, to-command environment
  3825. @item TAR_UNAME
  3826. Name of the file owner.
  3827. @vrindex TAR_GNAME, to-command environment
  3828. @item TAR_GNAME
  3829. Name of the file owner group.
  3830. @vrindex TAR_ATIME, to-command environment
  3831. @item TAR_ATIME
  3832. Time of last access. It is a decimal number, representing seconds
  3833. since the epoch. If the archive provides times with nanosecond
  3834. precision, the nanoseconds are appended to the timestamp after a
  3835. decimal point.
  3836. @vrindex TAR_MTIME, to-command environment
  3837. @item TAR_MTIME
  3838. Time of last modification.
  3839. @vrindex TAR_CTIME, to-command environment
  3840. @item TAR_CTIME
  3841. Time of last status change.
  3842. @vrindex TAR_SIZE, to-command environment
  3843. @item TAR_SIZE
  3844. Size of the file.
  3845. @vrindex TAR_UID, to-command environment
  3846. @item TAR_UID
  3847. UID of the file owner.
  3848. @vrindex TAR_GID, to-command environment
  3849. @item TAR_GID
  3850. GID of the file owner.
  3851. @end table
  3852. In addition to these variables, @env{TAR_VERSION} contains the
  3853. @GNUTAR{} version number.
  3854. If @var{command} exits with a non-0 status, @command{tar} will print
  3855. an error message similar to the following:
  3856. @smallexample
  3857. tar: 2345: Child returned status 1
  3858. @end smallexample
  3859. Here, @samp{2345} is the PID of the finished process.
  3860. If this behavior is not wanted, use @option{--ignore-command-error}:
  3861. @table @option
  3862. @opindex ignore-command-error
  3863. @item --ignore-command-error
  3864. Ignore exit codes of subprocesses. Notice that if the program
  3865. exits on signal or otherwise terminates abnormally, the error message
  3866. will be printed even if this option is used.
  3867. @opindex no-ignore-command-error
  3868. @item --no-ignore-command-error
  3869. Cancel the effect of any previous @option{--ignore-command-error}
  3870. option. This option is useful if you have set
  3871. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3872. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3873. @end table
  3874. @node remove files
  3875. @unnumberedsubsubsec Removing Files
  3876. @FIXME{The section is too terse. Something more to add? An example,
  3877. maybe?}
  3878. @table @option
  3879. @opindex remove-files
  3880. @item --remove-files
  3881. Remove files after adding them to the archive.
  3882. @end table
  3883. @node Scarce
  3884. @subsection Coping with Scarce Resources
  3885. @UNREVISED
  3886. @cindex Small memory
  3887. @cindex Running out of space
  3888. @menu
  3889. * Starting File::
  3890. * Same Order::
  3891. @end menu
  3892. @node Starting File
  3893. @unnumberedsubsubsec Starting File
  3894. @table @option
  3895. @opindex starting-file
  3896. @item --starting-file=@var{name}
  3897. @itemx -K @var{name}
  3898. Starts an operation in the middle of an archive. Use in conjunction
  3899. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3900. @end table
  3901. @cindex Middle of the archive, starting in the
  3902. If a previous attempt to extract files failed due to lack of disk
  3903. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3904. @var{name}}) to start extracting only after member @var{name} of the
  3905. archive. This assumes, of course, that there is now free space, or
  3906. that you are now extracting into a different file system. (You could
  3907. also choose to suspend @command{tar}, remove unnecessary files from
  3908. the file system, and then restart the same @command{tar} operation.
  3909. In this case, @option{--starting-file} is not necessary.
  3910. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  3911. @node Same Order
  3912. @unnumberedsubsubsec Same Order
  3913. @table @option
  3914. @cindex Large lists of file names on small machines
  3915. @opindex same-order
  3916. @opindex preserve-order
  3917. @item --same-order
  3918. @itemx --preserve-order
  3919. @itemx -s
  3920. To process large lists of file names on machines with small amounts of
  3921. memory. Use in conjunction with @option{--compare} (@option{--diff},
  3922. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  3923. (@option{--get}, @option{-x}).
  3924. @end table
  3925. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  3926. names to be listed or extracted is sorted in the same order as the
  3927. files in the archive. This allows a large list of names to be used,
  3928. even on a small machine that would not otherwise be able to hold all
  3929. the names in memory at the same time. Such a sorted list can easily be
  3930. created by running @samp{tar -t} on the archive and editing its output.
  3931. This option is probably never needed on modern computer systems.
  3932. @node backup
  3933. @section Backup options
  3934. @cindex backup options
  3935. @GNUTAR{} offers options for making backups of files
  3936. before writing new versions. These options control the details of
  3937. these backups. They may apply to the archive itself before it is
  3938. created or rewritten, as well as individual extracted members. Other
  3939. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3940. and @command{mv}, for example) offer similar options.
  3941. Backup options may prove unexpectedly useful when extracting archives
  3942. containing many members having identical name, or when extracting archives
  3943. on systems having file name limitations, making different members appear
  3944. has having similar names through the side-effect of name truncation.
  3945. (This is true only if we have a good scheme for truncated backup names,
  3946. which I'm not sure at all: I suspect work is needed in this area.)
  3947. When any existing file is backed up before being overwritten by extraction,
  3948. then clashing files are automatically be renamed to be unique, and the
  3949. true name is kept for only the last file of a series of clashing files.
  3950. By using verbose mode, users may track exactly what happens.
  3951. At the detail level, some decisions are still experimental, and may
  3952. change in the future, we are waiting comments from our users. So, please
  3953. do not learn to depend blindly on the details of the backup features.
  3954. For example, currently, directories themselves are never renamed through
  3955. using these options, so, extracting a file over a directory still has
  3956. good chances to fail. Also, backup options apply to created archives,
  3957. not only to extracted members. For created archives, backups will not
  3958. be attempted when the archive is a block or character device, or when it
  3959. refers to a remote file.
  3960. For the sake of simplicity and efficiency, backups are made by renaming old
  3961. files prior to creation or extraction, and not by copying. The original
  3962. name is restored if the file creation fails. If a failure occurs after a
  3963. partial extraction of a file, both the backup and the partially extracted
  3964. file are kept.
  3965. @table @samp
  3966. @item --backup[=@var{method}]
  3967. @opindex backup
  3968. @vindex VERSION_CONTROL
  3969. @cindex backups
  3970. Back up files that are about to be overwritten or removed.
  3971. Without this option, the original versions are destroyed.
  3972. Use @var{method} to determine the type of backups made.
  3973. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3974. environment variable. And if @env{VERSION_CONTROL} is not set,
  3975. use the @samp{existing} method.
  3976. @vindex version-control @r{Emacs variable}
  3977. This option corresponds to the Emacs variable @samp{version-control};
  3978. the same values for @var{method} are accepted as in Emacs. This option
  3979. also allows more descriptive names. The valid @var{method}s are:
  3980. @table @samp
  3981. @item t
  3982. @itemx numbered
  3983. @cindex numbered @r{backup method}
  3984. Always make numbered backups.
  3985. @item nil
  3986. @itemx existing
  3987. @cindex existing @r{backup method}
  3988. Make numbered backups of files that already have them, simple backups
  3989. of the others.
  3990. @item never
  3991. @itemx simple
  3992. @cindex simple @r{backup method}
  3993. Always make simple backups.
  3994. @end table
  3995. @item --suffix=@var{suffix}
  3996. @opindex suffix
  3997. @cindex backup suffix
  3998. @vindex SIMPLE_BACKUP_SUFFIX
  3999. Append @var{suffix} to each backup file made with @option{--backup}. If this
  4000. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  4001. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  4002. set, the default is @samp{~}, just as in Emacs.
  4003. @end table
  4004. Some people express the desire to @emph{always} use the @option{--backup}
  4005. option, by defining some kind of alias or script. This is not as easy
  4006. as one may think, due to the fact that old style options should appear first
  4007. and consume arguments a bit unpredictably for an alias or script. But,
  4008. if you are ready to give up using old style options, you may resort to
  4009. using something like (a Bourne shell function here):
  4010. @smallexample
  4011. tar () @{ /usr/local/bin/tar --backup $*; @}
  4012. @end smallexample
  4013. @node Applications
  4014. @section Notable @command{tar} Usages
  4015. @UNREVISED
  4016. @FIXME{Using Unix file linking capability to recreate directory
  4017. structures---linking files into one subdirectory and then
  4018. @command{tar}ring that directory.}
  4019. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  4020. @findex uuencode
  4021. You can easily use archive files to transport a group of files from
  4022. one system to another: put all relevant files into an archive on one
  4023. computer system, transfer the archive to another system, and extract
  4024. the contents there. The basic transfer medium might be magnetic tape,
  4025. Internet FTP, or even electronic mail (though you must encode the
  4026. archive with @command{uuencode} in order to transport it properly by
  4027. mail). Both machines do not have to use the same operating system, as
  4028. long as they both support the @command{tar} program.
  4029. For example, here is how you might copy a directory's contents from
  4030. one disk to another, while preserving the dates, modes, owners and
  4031. link-structure of all the files therein. In this case, the transfer
  4032. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  4033. @smallexample
  4034. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
  4035. @end smallexample
  4036. @noindent
  4037. You can avoid subshells by using @option{-C} option:
  4038. @smallexample
  4039. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xf -}
  4040. @end smallexample
  4041. @noindent
  4042. The command also works using short option forms:
  4043. @smallexample
  4044. $ @kbd{(cd sourcedir; tar --create --file=- . ) \
  4045. | (cd targetdir; tar --extract --file=-)}
  4046. # Or:
  4047. $ @kbd{tar --directory sourcedir --create --file=- . ) \
  4048. | tar --directory targetdir --extract --file=-}
  4049. @end smallexample
  4050. @noindent
  4051. This is one of the easiest methods to transfer a @command{tar} archive.
  4052. @node looking ahead
  4053. @section Looking Ahead: The Rest of this Manual
  4054. You have now seen how to use all eight of the operations available to
  4055. @command{tar}, and a number of the possible options. The next chapter
  4056. explains how to choose and change file and archive names, how to use
  4057. files to store names of other files which you can then call as
  4058. arguments to @command{tar} (this can help you save time if you expect to
  4059. archive the same list of files a number of times), and so forth.
  4060. @FIXME{in case it's not obvious, i'm making this up in some sense
  4061. based on my limited memory of what the next chapter *really* does. i
  4062. just wanted to flesh out this final section a little bit so i'd
  4063. remember to stick it in here. :-)}
  4064. If there are too many files to conveniently list on the command line,
  4065. you can list the names in a file, and @command{tar} will read that file.
  4066. @xref{files}.
  4067. There are various ways of causing @command{tar} to skip over some files,
  4068. and not archive them. @xref{Choosing}.
  4069. @node Backups
  4070. @chapter Performing Backups and Restoring Files
  4071. @UNREVISED
  4072. @GNUTAR{} is distributed along with the scripts
  4073. which the Free Software Foundation uses for performing backups. There
  4074. is no corresponding scripts available yet for doing restoration of
  4075. files. Even if there is a good chance those scripts may be satisfying
  4076. to you, they are not the only scripts or methods available for doing
  4077. backups and restore. You may well create your own, or use more
  4078. sophisticated packages dedicated to that purpose.
  4079. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  4080. Automatic Network Disk Archiver), a backup system developed by James
  4081. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  4082. This is free software, and it is available at these places:
  4083. @smallexample
  4084. http://www.cs.umd.edu/projects/amanda/amanda.html
  4085. ftp://ftp.cs.umd.edu/pub/amanda
  4086. @end smallexample
  4087. @FIXME{
  4088. Here is a possible plan for a future documentation about the backuping
  4089. scripts which are provided within the @GNUTAR{}
  4090. distribution.
  4091. @itemize @bullet
  4092. @item dumps
  4093. @itemize @minus
  4094. @item what are dumps
  4095. @item different levels of dumps
  4096. @itemize +
  4097. @item full dump = dump everything
  4098. @item level 1, level 2 dumps etc
  4099. A level @var{n} dump dumps everything changed since the last level
  4100. @var{n}-1 dump (?)
  4101. @end itemize
  4102. @item how to use scripts for dumps (ie, the concept)
  4103. @itemize +
  4104. @item scripts to run after editing backup specs (details)
  4105. @end itemize
  4106. @item Backup Specs, what is it.
  4107. @itemize +
  4108. @item how to customize
  4109. @item actual text of script [/sp/dump/backup-specs]
  4110. @end itemize
  4111. @item Problems
  4112. @itemize +
  4113. @item rsh doesn't work
  4114. @item rtape isn't installed
  4115. @item (others?)
  4116. @end itemize
  4117. @item the @option{--incremental} option of tar
  4118. @item tapes
  4119. @itemize +
  4120. @item write protection
  4121. @item types of media, different sizes and types, useful for different things
  4122. @item files and tape marks
  4123. one tape mark between files, two at end.
  4124. @item positioning the tape
  4125. MT writes two at end of write,
  4126. backspaces over one when writing again.
  4127. @end itemize
  4128. @end itemize
  4129. @end itemize
  4130. }
  4131. This chapter documents both the provided shell scripts and @command{tar}
  4132. options which are more specific to usage as a backup tool.
  4133. To @dfn{back up} a file system means to create archives that contain
  4134. all the files in that file system. Those archives can then be used to
  4135. restore any or all of those files (for instance if a disk crashes or a
  4136. file is accidentally deleted). File system @dfn{backups} are also
  4137. called @dfn{dumps}.
  4138. @menu
  4139. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4140. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4141. * Backup Levels:: Levels of Backups
  4142. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4143. * Scripted Backups:: Using the Backup Scripts
  4144. * Scripted Restoration:: Using the Restore Script
  4145. @end menu
  4146. @node Full Dumps
  4147. @section Using @command{tar} to Perform Full Dumps
  4148. @UNREVISED
  4149. @cindex full dumps
  4150. @cindex dumps, full
  4151. @cindex corrupted archives
  4152. Full dumps should only be made when no other people or programs
  4153. are modifying files in the file system. If files are modified while
  4154. @command{tar} is making the backup, they may not be stored properly in
  4155. the archive, in which case you won't be able to restore them if you
  4156. have to. (Files not being modified are written with no trouble, and do
  4157. not corrupt the entire archive.)
  4158. You will want to use the @option{--label=@var{archive-label}}
  4159. (@option{-V @var{archive-label}}) option to give the archive a
  4160. volume label, so you can tell what this archive is even if the label
  4161. falls off the tape, or anything like that.
  4162. Unless the file system you are dumping is guaranteed to fit on
  4163. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4164. Make sure you have enough tapes on hand to complete the backup.
  4165. If you want to dump each file system separately you will need to use
  4166. the @option{--one-file-system} option to prevent
  4167. @command{tar} from crossing file system boundaries when storing
  4168. (sub)directories.
  4169. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4170. option is not needed, since this is a complete copy of everything in
  4171. the file system, and a full restore from this backup would only be
  4172. done onto a completely
  4173. empty disk.
  4174. Unless you are in a hurry, and trust the @command{tar} program (and your
  4175. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4176. option, to make sure your files really made it onto the dump properly.
  4177. This will also detect cases where the file was modified while (or just
  4178. after) it was being archived. Not all media (notably cartridge tapes)
  4179. are capable of being verified, unfortunately.
  4180. @node Incremental Dumps
  4181. @section Using @command{tar} to Perform Incremental Dumps
  4182. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4183. stores additional metadata so that exact state of the file system
  4184. can be restored when extracting the archive.
  4185. @GNUTAR{} currently offers two options for handling incremental
  4186. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4187. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4188. @opindex listed-incremental
  4189. The option @option{--listed-incremental} instructs tar to operate on
  4190. an incremental archive with additional metadata stored in a standalone
  4191. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4192. determine which files have been changed, added or deleted since the
  4193. last backup, so that the next incremental backup will contain only
  4194. modified files. The name of the snapshot file is given as an argument
  4195. to the option:
  4196. @table @option
  4197. @item --listed-incremental=@var{file}
  4198. @itemx -g @var{file}
  4199. Handle incremental backups with snapshot data in @var{file}.
  4200. @end table
  4201. To create an incremental backup, you would use
  4202. @option{--listed-incremental} together with @option{--create}
  4203. (@pxref{create}). For example:
  4204. @smallexample
  4205. $ @kbd{tar --create \
  4206. --file=archive.1.tar \
  4207. --listed-incremental=/var/log/usr.snar \
  4208. /usr}
  4209. @end smallexample
  4210. This will create in @file{archive.1.tar} an incremental backup of
  4211. the @file{/usr} file system, storing additional metadata in the file
  4212. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4213. created. The created archive will then be a @dfn{level 0 backup};
  4214. please see the next section for more on backup levels.
  4215. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4216. determines which files are modified. In this case only these files will be
  4217. stored in the archive. Suppose, for example, that after running the
  4218. above command, you delete file @file{/usr/doc/old} and create
  4219. directory @file{/usr/local/db} with the following contents:
  4220. @smallexample
  4221. $ @kbd{ls /usr/local/db}
  4222. /usr/local/db/data
  4223. /usr/local/db/index
  4224. @end smallexample
  4225. Some time later you create another incremental backup. You will
  4226. then see:
  4227. @smallexample
  4228. $ @kbd{tar --create \
  4229. --file=archive.2.tar \
  4230. --listed-incremental=/var/log/usr.snar \
  4231. /usr}
  4232. tar: usr/local/db: Directory is new
  4233. usr/local/db/
  4234. usr/local/db/data
  4235. usr/local/db/index
  4236. @end smallexample
  4237. @noindent
  4238. The created archive @file{archive.2.tar} will contain only these
  4239. three members. This archive is called a @dfn{level 1 backup}. Notice
  4240. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4241. you plan to create more @samp{level 1} backups, it is necessary to
  4242. create a working copy of the snapshot file before running
  4243. @command{tar}. The above example will then be modified as follows:
  4244. @smallexample
  4245. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4246. $ @kbd{tar --create \
  4247. --file=archive.2.tar \
  4248. --listed-incremental=/var/log/usr.snar-1 \
  4249. /usr}
  4250. @end smallexample
  4251. Incremental dumps depend crucially on time stamps, so the results are
  4252. unreliable if you modify a file's time stamps during dumping (e.g.,
  4253. with the @option{--atime-preserve=replace} option), or if you set the clock
  4254. backwards.
  4255. Metadata stored in snapshot files include device numbers, which,
  4256. obviously is supposed to be a non-volatile value. However, it turns
  4257. out that NFS devices have undependable values when an automounter
  4258. gets in the picture. This can lead to a great deal of spurious
  4259. redumping in incremental dumps, so it is somewhat useless to compare
  4260. two NFS devices numbers over time. The solution implemented currently
  4261. is to considers all NFS devices as being equal when it comes to
  4262. comparing directories; this is fairly gross, but there does not seem
  4263. to be a better way to go.
  4264. Note that incremental archives use @command{tar} extensions and may
  4265. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4266. @opindex listed-incremental, using with @option{--extract}
  4267. @opindex extract, using with @option{--listed-incremental}
  4268. To extract from the incremental dumps, use
  4269. @option{--listed-incremental} together with @option{--extract}
  4270. option (@pxref{extracting files}). In this case, @command{tar} does
  4271. not need to access snapshot file, since all the data necessary for
  4272. extraction are stored in the archive itself. So, when extracting, you
  4273. can give whatever argument to @option{--listed-incremental}, the usual
  4274. practice is to use @option{--listed-incremental=/dev/null}.
  4275. Alternatively, you can use @option{--incremental}, which needs no
  4276. arguments. In general, @option{--incremental} (@option{-G}) can be
  4277. used as a shortcut for @option{--listed-incremental} when listing or
  4278. extracting incremental backups (for more information, regarding this
  4279. option, @pxref{incremental-op}).
  4280. When extracting from the incremental backup @GNUTAR{} attempts to
  4281. restore the exact state the file system had when the archive was
  4282. created. In particular, it will @emph{delete} those files in the file
  4283. system that did not exist in their directories when the archive was
  4284. created. If you have created several levels of incremental files,
  4285. then in order to restore the exact contents the file system had when
  4286. the last level was created, you will need to restore from all backups
  4287. in turn. Continuing our example, to restore the state of @file{/usr}
  4288. file system, one would do@footnote{Notice, that since both archives
  4289. were created withouth @option{-P} option (@pxref{absolute}), these
  4290. commands should be run from the root file system.}:
  4291. @smallexample
  4292. $ @kbd{tar --extract \
  4293. --listed-incremental=/dev/null \
  4294. --file archive.1.tar}
  4295. $ @kbd{tar --extract \
  4296. --listed-incremental=/dev/null \
  4297. --file archive.2.tar}
  4298. @end smallexample
  4299. To list the contents of an incremental archive, use @option{--list}
  4300. (@pxref{list}), as usual. To obtain more information about the
  4301. archive, use @option{--listed-incremental} or @option{--incremental}
  4302. combined with two @option{--verbose} options@footnote{Two
  4303. @option{--verbose} options were selected to avoid breaking usual
  4304. verbose listing output (@option{--list --verbose}) when using in
  4305. scripts.
  4306. @opindex incremental, using with @option{--list}
  4307. @opindex listed-incremental, using with @option{--list}
  4308. @opindex list, using with @option{--incremental}
  4309. @opindex list, using with @option{--listed-incremental}
  4310. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4311. contents of the DUMPDIR header (with terminating nulls) when
  4312. @option{--incremental} or @option{--listed-incremental} option was
  4313. given, no matter what the verbosity level. This behavior, and,
  4314. especially, the binary output it produced were considered incovenient
  4315. and were changed in version 1.16}:
  4316. @smallexample
  4317. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4318. @end smallexample
  4319. This command will print, for each directory in the archive, the list
  4320. of files in that directory at the time the archive was created. This
  4321. information is put out in a format which is both human-readable and
  4322. unambiguous for a program: each file name is printed as
  4323. @smallexample
  4324. @var{x} @var{file}
  4325. @end smallexample
  4326. @noindent
  4327. where @var{x} is a letter describing the status of the file: @samp{Y}
  4328. if the file is present in the archive, @samp{N} if the file is not
  4329. included in the archive, or a @samp{D} if the file is a directory (and
  4330. is included in the archive).@FIXME-xref{dumpdir format}. Each such
  4331. line is terminated by a newline character. The last line is followed
  4332. by an additional newline to indicate the end of the data.
  4333. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4334. gives the same behavior as @option{--listed-incremental} when used
  4335. with @option{--list} and @option{--extract} options. When used with
  4336. @option{--create} option, it creates an incremental archive without
  4337. creating snapshot file. Thus, it is impossible to create several
  4338. levels of incremental backups with @option{--incremental} option.
  4339. @node Backup Levels
  4340. @section Levels of Backups
  4341. An archive containing all the files in the file system is called a
  4342. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4343. creating a full dump every day. This strategy, however, would waste a
  4344. substantial amount of archive media and user time, as unchanged files
  4345. are daily re-archived.
  4346. It is more efficient to do a full dump only occasionally. To back up
  4347. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4348. one} dump archives all the files that have changed since the last full
  4349. dump.
  4350. A typical dump strategy would be to perform a full dump once a week,
  4351. and a level one dump once a day. This means some versions of files
  4352. will in fact be archived more than once, but this dump strategy makes
  4353. it possible to restore a file system to within one day of accuracy by
  4354. only extracting two archives---the last weekly (full) dump and the
  4355. last daily (level one) dump. The only information lost would be in
  4356. files changed or created since the last daily backup. (Doing dumps
  4357. more than once a day is usually not worth the trouble).
  4358. @GNUTAR{} comes with scripts you can use to do full
  4359. and level-one (actually, even level-two and so on) dumps. Using
  4360. scripts (shell programs) to perform backups and restoration is a
  4361. convenient and reliable alternative to typing out file name lists
  4362. and @command{tar} commands by hand.
  4363. Before you use these scripts, you need to edit the file
  4364. @file{backup-specs}, which specifies parameters used by the backup
  4365. scripts and by the restore script. This file is usually located
  4366. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4367. detailed description. Once the backup parameters are set, you can
  4368. perform backups or restoration by running the appropriate script.
  4369. The name of the backup script is @code{backup}. The name of the
  4370. restore script is @code{restore}. The following sections describe
  4371. their use in detail.
  4372. @emph{Please Note:} The backup and restoration scripts are
  4373. designed to be used together. While it is possible to restore files by
  4374. hand from an archive which was created using a backup script, and to create
  4375. an archive by hand which could then be extracted using the restore script,
  4376. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4377. making such an attempt.
  4378. @node Backup Parameters
  4379. @section Setting Parameters for Backups and Restoration
  4380. The file @file{backup-specs} specifies backup parameters for the
  4381. backup and restoration scripts provided with @command{tar}. You must
  4382. edit @file{backup-specs} to fit your system configuration and schedule
  4383. before using these scripts.
  4384. Syntactically, @file{backup-specs} is a shell script, containing
  4385. mainly variable assignments. However, any valid shell construct
  4386. is allowed in this file. Particularly, you may wish to define
  4387. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4388. For more information about shell script syntax, please refer to
  4389. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4390. g_02, the definition of the Shell Command Language}. See also
  4391. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4392. The shell variables controlling behavior of @code{backup} and
  4393. @code{restore} are described in the following subsections.
  4394. @menu
  4395. * General-Purpose Variables::
  4396. * Magnetic Tape Control::
  4397. * User Hooks::
  4398. * backup-specs example:: An Example Text of @file{Backup-specs}
  4399. @end menu
  4400. @node General-Purpose Variables
  4401. @subsection General-Purpose Variables
  4402. @defvr {Backup variable} ADMINISTRATOR
  4403. The user name of the backup administrator. @code{Backup} scripts
  4404. sends a backup report to this address.
  4405. @end defvr
  4406. @defvr {Backup variable} BACKUP_HOUR
  4407. The hour at which the backups are done. This can be a number from 0
  4408. to 23, or the time specification in form @var{hours}:@var{minutes},
  4409. or the string @samp{now}.
  4410. This variable is used by @code{backup}. Its value may be overridden
  4411. using @option{--time} option (@pxref{Scripted Backups}).
  4412. @end defvr
  4413. @defvr {Backup variable} TAPE_FILE
  4414. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4415. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4416. that your @command{mt} is able to access remote devices. If @var{RSH}
  4417. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4418. invocations of @command{mt}.
  4419. @end defvr
  4420. @defvr {Backup variable} BLOCKING
  4421. The blocking factor @command{tar} will use when writing the dump archive.
  4422. @xref{Blocking Factor}.
  4423. @end defvr
  4424. @defvr {Backup variable} BACKUP_DIRS
  4425. A list of file systems to be dumped (for @code{backup}), or restored
  4426. (for @code{restore}). You can include any directory
  4427. name in the list --- subdirectories on that file system will be
  4428. included, regardless of how they may look to other networked machines.
  4429. Subdirectories on other file systems will be ignored.
  4430. The host name specifies which host to run @command{tar} on, and should
  4431. normally be the host that actually contains the file system. However,
  4432. the host machine must have @GNUTAR{} installed, and
  4433. must be able to access the directory containing the backup scripts and
  4434. their support files using the same file name that is used on the
  4435. machine where the scripts are run (ie. what @command{pwd} will print
  4436. when in that directory on that machine). If the host that contains
  4437. the file system does not have this capability, you can specify another
  4438. host as long as it can access the file system through NFS.
  4439. If the list of file systems is very long you may wish to put it
  4440. in a separate file. This file is usually named
  4441. @file{/etc/backup/dirs}, but this name may be overridden in
  4442. @file{backup-specs} using @code{DIRLIST} variable.
  4443. @end defvr
  4444. @defvr {Backup variable} DIRLIST
  4445. A path to the file containing the list of the file systems to backup
  4446. or restore. By default it is @file{/etc/backup/dirs}.
  4447. @end defvr
  4448. @defvr {Backup variable} BACKUP_FILES
  4449. A list of individual files to be dumped (for @code{backup}), or restored
  4450. (for @code{restore}). These should be accessible from the machine on
  4451. which the backup script is run.
  4452. If the list of file systems is very long you may wish to store it
  4453. in a separate file. This file is usually named
  4454. @file{/etc/backup/files}, but this name may be overridden in
  4455. @file{backup-specs} using @code{FILELIST} variable.
  4456. @end defvr
  4457. @defvr {Backup variable} FILELIST
  4458. A path to the file containing the list of the individual files to backup
  4459. or restore. By default it is @file{/etc/backup/files}.
  4460. @end defvr
  4461. @defvr {Backup variable} MT
  4462. Full file name of @command{mt} binary.
  4463. @end defvr
  4464. @defvr {Backup variable} RSH
  4465. @anchor{RSH}
  4466. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4467. set it to @code{ssh}, to improve security. In this case you will have
  4468. to use public key authentication.
  4469. @end defvr
  4470. @defvr {Backup variable} RSH_COMMAND
  4471. Full file name of @command{rsh} binary on remote mashines. This will
  4472. be passed via @option{--rsh-command} option to the remote invocation
  4473. of @GNUTAR{}.
  4474. @end defvr
  4475. @defvr {Backup variable} VOLNO_FILE
  4476. Name of temporary file to hold volume numbers. This needs to be accessible
  4477. by all the machines which have file systems to be dumped.
  4478. @end defvr
  4479. @defvr {Backup variable} XLIST
  4480. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4481. located on the remote machine and containing the list of files to
  4482. be excluded from the backup. Exclude file lists are searched in
  4483. /etc/tar-backup directory. A common use for exclude file lists
  4484. is to exclude files containing security-sensitive information
  4485. (e.g., @file{/etc/shadow} from backups).
  4486. This variable affects only @code{backup}.
  4487. @end defvr
  4488. @defvr {Backup variable} SLEEP_TIME
  4489. Time to sleep between dumps of any two successive file systems
  4490. This variable affects only @code{backup}.
  4491. @end defvr
  4492. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4493. Script to be run when it's time to insert a new tape in for the next
  4494. volume. Administrators may want to tailor this script for their site.
  4495. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4496. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4497. the console.
  4498. @end defvr
  4499. @defvr {Backup variable} SLEEP_MESSAGE
  4500. Message to display on the terminal while waiting for dump time. Usually
  4501. this will just be some literal text.
  4502. @end defvr
  4503. @defvr {Backup variable} TAR
  4504. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4505. scripts will search @command{tar} in the current shell path.
  4506. @end defvr
  4507. @node Magnetic Tape Control
  4508. @subsection Magnetic Tape Control
  4509. Backup scripts access tape device using special @dfn{hook functions}.
  4510. These functions take a single argument -- the name of the tape
  4511. device. Their names are kept in the following variables:
  4512. @defvr {Backup variable} MT_BEGIN
  4513. The name of @dfn{begin} function. This function is called before
  4514. accessing the drive. By default it retensions the tape:
  4515. @smallexample
  4516. MT_BEGIN=mt_begin
  4517. mt_begin() @{
  4518. mt -f "$1" retension
  4519. @}
  4520. @end smallexample
  4521. @end defvr
  4522. @defvr {Backup variable} MT_REWIND
  4523. The name of @dfn{rewind} function. The default definition is as
  4524. follows:
  4525. @smallexample
  4526. MT_REWIND=mt_rewind
  4527. mt_rewind() @{
  4528. mt -f "$1" rewind
  4529. @}
  4530. @end smallexample
  4531. @end defvr
  4532. @defvr {Backup variable} MT_OFFLINE
  4533. The name of the function switching the tape off line. By default
  4534. it is defined as follows:
  4535. @smallexample
  4536. MT_OFFLINE=mt_offline
  4537. mt_offline() @{
  4538. mt -f "$1" offl
  4539. @}
  4540. @end smallexample
  4541. @end defvr
  4542. @defvr {Backup variable} MT_STATUS
  4543. The name of the function used to obtain the status of the archive device,
  4544. including error count. Default definition:
  4545. @smallexample
  4546. MT_STATUS=mt_status
  4547. mt_status() @{
  4548. mt -f "$1" status
  4549. @}
  4550. @end smallexample
  4551. @end defvr
  4552. @node User Hooks
  4553. @subsection User Hooks
  4554. @dfn{User hooks} are shell functions executed before and after
  4555. each @command{tar} invocation. Thus, there are @dfn{backup
  4556. hooks}, which are executed before and after dumping each file
  4557. system, and @dfn{restore hooks}, executed before and
  4558. after restoring a file system. Each user hook is a shell function
  4559. taking four arguments:
  4560. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4561. Its arguments are:
  4562. @table @var
  4563. @item level
  4564. Current backup or restore level.
  4565. @item host
  4566. Name or IP address of the host machine being dumped or restored.
  4567. @item fs
  4568. Full path name to the file system being dumped or restored.
  4569. @item fsname
  4570. File system name with directory separators replaced with colons. This
  4571. is useful, e.g., for creating unique files.
  4572. @end table
  4573. @end deffn
  4574. Following variables keep the names of user hook functions
  4575. @defvr {Backup variable} DUMP_BEGIN
  4576. Dump begin function. It is executed before dumping the file system.
  4577. @end defvr
  4578. @defvr {Backup variable} DUMP_END
  4579. Executed after dumping the file system.
  4580. @end defvr
  4581. @defvr {Backup variable} RESTORE_BEGIN
  4582. Executed before restoring the file system.
  4583. @end defvr
  4584. @defvr {Backup variable} RESTORE_END
  4585. Executed after restoring the file system.
  4586. @end defvr
  4587. @node backup-specs example
  4588. @subsection An Example Text of @file{Backup-specs}
  4589. The following is an example of @file{backup-specs}:
  4590. @smallexample
  4591. # site-specific parameters for file system backup.
  4592. ADMINISTRATOR=friedman
  4593. BACKUP_HOUR=1
  4594. TAPE_FILE=/dev/nrsmt0
  4595. # Use @code{ssh} instead of the less secure @code{rsh}
  4596. RSH=/usr/bin/ssh
  4597. RSH_COMMAND=/usr/bin/ssh
  4598. # Override MT_STATUS function:
  4599. my_status() @{
  4600. mts -t $TAPE_FILE
  4601. @}
  4602. MT_STATUS=my_status
  4603. # Disable MT_OFFLINE function
  4604. MT_OFFLINE=:
  4605. BLOCKING=124
  4606. BACKUP_DIRS="
  4607. albert:/fs/fsf
  4608. apple-gunkies:/gd
  4609. albert:/fs/gd2
  4610. albert:/fs/gp
  4611. geech:/usr/jla
  4612. churchy:/usr/roland
  4613. albert:/
  4614. albert:/usr
  4615. apple-gunkies:/
  4616. apple-gunkies:/usr
  4617. gnu:/hack
  4618. gnu:/u
  4619. apple-gunkies:/com/mailer/gnu
  4620. apple-gunkies:/com/archive/gnu"
  4621. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4622. @end smallexample
  4623. @node Scripted Backups
  4624. @section Using the Backup Scripts
  4625. The syntax for running a backup script is:
  4626. @smallexample
  4627. backup --level=@var{level} --time=@var{time}
  4628. @end smallexample
  4629. The @option{level} option requests the dump level. Thus, to produce
  4630. a full dump, specify @code{--level=0} (this is the default, so
  4631. @option{--level} may be omitted if its value is @code{0}).
  4632. @footnote{For backward compatibility, the @code{backup} will also
  4633. try to deduce the requested dump level from the name of the
  4634. script itself. If the name consists of a string @samp{level-}
  4635. followed by a single decimal digit, that digit is taken as
  4636. the dump level number. Thus, you may create a link from @code{backup}
  4637. to @code{level-1} and then run @code{level-1} whenever you need to
  4638. create a level one dump.}
  4639. The @option{--time} option determines when should the backup be
  4640. run. @var{Time} may take three forms:
  4641. @table @asis
  4642. @item @var{hh}:@var{mm}
  4643. The dump must be run at @var{hh} hours @var{mm} minutes.
  4644. @item @var{hh}
  4645. The dump must be run at @var{hh} hours
  4646. @item now
  4647. The dump must be run immediately.
  4648. @end table
  4649. You should start a script with a tape or disk mounted. Once you
  4650. start a script, it prompts you for new tapes or disks as it
  4651. needs them. Media volumes don't have to correspond to archive
  4652. files --- a multi-volume archive can be started in the middle of a
  4653. tape that already contains the end of another multi-volume archive.
  4654. The @code{restore} script prompts for media by its archive volume,
  4655. so to avoid an error message you should keep track of which tape
  4656. (or disk) contains which volume of the archive (@pxref{Scripted
  4657. Restoration}).
  4658. The backup scripts write two files on the file system. The first is a
  4659. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4660. to store and retrieve information about which files were dumped. This
  4661. file is not meant to be read by humans, and should not be deleted by
  4662. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4663. file.
  4664. The second file is a log file containing the names of the file systems
  4665. and files dumped, what time the backup was made, and any error
  4666. messages that were generated, as well as how much space was left in
  4667. the media volume after the last volume of the archive was written.
  4668. You should check this log file after every backup. The file name is
  4669. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4670. represents current date, and @var{n} represents current dump level number.
  4671. The script also prints the name of each system being dumped to the
  4672. standard output.
  4673. Following is the full list of options accepted by @code{backup}
  4674. script:
  4675. @table @option
  4676. @item -l @var{level}
  4677. @itemx --level=@var{level}
  4678. Do backup level @var{level} (default 0).
  4679. @item -f
  4680. @itemx --force
  4681. Force backup even if today's log file already exists.
  4682. @item -v[@var{level}]
  4683. @itemx --verbose[=@var{level}]
  4684. Set verbosity level. The higher the level is, the more debugging
  4685. information will be output during execution. Devault @var{level}
  4686. is 100, which means the highest debugging level.
  4687. @item -t @var{start-time}
  4688. @itemx --time=@var{start-time}
  4689. Wait till @var{time}, then do backup.
  4690. @item -h
  4691. @itemx --help
  4692. Display short help message and exit.
  4693. @item -V
  4694. @itemx --version
  4695. Display information about the program's name, version, origin and legal
  4696. status, all on standard output, and then exit successfully.
  4697. @end table
  4698. @node Scripted Restoration
  4699. @section Using the Restore Script
  4700. To restore files that were archived using a scripted backup, use the
  4701. @code{restore} script. Its usage is quite straightforward. In the
  4702. simplest form, invoke @code{restore --all}, it will
  4703. then restore all the file systems and files specified in
  4704. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4705. You may select the file systems (and/or files) to restore by
  4706. giving @code{restore} list of @dfn{patterns} in its command
  4707. line. For example, running
  4708. @smallexample
  4709. restore 'albert:*'
  4710. @end smallexample
  4711. @noindent
  4712. will restore all file systems on the machine @samp{albert}. A more
  4713. complicated example:
  4714. @smallexample
  4715. restore 'albert:*' '*:/var'
  4716. @end smallexample
  4717. @noindent
  4718. This command will restore all file systems on the machine @samp{albert}
  4719. as well as @file{/var} file system on all machines.
  4720. By default @code{restore} will start restoring files from the lowest
  4721. available dump level (usually zero) and will continue through
  4722. all available dump levels. There may be situations where such a
  4723. thorough restore is not necessary. For example, you may wish to
  4724. restore only files from the recent level one backup. To do so,
  4725. use @option{--level} option, as shown in the example below:
  4726. @smallexample
  4727. restore --level=1
  4728. @end smallexample
  4729. The full list of options accepted by @code{restore} follows:
  4730. @table @option
  4731. @item -a
  4732. @itemx --all
  4733. Restore all file systems and files specified in @file{backup-specs}
  4734. @item -l @var{level}
  4735. @itemx --level=@var{level}
  4736. Start restoring from the given backup level, instead of the default 0.
  4737. @item -v[@var{level}]
  4738. @itemx --verbose[=@var{level}]
  4739. Set verbosity level. The higher the level is, the more debugging
  4740. information will be output during execution. Devault @var{level}
  4741. is 100, which means the highest debugging level.
  4742. @item -h
  4743. @itemx --help
  4744. Display short help message and exit.
  4745. @item -V
  4746. @itemx --version
  4747. Display information about the program's name, version, origin and legal
  4748. status, all on standard output, and then exit successfully.
  4749. @end table
  4750. You should start the restore script with the media containing the
  4751. first volume of the archive mounted. The script will prompt for other
  4752. volumes as they are needed. If the archive is on tape, you don't need
  4753. to rewind the tape to to its beginning---if the tape head is
  4754. positioned past the beginning of the archive, the script will rewind
  4755. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4756. positioning.}
  4757. @quotation
  4758. @strong{Warning:} The script will delete files from the active file
  4759. system if they were not in the file system when the archive was made.
  4760. @end quotation
  4761. @xref{Incremental Dumps}, for an explanation of how the script makes
  4762. that determination.
  4763. @node Choosing
  4764. @chapter Choosing Files and Names for @command{tar}
  4765. @UNREVISED
  4766. Certain options to @command{tar} enable you to specify a name for your
  4767. archive. Other options let you decide which files to include or exclude
  4768. from the archive, based on when or whether files were modified, whether
  4769. the file names do or don't match specified patterns, or whether files
  4770. are in specified directories.
  4771. This chapter discusses these options in detail.
  4772. @menu
  4773. * file:: Choosing the Archive's Name
  4774. * Selecting Archive Members::
  4775. * files:: Reading Names from a File
  4776. * exclude:: Excluding Some Files
  4777. * Wildcards:: Wildcards Patterns and Matching
  4778. * after:: Operating Only on New Files
  4779. * recurse:: Descending into Directories
  4780. * one:: Crossing File System Boundaries
  4781. @end menu
  4782. @node file
  4783. @section Choosing and Naming Archive Files
  4784. @UNREVISED
  4785. @cindex Naming an archive
  4786. @cindex Archive Name
  4787. @cindex Choosing an archive file
  4788. @cindex Where is the archive?
  4789. By default, @command{tar} uses an archive file name that was compiled when
  4790. it was built on the system; usually this name refers to some physical
  4791. tape drive on the machine. However, the person who installed @command{tar}
  4792. on the system may not have set the default to a meaningful value as far as
  4793. most users are concerned. As a result, you will usually want to tell
  4794. @command{tar} where to find (or create) the archive. The
  4795. @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4796. option allows you to either specify or name a file to use as the archive
  4797. instead of the default archive file location.
  4798. @table @option
  4799. @opindex file, short description
  4800. @item --file=@var{archive-name}
  4801. @itemx -f @var{archive-name}
  4802. Name the archive to create or operate on. Use in conjunction with
  4803. any operation.
  4804. @end table
  4805. For example, in this @command{tar} command,
  4806. @smallexample
  4807. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4808. @end smallexample
  4809. @noindent
  4810. @file{collection.tar} is the name of the archive. It must directly
  4811. follow the @option{-f} option, since whatever directly follows @option{-f}
  4812. @emph{will} end up naming the archive. If you neglect to specify an
  4813. archive name, you may end up overwriting a file in the working directory
  4814. with the archive you create since @command{tar} will use this file's name
  4815. for the archive name.
  4816. An archive can be saved as a file in the file system, sent through a
  4817. pipe or over a network, or written to an I/O device such as a tape,
  4818. floppy disk, or CD write drive.
  4819. @cindex Writing new archives
  4820. @cindex Archive creation
  4821. If you do not name the archive, @command{tar} uses the value of the
  4822. environment variable @env{TAPE} as the file name for the archive. If
  4823. that is not available, @command{tar} uses a default, compiled-in archive
  4824. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4825. @cindex Standard input and output
  4826. @cindex tar to standard input and output
  4827. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4828. archive from standard input (when listing or extracting files), or
  4829. writes it to standard output (when creating an archive). If you use
  4830. @file{-} as an @var{archive-name} when modifying an archive,
  4831. @command{tar} reads the original archive from its standard input and
  4832. writes the entire new archive to its standard output.
  4833. The following example is a convenient way of copying directory
  4834. hierarchy from @file{sourcedir} to @file{targetdir}.
  4835. @smallexample
  4836. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)}
  4837. @end smallexample
  4838. The @option{-C} option allows to avoid using subshells:
  4839. @smallexample
  4840. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xpf -}
  4841. @end smallexample
  4842. In both examples above, the leftmost @command{tar} invocation archives
  4843. the contents of @file{sourcedir} to the standard output, while the
  4844. rightmost one reads this archive from its standard input and
  4845. extracts it. The @option{-p} option tells it to restore permissions
  4846. of the extracted files.
  4847. @cindex Remote devices
  4848. @cindex tar to a remote device
  4849. @anchor{remote-dev}
  4850. To specify an archive file on a device attached to a remote machine,
  4851. use the following:
  4852. @smallexample
  4853. @kbd{--file=@var{hostname}:/@var{dev}/@var{file-name}}
  4854. @end smallexample
  4855. @noindent
  4856. @command{tar} will complete the remote connection, if possible, and
  4857. prompt you for a username and password. If you use
  4858. @option{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @command{tar}
  4859. will complete the remote connection, if possible, using your username
  4860. as the username on the remote machine.
  4861. @cindex Local and remote archives
  4862. @anchor{local and remote archives}
  4863. If the archive file name includes a colon (@samp{:}), then it is assumed
  4864. to be a file on another machine. If the archive file is
  4865. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4866. host @var{host}. The remote host is accessed using the @command{rsh}
  4867. program, with a username of @var{user}. If the username is omitted
  4868. (along with the @samp{@@} sign), then your user name will be used.
  4869. (This is the normal @command{rsh} behavior.) It is necessary for the
  4870. remote machine, in addition to permitting your @command{rsh} access, to
  4871. have the @file{rmt} program installed (This command is included in
  4872. the @GNUTAR{} distribution and by default is installed under
  4873. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4874. installation prefix). If you need to use a file whose name includes a
  4875. colon, then the remote tape drive behavior
  4876. can be inhibited by using the @option{--force-local} option.
  4877. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4878. tries to minimize input and output operations. The Amanda backup
  4879. system, when used with @GNUTAR{}, has an initial sizing pass which
  4880. uses this feature.
  4881. @node Selecting Archive Members
  4882. @section Selecting Archive Members
  4883. @cindex Specifying files to act on
  4884. @cindex Specifying archive members
  4885. @dfn{File Name arguments} specify which files in the file system
  4886. @command{tar} operates on, when creating or adding to an archive, or which
  4887. archive members @command{tar} operates on, when reading or deleting from
  4888. an archive. @xref{Operations}.
  4889. To specify file names, you can include them as the last arguments on
  4890. the command line, as follows:
  4891. @smallexample
  4892. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4893. @end smallexample
  4894. If a file name begins with dash (@samp{-}), precede it with
  4895. @option{--add-file} option to prevent it from being treated as an
  4896. option.
  4897. If you specify a directory name as a file name argument, all the files
  4898. in that directory are operated on by @command{tar}.
  4899. If you do not specify files, @command{tar} behavior differs depending
  4900. on the operation mode as described below:
  4901. When @command{tar} is invoked with @option{--create} (@option{-c}),
  4902. @command{tar} will stop immediately, reporting the following:
  4903. @smallexample
  4904. @group
  4905. $ @kbd{tar cf a.tar}
  4906. tar: Cowardly refusing to create an empty archive
  4907. Try `tar --help' or `tar --usage' for more information.
  4908. @end group
  4909. @end smallexample
  4910. If you specify either @option{--list} (@option{-t}) or
  4911. @option{--extract} (@option{--get}, @option{-x}), @command{tar}
  4912. operates on all the archive members in the archive.
  4913. If run with @option{--diff} option, tar will compare the archive with
  4914. the contents of the current working directory.
  4915. If you specify any other operation, @command{tar} does nothing.
  4916. By default, @command{tar} takes file names from the command line. However,
  4917. there are other ways to specify file or member names, or to modify the
  4918. manner in which @command{tar} selects the files or members upon which to
  4919. operate. In general, these methods work both for specifying the names
  4920. of files and archive members.
  4921. @node files
  4922. @section Reading Names from a File
  4923. @cindex Reading file names from a file
  4924. @cindex Lists of file names
  4925. @cindex File Name arguments, alternatives
  4926. Instead of giving the names of files or archive members on the command
  4927. line, you can put the names into a file, and then use the
  4928. @option{--files-from=@var{file-of-names}} (@option{-T
  4929. @var{file-of-names}}) option to @command{tar}. Give the name of the
  4930. file which contains the list of files to include as the argument to
  4931. @option{--files-from}. In the list, the file names should be separated by
  4932. newlines. You will frequently use this option when you have generated
  4933. the list of files to archive with the @command{find} utility.
  4934. @table @option
  4935. @opindex files-from
  4936. @item --files-from=@var{file-name}
  4937. @itemx -T @var{file-name}
  4938. Get names to extract or create from file @var{file-name}.
  4939. @end table
  4940. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  4941. you specify either @code{--files-from=-} or @code{-T -}), then the file
  4942. names are read from standard input.
  4943. Unless you are running @command{tar} with @option{--create}, you can not use
  4944. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  4945. command.
  4946. Any number of @option{-T} options can be given in the command line.
  4947. The following example shows how to use @command{find} to generate a list of
  4948. files smaller than 400K in length and put that list into a file
  4949. called @file{small-files}. You can then use the @option{-T} option to
  4950. @command{tar} to specify the files from that file, @file{small-files}, to
  4951. create the archive @file{little.tgz}. (The @option{-z} option to
  4952. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4953. more information.)
  4954. @smallexample
  4955. $ @kbd{find . -size -400 -print > small-files}
  4956. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4957. @end smallexample
  4958. @noindent
  4959. In the file list given by @option{-T} option, any file name beginning
  4960. with @samp{-} character is considered a @command{tar} option and is
  4961. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  4962. recognized only @option{-C} option in file lists, and only if the
  4963. option and its argument occupied two consecutive lines.} For example,
  4964. the common use of this feature is to change to another directory by
  4965. specifying @option{-C} option:
  4966. @smallexample
  4967. @group
  4968. $ @kbd{cat list}
  4969. -C/etc
  4970. passwd
  4971. hosts
  4972. -C/lib
  4973. libc.a
  4974. $ @kbd{tar -c -f foo.tar --files-from list}
  4975. @end group
  4976. @end smallexample
  4977. @noindent
  4978. In this example, @command{tar} will first switch to @file{/etc}
  4979. directory and add files @file{passwd} and @file{hosts} to the
  4980. archive. Then it will change to @file{/lib} directory and will archive
  4981. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  4982. contain:
  4983. @smallexample
  4984. @group
  4985. $ @kbd{tar tf foo.tar}
  4986. passwd
  4987. hosts
  4988. libc.a
  4989. @end group
  4990. @end smallexample
  4991. @noindent
  4992. @opindex directory, using in @option{--files-from} argument
  4993. Notice that the option parsing algorithm used with @option{-T} is
  4994. stricter than the one used by shell. Namely, when specifying option
  4995. arguments, you should observe the following rules:
  4996. @itemize @bullet
  4997. @item
  4998. When using short (single-letter) option form, its argument must
  4999. immediately follow the option letter, without any intervening
  5000. whitespace. For example: @code{-Cdir}.
  5001. @item
  5002. When using long option form, the option argument must be separated
  5003. from the option by a single equal sign. No whitespace is allowed on
  5004. any side of the equal sign. For example: @code{--directory=dir}.
  5005. @item
  5006. For both short and long option forms, the option argument can be given
  5007. on the next line after the option name, e.g.:
  5008. @smallexample
  5009. @group
  5010. --directory
  5011. dir
  5012. @end group
  5013. @end smallexample
  5014. @noindent
  5015. and
  5016. @smallexample
  5017. @group
  5018. -C
  5019. dir
  5020. @end group
  5021. @end smallexample
  5022. @end itemize
  5023. @opindex add-file
  5024. If you happen to have a file whose name starts with @samp{-},
  5025. precede it with @option{--add-file} option to prevent it from
  5026. being recognized as an option. For example: @code{--add-file=--my-file}.
  5027. @menu
  5028. * nul::
  5029. @end menu
  5030. @node nul
  5031. @subsection @code{NUL} Terminated File Names
  5032. @cindex File names, terminated by @code{NUL}
  5033. @cindex @code{NUL} terminated file names
  5034. The @option{--null} option causes
  5035. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}})
  5036. to read file names terminated by a @code{NUL} instead of a newline, so
  5037. files whose names contain newlines can be archived using
  5038. @option{--files-from}.
  5039. @table @option
  5040. @opindex null
  5041. @item --null
  5042. Only consider @code{NUL} terminated file names, instead of files that
  5043. terminate in a newline.
  5044. @end table
  5045. The @option{--null} option is just like the one in @acronym{GNU}
  5046. @command{xargs} and @command{cpio}, and is useful with the
  5047. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  5048. @command{tar}, @option{--null} also disables special handling for
  5049. file names that begin with dash.
  5050. This example shows how to use @command{find} to generate a list of files
  5051. larger than 800K in length and put that list into a file called
  5052. @file{long-files}. The @option{-print0} option to @command{find} is just
  5053. like @option{-print}, except that it separates files with a @code{NUL}
  5054. rather than with a newline. You can then run @command{tar} with both the
  5055. @option{--null} and @option{-T} options to specify that @command{tar} get the
  5056. files from that file, @file{long-files}, to create the archive
  5057. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  5058. @command{tar} to recognize the @code{NUL} separator between files.
  5059. @smallexample
  5060. $ @kbd{find . -size +800 -print0 > long-files}
  5061. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  5062. @end smallexample
  5063. @FIXME{say anything else here to conclude the section?}
  5064. @node exclude
  5065. @section Excluding Some Files
  5066. @UNREVISED
  5067. @cindex File names, excluding files by
  5068. @cindex Excluding files by name and pattern
  5069. @cindex Excluding files by file system
  5070. To avoid operating on files whose names match a particular pattern,
  5071. use the @option{--exclude} or @option{--exclude-from} options.
  5072. @table @option
  5073. @opindex exclude
  5074. @item --exclude=@var{pattern}
  5075. Causes @command{tar} to ignore files that match the @var{pattern}.
  5076. @end table
  5077. @findex exclude
  5078. The @option{--exclude=@var{pattern}} option prevents any file or
  5079. member whose name matches the shell wildcard (@var{pattern}) from
  5080. being operated on.
  5081. For example, to create an archive with all the contents of the directory
  5082. @file{src} except for files whose names end in @file{.o}, use the
  5083. command @samp{tar -cf src.tar --exclude='*.o' src}.
  5084. You may give multiple @option{--exclude} options.
  5085. @table @option
  5086. @opindex exclude-from
  5087. @item --exclude-from=@var{file}
  5088. @itemx -X @var{file}
  5089. Causes @command{tar} to ignore files that match the patterns listed in
  5090. @var{file}.
  5091. @end table
  5092. @findex exclude-from
  5093. Use the @option{--exclude-from} option to read a
  5094. list of patterns, one per line, from @var{file}; @command{tar} will
  5095. ignore files matching those patterns. Thus if @command{tar} is
  5096. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  5097. single line @file{*.o}, no files whose names end in @file{.o} will be
  5098. added to the archive.
  5099. @table @option
  5100. @opindex exclude-caches
  5101. @item --exclude-caches
  5102. Causes @command{tar} to ignore directories containing a cache directory tag.
  5103. @end table
  5104. @findex exclude-caches
  5105. When creating an archive, the @option{--exclude-caches} option causes
  5106. @command{tar} to exclude all directories that contain a @dfn{cache
  5107. directory tag}. A cache directory tag is a short file with the
  5108. well-known name @file{CACHEDIR.TAG} and having a standard header
  5109. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5110. Various applications write cache directory tags into directories they
  5111. use to hold regenerable, non-precious data, so that such data can be
  5112. more easily excluded from backups.
  5113. @menu
  5114. * problems with exclude::
  5115. @end menu
  5116. @node problems with exclude
  5117. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5118. @opindex exclude, potential problems with
  5119. Some users find @samp{exclude} options confusing. Here are some common
  5120. pitfalls:
  5121. @itemize @bullet
  5122. @item
  5123. The main operating mode of @command{tar} does not act on a path name
  5124. explicitly listed on the command line if one of its file name
  5125. components is excluded. In the example above, if
  5126. you create an archive and exclude files that end with @samp{*.o}, but
  5127. explicitly name the file @samp{dir.o/foo} after all the options have been
  5128. listed, @samp{dir.o/foo} will be excluded from the archive.
  5129. @item
  5130. You can sometimes confuse the meanings of @option{--exclude} and
  5131. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5132. to be excluded are given as a pattern on the command line. Use
  5133. @option{--exclude-from} to introduce the name of a file which contains
  5134. a list of patterns, one per line; each of these patterns can exclude
  5135. zero, one, or many files.
  5136. @item
  5137. When you use @option{--exclude=@var{pattern}}, be sure to quote the
  5138. @var{pattern} parameter, so @GNUTAR{} sees wildcard characters
  5139. like @samp{*}. If you do not do this, the shell might expand the
  5140. @samp{*} itself using files at hand, so @command{tar} might receive a
  5141. list of files instead of one pattern, or none at all, making the
  5142. command somewhat illegal. This might not correspond to what you want.
  5143. For example, write:
  5144. @smallexample
  5145. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5146. @end smallexample
  5147. @noindent
  5148. rather than:
  5149. @smallexample
  5150. # @emph{Wrong!}
  5151. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5152. @end smallexample
  5153. @item
  5154. You must use use shell syntax, or globbing, rather than @code{regexp}
  5155. syntax, when using exclude options in @command{tar}. If you try to use
  5156. @code{regexp} syntax to describe files to be excluded, your command
  5157. might fail.
  5158. @item
  5159. @FIXME{The change in semantics must have occurred before 1.11,
  5160. so I doubt if it is worth mentioning at all. Anyway, should at
  5161. least specify in which version the semantics changed.}
  5162. In earlier versions of @command{tar}, what is now the
  5163. @option{--exclude-from} option was called @option{--exclude} instead.
  5164. Now, @option{--exclude} applies to patterns listed on the command
  5165. line and @option{--exclude-from} applies to patterns listed in a
  5166. file.
  5167. @end itemize
  5168. @node Wildcards
  5169. @section Wildcards Patterns and Matching
  5170. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5171. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5172. existing files matching the given pattern. @GNUTAR{} can use wildcard
  5173. patterns for matching (or globbing) archive members when extracting
  5174. from or listing an archive. Wildcard patterns are also used for
  5175. verifying volume labels of @command{tar} archives. This section has the
  5176. purpose of explaining wildcard syntax for @command{tar}.
  5177. @FIXME{the next few paragraphs need work.}
  5178. A @var{pattern} should be written according to shell syntax, using wildcard
  5179. characters to effect globbing. Most characters in the pattern stand
  5180. for themselves in the matched string, and case is significant: @samp{a}
  5181. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5182. pattern matches any single character in the matched string. The character
  5183. @samp{*} in the pattern matches zero, one, or more single characters in
  5184. the matched string. The character @samp{\} says to take the following
  5185. character of the pattern @emph{literally}; it is useful when one needs to
  5186. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5187. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5188. class. A @dfn{character class} is a list of acceptable characters
  5189. for the next single character of the matched string. For example,
  5190. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5191. Note that within a character class, all of the ``special characters''
  5192. listed above other than @samp{\} lose their special meaning; for example,
  5193. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5194. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5195. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5196. @emph{last} in a character class.)
  5197. @cindex Excluding characters from a character class
  5198. @cindex Character class, excluding characters from
  5199. If the first character of the class after the opening @samp{[}
  5200. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5201. Rather than listing character to match, it lists those characters which
  5202. are @emph{forbidden} as the next single character of the matched string.
  5203. Other characters of the class stand for themselves. The special
  5204. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5205. letters, is meant to represent all characters between @var{a} and
  5206. @var{e}, inclusive.
  5207. @FIXME{need to add a sentence or so here to make this clear for those
  5208. who don't have dan around.}
  5209. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5210. special for wildcard matches. However, if a pattern completely matches
  5211. a directory prefix of a matched string, then it matches the full matched
  5212. string: thus, excluding a directory also excludes all the files beneath it.
  5213. @menu
  5214. * controlling pattern-matching::
  5215. @end menu
  5216. @node controlling pattern-matching
  5217. @unnumberedsubsec Controlling Pattern-Matching
  5218. For the purposes of this section, we call @dfn{exclusion members} all
  5219. member names obtained while processing @option{--exclude} and
  5220. @option{--exclude-from} options, and @dfn{inclusion members} those
  5221. member names that were given in the command line or read from the file
  5222. specified with @option{--files-from} option.
  5223. These two pairs of member lists are used in the following operations:
  5224. @option{--diff}, @option{--extract}, @option{--list},
  5225. @option{--update}.
  5226. There are no inclusion members in create mode (@option{--create} and
  5227. @option{--append}), since in this mode the names obtained from the
  5228. command line refer to @emph{files}, not archive members.
  5229. By default, inclusion members are compared with archive members
  5230. literally @footnote{Notice that earlier @GNUTAR{} versions used
  5231. globbing for inclusion members, which contradicted to UNIX98
  5232. specification and was not documented. @xref{Changes}, for more
  5233. information on this and other changes} and exclusion members are
  5234. treated as globbing patterns. For example:
  5235. @smallexample
  5236. @group
  5237. $ @kbd{tar tf foo.tar}
  5238. a.c
  5239. b.c
  5240. a.txt
  5241. [remarks]
  5242. # @i{Member names are used verbatim:}
  5243. $ @kbd{tar -xf foo.tar -v '[remarks]'}
  5244. [remarks]
  5245. # @i{Exclude member names are globbed:}
  5246. $ @kbd{tar -xf foo.tar -v --exclude '*.c'}
  5247. a.txt
  5248. [remarks]
  5249. @end group
  5250. @end smallexample
  5251. This behavior can be altered by using the following options:
  5252. @table @option
  5253. @opindex wildcards
  5254. @item --wildcards
  5255. Treat all member names as wildcards.
  5256. @opindex no-wildcards
  5257. @item --no-wildcards
  5258. Treat all member names as literal strings.
  5259. @end table
  5260. Thus, to extract files whose names end in @samp{.c}, you can use:
  5261. @smallexample
  5262. $ @kbd{tar -xf foo.tar -v --wildcards '*.c'}
  5263. a.c
  5264. b.c
  5265. @end smallexample
  5266. @noindent
  5267. Notice quoting of the pattern to prevent the shell from interpreting
  5268. it.
  5269. The effect of @option{--wildcards} option is cancelled by
  5270. @option{--no-wildcards}. This can be used to pass part of
  5271. the command line arguments verbatim and other part as globbing
  5272. patterns. For example, the following invocation:
  5273. @smallexample
  5274. $ @kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
  5275. @end smallexample
  5276. @noindent
  5277. instructs @command{tar} to extract from @file{foo.tar} all files whose
  5278. names end in @samp{.txt} and the file named @file{[remarks]}.
  5279. Normally, a pattern matches a name if an initial subsequence of the
  5280. name's components matches the pattern, where @samp{*}, @samp{?}, and
  5281. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  5282. and wildcards can match @samp{/}.
  5283. Other than optionally stripping leading @samp{/} from names
  5284. (@pxref{absolute}), patterns and names are used as-is. For
  5285. example, trailing @samp{/} is not trimmed from a user-specified name
  5286. before deciding whether to exclude it.
  5287. However, this matching procedure can be altered by the options listed
  5288. below. These options accumulate. For example:
  5289. @smallexample
  5290. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  5291. @end smallexample
  5292. ignores case when excluding @samp{makefile}, but not when excluding
  5293. @samp{readme}.
  5294. @table @option
  5295. @opindex anchored
  5296. @opindex no-anchored
  5297. @item --anchored
  5298. @itemx --no-anchored
  5299. If anchored, a pattern must match an initial subsequence
  5300. of the name's components. Otherwise, the pattern can match any
  5301. subsequence. Default is @option{--no-anchored} for exclusion members
  5302. and @option{--anchored} inclusion members.
  5303. @opindex ignore-case
  5304. @opindex no-ignore-case
  5305. @item --ignore-case
  5306. @itemx --no-ignore-case
  5307. When ignoring case, upper-case patterns match lower-case names and vice versa.
  5308. When not ignoring case (the default), matching is case-sensitive.
  5309. @opindex wildcards-match-slash
  5310. @opindex no-wildcards-match-slash
  5311. @item --wildcards-match-slash
  5312. @itemx --no-wildcards-match-slash
  5313. When wildcards match slash (the default for exclusion members), a
  5314. wildcard like @samp{*} in the pattern can match a @samp{/} in the
  5315. name. Otherwise, @samp{/} is matched only by @samp{/}.
  5316. @end table
  5317. The @option{--recursion} and @option{--no-recursion} options
  5318. (@pxref{recurse}) also affect how member patterns are interpreted. If
  5319. recursion is in effect, a pattern matches a name if it matches any of
  5320. the name's parent directories.
  5321. The following table summarizes pattern-matching default values:
  5322. @multitable @columnfractions .3 .7
  5323. @headitem Members @tab Default settings
  5324. @item Inclusion @tab @option{--no-wildcards --anchored --no-wildcards-match-slash}
  5325. @item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
  5326. @end multitable
  5327. @node after
  5328. @section Operating Only on New Files
  5329. @UNREVISED
  5330. @cindex Excluding file by age
  5331. @cindex Data Modification time, excluding files by
  5332. @cindex Modification time, excluding files by
  5333. @cindex Age, excluding files by
  5334. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5335. @option{-N @var{date}}) option causes @command{tar} to only work on
  5336. files whose data modification or status change times are newer than
  5337. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5338. it is taken to be a file name; the data modification time of that file
  5339. is used as the date. If you use this option when creating or appending
  5340. to an archive, the archive will only include new files. If you use
  5341. @option{--after-date} when extracting an archive, @command{tar} will
  5342. only extract files newer than the @var{date} you specify.
  5343. If you only want @command{tar} to make the date comparison based on
  5344. modification of the file's data (rather than status
  5345. changes), then use the @option{--newer-mtime=@var{date}} option.
  5346. You may use these options with any operation. Note that these options
  5347. differ from the @option{--update} (@option{-u}) operation in that they
  5348. allow you to specify a particular date against which @command{tar} can
  5349. compare when deciding whether or not to archive the files.
  5350. @table @option
  5351. @opindex after-date
  5352. @opindex newer
  5353. @item --after-date=@var{date}
  5354. @itemx --newer=@var{date}
  5355. @itemx -N @var{date}
  5356. Only store files newer than @var{date}.
  5357. Acts on files only if their data modification or status change times are
  5358. later than @var{date}. Use in conjunction with any operation.
  5359. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5360. name; the data modification time of that file is used as the date.
  5361. @opindex newer-mtime
  5362. @item --newer-mtime=@var{date}
  5363. Acts like @option{--after-date}, but only looks at data modification times.
  5364. @end table
  5365. These options limit @command{tar} to operate only on files which have
  5366. been modified after the date specified. A file's status is considered to have
  5367. changed if its contents have been modified, or if its owner,
  5368. permissions, and so forth, have been changed. (For more information on
  5369. how to specify a date, see @ref{Date input formats}; remember that the
  5370. entire date argument must be quoted if it contains any spaces.)
  5371. Gurus would say that @option{--after-date} tests both the data
  5372. modification time (@code{mtime}, the time the contents of the file
  5373. were last modified) and the status change time (@code{ctime}, the time
  5374. the file's status was last changed: owner, permissions, etc.@:)
  5375. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5376. field.
  5377. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5378. @code{ctime} and processes the file if either one is more recent than
  5379. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5380. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5381. contents of the file were looked at).
  5382. Date specifiers can have embedded spaces. Because of this, you may need
  5383. to quote date arguments to keep the shell from parsing them as separate
  5384. arguments. For example, the following command will add to the archive
  5385. all the files modified less than two days ago:
  5386. @smallexample
  5387. $ @kbd{tar -cf foo.tar --newer-mtime '2 days ago'}
  5388. @end smallexample
  5389. @quotation
  5390. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5391. should not be used for incremental backups. @xref{Incremental Dumps},
  5392. for proper way of creating incremental backups.
  5393. @end quotation
  5394. @node recurse
  5395. @section Descending into Directories
  5396. @UNREVISED
  5397. @cindex Avoiding recursion in directories
  5398. @cindex Descending directories, avoiding
  5399. @cindex Directories, avoiding recursion
  5400. @cindex Recursion in directories, avoiding
  5401. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5402. Usually, @command{tar} will recursively explore all directories (either
  5403. those given on the command line or through the @option{--files-from}
  5404. option) for the various files they contain. However, you may not always
  5405. want @command{tar} to act this way.
  5406. @opindex no-recursion
  5407. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5408. into specified directories. If you specify @option{--no-recursion}, you can
  5409. use the @command{find} utility for hunting through levels of directories to
  5410. construct a list of file names which you could then pass to @command{tar}.
  5411. @command{find} allows you to be more selective when choosing which files to
  5412. archive; see @ref{files}, for more information on using @command{find} with
  5413. @command{tar}, or look.
  5414. @table @option
  5415. @item --no-recursion
  5416. Prevents @command{tar} from recursively descending directories.
  5417. @opindex recursion
  5418. @item --recursion
  5419. Requires @command{tar} to recursively descend directories.
  5420. This is the default.
  5421. @end table
  5422. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5423. directory entries themselves, but does not descend on them
  5424. recursively. Many people use @command{find} for locating files they
  5425. want to back up, and since @command{tar} @emph{usually} recursively
  5426. descends on directories, they have to use the @samp{@w{-not -type d}}
  5427. test in their @command{find} invocation (@pxref{Type, Type, Type test,
  5428. find, Finding Files}), as they usually do not want all the files in a
  5429. directory. They then use the @option{--files-from} option to archive
  5430. the files located via @command{find}.
  5431. The problem when restoring files archived in this manner is that the
  5432. directories themselves are not in the archive; so the
  5433. @option{--same-permissions} (@option{--preserve-permissions},
  5434. @option{-p}) option does not affect them---while users might really
  5435. like it to. Specifying @option{--no-recursion} is a way to tell
  5436. @command{tar} to grab only the directory entries given to it, adding
  5437. no new files on its own. To summarize, if you use @command{find} to
  5438. create a list of files to be stored in an archive, use it as follows:
  5439. @smallexample
  5440. @group
  5441. $ @kbd{find @var{dir} @var{tests} | \
  5442. tar -cf @var{archive} -T - --no-recursion}
  5443. @end group
  5444. @end smallexample
  5445. The @option{--no-recursion} option also applies when extracting: it
  5446. causes @command{tar} to extract only the matched directory entries, not
  5447. the files under those directories.
  5448. The @option{--no-recursion} option also affects how globbing patterns
  5449. are interpreted (@pxref{controlling pattern-matching}).
  5450. The @option{--no-recursion} and @option{--recursion} options apply to
  5451. later options and operands, and can be overridden by later occurrences
  5452. of @option{--no-recursion} and @option{--recursion}. For example:
  5453. @smallexample
  5454. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5455. @end smallexample
  5456. @noindent
  5457. creates an archive with one entry for @file{grape}, and the recursive
  5458. contents of @file{grape/concord}, but no entries under @file{grape}
  5459. other than @file{grape/concord}.
  5460. @node one
  5461. @section Crossing File System Boundaries
  5462. @cindex File system boundaries, not crossing
  5463. @UNREVISED
  5464. @command{tar} will normally automatically cross file system boundaries in
  5465. order to archive files which are part of a directory tree. You can
  5466. change this behavior by running @command{tar} and specifying
  5467. @option{--one-file-system}. This option only affects files that are
  5468. archived because they are in a directory that is being archived;
  5469. @command{tar} will still archive files explicitly named on the command line
  5470. or through @option{--files-from}, regardless of where they reside.
  5471. @table @option
  5472. @opindex one-file-system
  5473. @item --one-file-system
  5474. Prevents @command{tar} from crossing file system boundaries when
  5475. archiving. Use in conjunction with any write operation.
  5476. @end table
  5477. The @option{--one-file-system} option causes @command{tar} to modify its
  5478. normal behavior in archiving the contents of directories. If a file in
  5479. a directory is not on the same file system as the directory itself, then
  5480. @command{tar} will not archive that file. If the file is a directory
  5481. itself, @command{tar} will not archive anything beneath it; in other words,
  5482. @command{tar} will not cross mount points.
  5483. This option is useful for making full or incremental archival backups of
  5484. a file system. If this option is used in conjunction with
  5485. @option{--verbose} (@option{-v}), files that are excluded are
  5486. mentioned by name on the standard error.
  5487. @menu
  5488. * directory:: Changing Directory
  5489. * absolute:: Absolute File Names
  5490. @end menu
  5491. @node directory
  5492. @subsection Changing the Working Directory
  5493. @UNREVISED
  5494. @FIXME{need to read over this node now for continuity; i've switched
  5495. things around some.}
  5496. @cindex Changing directory mid-stream
  5497. @cindex Directory, changing mid-stream
  5498. @cindex Working directory, specifying
  5499. To change the working directory in the middle of a list of file names,
  5500. either on the command line or in a file specified using
  5501. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5502. This will change the working directory to the specified directory
  5503. after that point in the list.
  5504. @table @option
  5505. @opindex directory
  5506. @item --directory=@var{directory}
  5507. @itemx -C @var{directory}
  5508. Changes the working directory in the middle of a command line.
  5509. @end table
  5510. For example,
  5511. @smallexample
  5512. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5513. @end smallexample
  5514. @noindent
  5515. will place the files @file{grape} and @file{prune} from the current
  5516. directory into the archive @file{jams.tar}, followed by the file
  5517. @file{cherry} from the directory @file{food}. This option is especially
  5518. useful when you have several widely separated files that you want to
  5519. store in the same archive.
  5520. Note that the file @file{cherry} is recorded in the archive under the
  5521. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5522. archive will contain three files that all appear to have come from the
  5523. same directory; if the archive is extracted with plain @samp{tar
  5524. --extract}, all three files will be written in the current directory.
  5525. Contrast this with the command,
  5526. @smallexample
  5527. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5528. @end smallexample
  5529. @noindent
  5530. which records the third file in the archive under the name
  5531. @file{red/cherry} so that, if the archive is extracted using
  5532. @samp{tar --extract}, the third file will be written in a subdirectory
  5533. named @file{orange-colored}.
  5534. You can use the @option{--directory} option to make the archive
  5535. independent of the original name of the directory holding the files.
  5536. The following command places the files @file{/etc/passwd},
  5537. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5538. @file{foo.tar}:
  5539. @smallexample
  5540. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5541. @end smallexample
  5542. @noindent
  5543. However, the names of the archive members will be exactly what they were
  5544. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5545. They will not appear to be related by file name to the original
  5546. directories where those files were located.
  5547. Note that @option{--directory} options are interpreted consecutively. If
  5548. @option{--directory} specifies a relative file name, it is interpreted
  5549. relative to the then current directory, which might not be the same as
  5550. the original current working directory of @command{tar}, due to a previous
  5551. @option{--directory} option.
  5552. When using @option{--files-from} (@pxref{files}), you can put various
  5553. @command{tar} options (including @option{-C}) in the file list. Notice,
  5554. however, that in this case the option and its argument may not be
  5555. separated by whitespace. If you use short option, its argument must
  5556. either follow the option letter immediately, without any intervening
  5557. whitespace, or occupy the next line. Otherwise, if you use long
  5558. option, separate its argument by an equal sign.
  5559. For instance, the file list for the above example will be:
  5560. @smallexample
  5561. @group
  5562. -C
  5563. /etc
  5564. passwd
  5565. hosts
  5566. -C
  5567. /lib
  5568. libc.a
  5569. @end group
  5570. @end smallexample
  5571. @noindent
  5572. To use it, you would invoke @command{tar} as follows:
  5573. @smallexample
  5574. $ @kbd{tar -c -f foo.tar --files-from list}
  5575. @end smallexample
  5576. Notice also that you can only use the short option variant in the file
  5577. list, i.e., always use @option{-C}, not @option{--directory}.
  5578. The interpretation of @option{--directory} is disabled by
  5579. @option{--null} option.
  5580. @node absolute
  5581. @subsection Absolute File Names
  5582. @UNREVISED
  5583. @table @option
  5584. @opindex absolute-names
  5585. @item --absolute-names
  5586. @itemx -P
  5587. Do not strip leading slashes from file names, and permit file names
  5588. containing a @file{..} file name component.
  5589. @end table
  5590. By default, @GNUTAR{} drops a leading @samp{/} on
  5591. input or output, and complains about file names containing a @file{..}
  5592. component. This option turns off this behavior.
  5593. When @command{tar} extracts archive members from an archive, it strips any
  5594. leading slashes (@samp{/}) from the member name. This causes absolute
  5595. member names in the archive to be treated as relative file names. This
  5596. allows you to have such members extracted wherever you want, instead of
  5597. being restricted to extracting the member in the exact directory named
  5598. in the archive. For example, if the archive member has the name
  5599. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5600. really @file{etc/passwd}.
  5601. File names containing @file{..} can cause problems when extracting, so
  5602. @command{tar} normally warns you about such files when creating an
  5603. archive, and rejects attempts to extracts such files.
  5604. Other @command{tar} programs do not do this. As a result, if you
  5605. create an archive whose member names start with a slash, they will be
  5606. difficult for other people with a non-@GNUTAR{}
  5607. program to use. Therefore, @GNUTAR{} also strips
  5608. leading slashes from member names when putting members into the
  5609. archive. For example, if you ask @command{tar} to add the file
  5610. @file{/bin/ls} to an archive, it will do so, but the member name will
  5611. be @file{bin/ls}.@footnote{A side effect of this is that when
  5612. @option{--create} is used with @option{--verbose} the resulting output
  5613. is not, generally speaking, the same as the one you'd get running
  5614. @kbd{tar --list} command. This may be important if you use some
  5615. scripts for comparing both outputs. @xref{listing member and file names},
  5616. for the information on how to handle this case.}
  5617. If you use the @option{--absolute-names} (@option{-P}) option,
  5618. @command{tar} will do none of these transformations.
  5619. To archive or extract files relative to the root directory, specify
  5620. the @option{--absolute-names} (@option{-P}) option.
  5621. Normally, @command{tar} acts on files relative to the working
  5622. directory---ignoring superior directory names when archiving, and
  5623. ignoring leading slashes when extracting.
  5624. When you specify @option{--absolute-names} (@option{-P}),
  5625. @command{tar} stores file names including all superior directory
  5626. names, and preserves leading slashes. If you only invoked
  5627. @command{tar} from the root directory you would never need the
  5628. @option{--absolute-names} option, but using this option
  5629. may be more convenient than switching to root.
  5630. @FIXME{Should be an example in the tutorial/wizardry section using this
  5631. to transfer files between systems.}
  5632. @FIXME{Is write access an issue?}
  5633. @table @option
  5634. @item --absolute-names
  5635. Preserves full file names (including superior directory names) when
  5636. archiving files. Preserves leading slash when extracting files.
  5637. @end table
  5638. @FIXME{this is still horrible; need to talk with dan on monday.}
  5639. @command{tar} prints out a message about removing the @samp{/} from
  5640. file names. This message appears once per @GNUTAR{}
  5641. invocation. It represents something which ought to be told; ignoring
  5642. what it means can cause very serious surprises, later.
  5643. Some people, nevertheless, do not want to see this message. Wanting to
  5644. play really dangerously, one may of course redirect @command{tar} standard
  5645. error to the sink. For example, under @command{sh}:
  5646. @smallexample
  5647. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5648. @end smallexample
  5649. @noindent
  5650. Another solution, both nicer and simpler, would be to change to
  5651. the @file{/} directory first, and then avoid absolute notation.
  5652. For example:
  5653. @smallexample
  5654. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5655. # @i{or}:
  5656. $ @kbd{tar -c -f archive.tar -C / home}
  5657. @end smallexample
  5658. @include getdate.texi
  5659. @node Formats
  5660. @chapter Controlling the Archive Format
  5661. @cindex Tar archive formats
  5662. Due to historical reasons, there are several formats of tar archives.
  5663. All of them are based on the same principles, but have some subtle
  5664. differences that often make them incompatible with each other.
  5665. GNU tar is able to create and handle archives in a variety of formats.
  5666. The most frequently used formats are (in alphabetical order):
  5667. @table @asis
  5668. @item gnu
  5669. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5670. from an early @acronym{POSIX} standard, adding some improvements such as
  5671. sparse file handling and incremental archives. Unfortunately these
  5672. features were implemented in a way incompatible with other archive
  5673. formats.
  5674. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5675. length.
  5676. @item oldgnu
  5677. Format used by @GNUTAR{} of versions prior to 1.12.
  5678. @item v7
  5679. Archive format, compatible with the V7 implementation of tar. This
  5680. format imposes a number of limitations. The most important of them
  5681. are:
  5682. @enumerate
  5683. @item The maximum length of a file name is limited to 99 characters.
  5684. @item The maximum length of a symbolic link is limited to 99 characters.
  5685. @item It is impossible to store special files (block and character
  5686. devices, fifos etc.)
  5687. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5688. octal)
  5689. @item V7 archives do not contain symbolic ownership information (user
  5690. and group name of the file owner).
  5691. @end enumerate
  5692. This format has traditionally been used by Automake when producing
  5693. Makefiles. This practice will change in the future, in the meantime,
  5694. however this means that projects containing filenames more than 99
  5695. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5696. Automake prior to 1.9.
  5697. @item ustar
  5698. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5699. symbolic ownership information. It is also able to store
  5700. special files. However, it imposes several restrictions as well:
  5701. @enumerate
  5702. @item The maximum length of a file name is limited to 256 characters,
  5703. provided that the filename can be split at directory separator in
  5704. two parts, first of them being at most 155 bytes long. So, in most
  5705. cases the maximum file name length will be shorter than 256
  5706. characters.
  5707. @item The maximum length of a symbolic link name is limited to
  5708. 100 characters.
  5709. @item Maximum size of a file the archive is able to accomodate
  5710. is 8GB
  5711. @item Maximum value of UID/GID is 2097151.
  5712. @item Maximum number of bits in device major and minor numbers is 21.
  5713. @end enumerate
  5714. @item star
  5715. Format used by J@"org Schilling @command{star}
  5716. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5717. currently does not produce them.
  5718. @item posix
  5719. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5720. most flexible and feature-rich format. It does not impose any
  5721. restrictions on file sizes or filename lengths. This format is quite
  5722. recent, so not all tar implementations are able to handle it properly.
  5723. However, this format is designed in such a way that any tar
  5724. implementation able to read @samp{ustar} archives will be able to read
  5725. most @samp{posix} archives as well, with the only exception that any
  5726. additional information (such as long file names etc.) will in such
  5727. case be extracted as plain text files along with the files it refers to.
  5728. This archive format will be the default format for future versions
  5729. of @GNUTAR{}.
  5730. @end table
  5731. The following table summarizes the limitations of each of these
  5732. formats:
  5733. @multitable @columnfractions .10 .20 .20 .20 .20
  5734. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  5735. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5736. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5737. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5738. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5739. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5740. @end multitable
  5741. The default format for @GNUTAR{} is defined at compilation
  5742. time. You may check it by running @command{tar --help}, and examining
  5743. the last lines of its output. Usually, @GNUTAR{} is configured
  5744. to create archives in @samp{gnu} format, however, future version will
  5745. switch to @samp{posix}.
  5746. @menu
  5747. * Portability:: Making @command{tar} Archives More Portable
  5748. * Compression:: Using Less Space through Compression
  5749. * Attributes:: Handling File Attributes
  5750. * Standard:: The Standard Format
  5751. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5752. * cpio:: Comparison of @command{tar} and @command{cpio}
  5753. @end menu
  5754. @node Portability
  5755. @section Making @command{tar} Archives More Portable
  5756. Creating a @command{tar} archive on a particular system that is meant to be
  5757. useful later on many other machines and with other versions of @command{tar}
  5758. is more challenging than you might think. @command{tar} archive formats
  5759. have been evolving since the first versions of Unix. Many such formats
  5760. are around, and are not always compatible with each other. This section
  5761. discusses a few problems, and gives some advice about making @command{tar}
  5762. archives more portable.
  5763. One golden rule is simplicity. For example, limit your @command{tar}
  5764. archives to contain only regular files and directories, avoiding
  5765. other kind of special files. Do not attempt to save sparse files or
  5766. contiguous files as such. Let's discuss a few more problems, in turn.
  5767. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  5768. archives and archive labels) in GNU and PAX formats.}
  5769. @menu
  5770. * Portable Names:: Portable Names
  5771. * dereference:: Symbolic Links
  5772. * old:: Old V7 Archives
  5773. * ustar:: Ustar Archives
  5774. * gnu:: GNU and old GNU format archives.
  5775. * posix:: @acronym{POSIX} archives
  5776. * Checksumming:: Checksumming Problems
  5777. * Large or Negative Values:: Large files, negative time stamps, etc.
  5778. @end menu
  5779. @node Portable Names
  5780. @subsection Portable Names
  5781. Use portable file and member names. A name is portable if it contains
  5782. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5783. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5784. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5785. old Unix hosts, limit your file name components to 14 characters or
  5786. less.
  5787. If you intend to have your @command{tar} archives to be read under
  5788. MSDOS, you should not rely on case distinction for file names, and you
  5789. might use the @acronym{GNU} @command{doschk} program for helping you
  5790. further diagnosing illegal MSDOS names, which are even more limited
  5791. than System V's.
  5792. @node dereference
  5793. @subsection Symbolic Links
  5794. @cindex File names, using symbolic links
  5795. @cindex Symbolic link as file name
  5796. @opindex dereference
  5797. Normally, when @command{tar} archives a symbolic link, it writes a
  5798. block to the archive naming the target of the link. In that way, the
  5799. @command{tar} archive is a faithful record of the file system contents.
  5800. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  5801. @command{tar} to archive the files symbolic links point to, instead of
  5802. the links themselves. When this option is used, when @command{tar}
  5803. encounters a symbolic link, it will archive the linked-to file,
  5804. instead of simply recording the presence of a symbolic link.
  5805. The name under which the file is stored in the file system is not
  5806. recorded in the archive. To record both the symbolic link name and
  5807. the file name in the system, archive the file under both names. If
  5808. all links were recorded automatically by @command{tar}, an extracted file
  5809. might be linked to a file name that no longer exists in the file
  5810. system.
  5811. If a linked-to file is encountered again by @command{tar} while creating
  5812. the same archive, an entire second copy of it will be stored. (This
  5813. @emph{might} be considered a bug.)
  5814. So, for portable archives, do not archive symbolic links as such,
  5815. and use @option{--dereference} (@option{-h}): many systems do not support
  5816. symbolic links, and moreover, your distribution might be unusable if
  5817. it contains unresolved symbolic links.
  5818. @node old
  5819. @subsection Old V7 Archives
  5820. @cindex Format, old style
  5821. @cindex Old style format
  5822. @cindex Old style archives
  5823. @cindex v7 archive format
  5824. Certain old versions of @command{tar} cannot handle additional
  5825. information recorded by newer @command{tar} programs. To create an
  5826. archive in V7 format (not ANSI), which can be read by these old
  5827. versions, specify the @option{--format=v7} option in
  5828. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  5829. accepts @option{--portability} or @samp{op-old-archive} for this
  5830. option). When you specify it,
  5831. @command{tar} leaves out information about directories, pipes, fifos,
  5832. contiguous files, and device files, and specifies file ownership by
  5833. group and user IDs instead of group and user names.
  5834. When updating an archive, do not use @option{--format=v7}
  5835. unless the archive was created using this option.
  5836. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5837. @command{tar} program without serious trouble, so this option should
  5838. seldom be needed. On the other hand, most modern @command{tar}s are
  5839. able to read old format archives, so it might be safer for you to
  5840. always use @option{--format=v7} for your distributions.
  5841. @node ustar
  5842. @subsection Ustar Archive Format
  5843. @cindex ustar archive format
  5844. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5845. @code{ustar}. Although it is more flexible than the V7 format, it
  5846. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5847. description of @code{ustar} format). Along with V7 format,
  5848. @code{ustar} format is a good choice for archives intended to be read
  5849. with other implementations of @command{tar}.
  5850. To create archive in @code{ustar} format, use @option{--format=ustar}
  5851. option in conjunction with the @option{--create} (@option{-c}).
  5852. @node gnu
  5853. @subsection @acronym{GNU} and old @GNUTAR{} format
  5854. @cindex GNU archive format
  5855. @cindex Old GNU archive format
  5856. @GNUTAR{} was based on an early draft of the
  5857. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5858. @command{tar}, such as the support for file names longer than 100
  5859. characters, use portions of the @command{tar} header record which were
  5860. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  5861. @acronym{POSIX} have allocated the same parts of the header record for
  5862. other purposes. As a result, @GNUTAR{} format is
  5863. incompatible with the current @acronym{POSIX} specification, and with
  5864. @command{tar} programs that follow it.
  5865. In the majority of cases, @command{tar} will be configured to create
  5866. this format by default. This will change in the future releases, since
  5867. we plan to make @samp{posix} format the default.
  5868. To force creation a @GNUTAR{} archive, use option
  5869. @option{--format=gnu}.
  5870. @node posix
  5871. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  5872. @cindex POSIX archive format
  5873. @cindex PAX archive format
  5874. The version @value{VERSION} of @GNUTAR{} is able
  5875. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  5876. A @acronym{POSIX} conformant archive will be created if @command{tar}
  5877. was given @option{--format=posix} option.
  5878. @node Checksumming
  5879. @subsection Checksumming Problems
  5880. SunOS and HP-UX @command{tar} fail to accept archives created using
  5881. @GNUTAR{} and containing non-ASCII file names, that
  5882. is, file names having characters with the eight bit set, because they
  5883. use signed checksums, while @GNUTAR{} uses unsigned
  5884. checksums while creating archives, as per @acronym{POSIX} standards. On
  5885. reading, @GNUTAR{} computes both checksums and
  5886. accept any. It is somewhat worrying that a lot of people may go
  5887. around doing backup of their files using faulty (or at least
  5888. non-standard) software, not learning about it until it's time to
  5889. restore their missing files with an incompatible file extractor, or
  5890. vice versa.
  5891. @GNUTAR{} compute checksums both ways, and accept
  5892. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5893. wrong checksums. @GNUTAR{} produces the standard
  5894. checksum, however, raising incompatibilities with Sun. That is to
  5895. say, @GNUTAR{} has not been modified to
  5896. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5897. I've been told that more recent Sun @command{tar} now read standard
  5898. archives, so maybe Sun did a similar patch, after all?
  5899. The story seems to be that when Sun first imported @command{tar}
  5900. sources on their system, they recompiled it without realizing that
  5901. the checksums were computed differently, because of a change in
  5902. the default signing of @code{char}'s in their compiler. So they
  5903. started computing checksums wrongly. When they later realized their
  5904. mistake, they merely decided to stay compatible with it, and with
  5905. themselves afterwards. Presumably, but I do not really know, HP-UX
  5906. has chosen that their @command{tar} archives to be compatible with Sun's.
  5907. The current standards do not favor Sun @command{tar} format. In any
  5908. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5909. a @command{tar} able to read the good archives they receive.
  5910. @node Large or Negative Values
  5911. @subsection Large or Negative Values
  5912. @cindex large values
  5913. @cindex future time stamps
  5914. @cindex negative time stamps
  5915. @UNREVISED{}
  5916. The above sections suggest to use @samp{oldest possible} archive
  5917. format if in doubt. However, sometimes it is not possible. If you
  5918. attempt to archive a file whose metadata cannot be represented using
  5919. required format, @GNUTAR{} will print error message and ignore such a
  5920. file. You will than have to switch to a format that is able to
  5921. handle such values. The format summary table (@pxref{Formats}) will
  5922. help you to do so.
  5923. In particular, when trying to archive files larger than 8GB or with
  5924. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  5925. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  5926. @acronym{POSIX} archive formats. When considering which format to
  5927. choose, bear in mind that the @acronym{GNU} format uses
  5928. two's-complement base-256 notation to store values that do not fit
  5929. into standard @acronym{ustar} range. Such archives can generally be
  5930. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  5931. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  5932. example, using two's complement representation for negative time
  5933. stamps that assumes a signed 32-bit @code{time_t} generates archives
  5934. that are not portable to hosts with differing @code{time_t}
  5935. representations.
  5936. On the other hand, @acronym{POSIX} archives, generally speaking, can
  5937. be extracted by any tar implementation that understands older
  5938. @acronym{ustar} format. The only exception are files larger than 8GB.
  5939. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  5940. POSIX-aware tars.}
  5941. @node Compression
  5942. @section Using Less Space through Compression
  5943. @menu
  5944. * gzip:: Creating and Reading Compressed Archives
  5945. * sparse:: Archiving Sparse Files
  5946. @end menu
  5947. @node gzip
  5948. @subsection Creating and Reading Compressed Archives
  5949. @cindex Compressed archives
  5950. @cindex Storing archives in compressed format
  5951. @GNUTAR{} is able to create and read compressed archives. It supports
  5952. @command{gzip} and @command{bzip2} compression programs. For backward
  5953. compatibilty, it also supports @command{compress} command, although
  5954. we strongly recommend against using it, since there is a patent
  5955. covering the algorithm it uses and you could be sued for patent
  5956. infringement merely by running @command{compress}! Besides, it is less
  5957. effective than @command{gzip} and @command{bzip2}.
  5958. Creating a compressed archive is simple: you just specify a
  5959. @dfn{compression option} along with the usual archive creation
  5960. commands. The compression option is @option{-z} (@option{--gzip}) to
  5961. create a @command{gzip} compressed archive, @option{-j}
  5962. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  5963. @option{-Z} (@option{--compress}) to use @command{compress} program.
  5964. For example:
  5965. @smallexample
  5966. $ @kbd{tar cfz archive.tar.gz .}
  5967. @end smallexample
  5968. Reading compressed archive is even simpler: you don't need to specify
  5969. any additional options as @GNUTAR{} recognizes its format
  5970. automatically. Thus, the following commands will list and extract the
  5971. archive created in previous example:
  5972. @smallexample
  5973. # List the compressed archive
  5974. $ @kbd{tar tf archive.tar.gz}
  5975. # Extract the compressed archive
  5976. $ @kbd{tar xf archive.tar.gz}
  5977. @end smallexample
  5978. The only case when you have to specify a decompression option while
  5979. reading the archive is when reading from a pipe or from a tape drive
  5980. that does not support random access. However, in this case @GNUTAR{}
  5981. will indicate which option you should use. For example:
  5982. @smallexample
  5983. $ @kbd{cat archive.tar.gz | tar tf -}
  5984. tar: Archive is compressed. Use -z option
  5985. tar: Error is not recoverable: exiting now
  5986. @end smallexample
  5987. If you see such diagnostics, just add the suggested option to the
  5988. invocation of @GNUTAR{}:
  5989. @smallexample
  5990. $ @kbd{cat archive.tar.gz | tar tfz -}
  5991. @end smallexample
  5992. Notice also, that there are several restrictions on operations on
  5993. compressed archives. First of all, compressed archives cannot be
  5994. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  5995. (@option{--delete}) members from them. Likewise, you cannot append
  5996. another @command{tar} archive to a compressed archive using
  5997. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  5998. compressed.
  5999. The following table summarizes compression options used by @GNUTAR{}.
  6000. @table @option
  6001. @opindex gzip
  6002. @opindex ungzip
  6003. @item -z
  6004. @itemx --gzip
  6005. @itemx --ungzip
  6006. Filter the archive through @command{gzip}.
  6007. You can use @option{--gzip} and @option{--gunzip} on physical devices
  6008. (tape drives, etc.) and remote files as well as on normal files; data
  6009. to or from such devices or remote files is reblocked by another copy
  6010. of the @command{tar} program to enforce the specified (or default) record
  6011. size. The default compression parameters are used; if you need to
  6012. override them, set @env{GZIP} environment variable, e.g.:
  6013. @smallexample
  6014. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  6015. @end smallexample
  6016. @noindent
  6017. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  6018. @command{gzip} explicitly:
  6019. @smallexample
  6020. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  6021. @end smallexample
  6022. @cindex corrupted archives
  6023. About corrupted compressed archives: @command{gzip}'ed files have no
  6024. redundancy, for maximum compression. The adaptive nature of the
  6025. compression scheme means that the compression tables are implicitly
  6026. spread all over the archive. If you lose a few blocks, the dynamic
  6027. construction of the compression tables becomes unsynchronized, and there
  6028. is little chance that you could recover later in the archive.
  6029. There are pending suggestions for having a per-volume or per-file
  6030. compression in @GNUTAR{}. This would allow for viewing the
  6031. contents without decompression, and for resynchronizing decompression at
  6032. every volume or file, in case of corrupted archives. Doing so, we might
  6033. lose some compressibility. But this would have make recovering easier.
  6034. So, there are pros and cons. We'll see!
  6035. @opindex bzip2
  6036. @item -j
  6037. @itemx --bzip2
  6038. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  6039. @opindex compress
  6040. @opindex uncompress
  6041. @item -Z
  6042. @itemx --compress
  6043. @itemx --uncompress
  6044. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  6045. The @acronym{GNU} Project recommends you not use
  6046. @command{compress}, because there is a patent covering the algorithm it
  6047. uses. You could be sued for patent infringement merely by running
  6048. @command{compress}.
  6049. @opindex use-compress-program
  6050. @item --use-compress-program=@var{prog}
  6051. Use external compression program @var{prog}. Use this option if you
  6052. have a compression program that @GNUTAR{} does not support. There
  6053. are two requirements to which @var{prog} should comply:
  6054. First, when called without options, it should read data from standard
  6055. input, compress it and output it on standard output.
  6056. Secondly, if called with @option{-d} argument, it should do exactly
  6057. the opposite, i.e., read the compressed data from the standard input
  6058. and produce uncompressed data on the standard output.
  6059. @end table
  6060. @cindex gpg, using with tar
  6061. @cindex gnupg, using with tar
  6062. @cindex Using encrypted archives
  6063. The @option{--use-compress-program} option, in particular, lets you
  6064. implement your own filters, not necessarily dealing with
  6065. compression/decomression. For example, suppose you wish to implement
  6066. PGP encryption on top of compression, using @command{gpg} (@pxref{Top,
  6067. gpg, gpg ---- encryption and signing tool, gpg}). The following
  6068. script does that:
  6069. @smallexample
  6070. @group
  6071. #! /bin/sh
  6072. case $1 in
  6073. -d) gpg --decrypt - | gzip -d -c;;
  6074. '') gzip -c | gpg -s ;;
  6075. *) echo "Unknown option $1">&2; exit 1;;
  6076. esac
  6077. @end group
  6078. @end smallexample
  6079. Suppose you name it @file{gpgz} and save it somewhere in your
  6080. @env{PATH}. Then the following command will create a commpressed
  6081. archive signed with your private key:
  6082. @smallexample
  6083. $ @kbd{tar -cf foo.tar.gpgz --use-compress=gpgz .}
  6084. @end smallexample
  6085. @noindent
  6086. Likewise, the following command will list its contents:
  6087. @smallexample
  6088. $ @kbd{tar -tf foo.tar.gpgz --use-compress=gpgz .}
  6089. @end smallexample
  6090. @ignore
  6091. The above is based on the following discussion:
  6092. I have one question, or maybe it's a suggestion if there isn't a way
  6093. to do it now. I would like to use @option{--gzip}, but I'd also like
  6094. the output to be fed through a program like @acronym{GNU}
  6095. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  6096. to use :-)), basically adding ECC protection on top of compression.
  6097. It seems as if this should be quite easy to do, but I can't work out
  6098. exactly how to go about it. Of course, I can pipe the standard output
  6099. of @command{tar} through @command{ecc}, but then I lose (though I
  6100. haven't started using it yet, I confess) the ability to have
  6101. @command{tar} use @command{rmt} for it's I/O (I think).
  6102. I think the most straightforward thing would be to let me specify a
  6103. general set of filters outboard of compression (preferably ordered,
  6104. so the order can be automatically reversed on input operations, and
  6105. with the options they require specifiable), but beggars shouldn't be
  6106. choosers and anything you decide on would be fine with me.
  6107. By the way, I like @command{ecc} but if (as the comments say) it can't
  6108. deal with loss of block sync, I'm tempted to throw some time at adding
  6109. that capability. Supposing I were to actually do such a thing and
  6110. get it (apparently) working, do you accept contributed changes to
  6111. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  6112. Isn't that exactly the role of the
  6113. @option{--use-compress-prog=@var{program}} option?
  6114. I never tried it myself, but I suspect you may want to write a
  6115. @var{prog} script or program able to filter stdin to stdout to
  6116. way you want. It should recognize the @option{-d} option, for when
  6117. extraction is needed rather than creation.
  6118. It has been reported that if one writes compressed data (through the
  6119. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  6120. the DLT compression mode, the data will actually get bigger and one will
  6121. end up with less space on the tape.
  6122. @end ignore
  6123. @node sparse
  6124. @subsection Archiving Sparse Files
  6125. @cindex Sparse Files
  6126. @UNREVISED
  6127. @table @option
  6128. @opindex sparse
  6129. @item -S
  6130. @itemx --sparse
  6131. Handle sparse files efficiently.
  6132. @end table
  6133. This option causes all files to be put in the archive to be tested for
  6134. sparseness, and handled specially if they are. The @option{--sparse}
  6135. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  6136. backed up. Using this option dramatically decreases the amount of
  6137. space needed to store such a file.
  6138. In later versions, this option may be removed, and the testing and
  6139. treatment of sparse files may be done automatically with any special
  6140. @acronym{GNU} options. For now, it is an option needing to be specified on
  6141. the command line with the creation or updating of an archive.
  6142. Files in the file system occasionally have ``holes.'' A hole in a file
  6143. is a section of the file's contents which was never written. The
  6144. contents of a hole read as all zeros. On many operating systems,
  6145. actual disk storage is not allocated for holes, but they are counted
  6146. in the length of the file. If you archive such a file, @command{tar}
  6147. could create an archive longer than the original. To have @command{tar}
  6148. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  6149. you use this option, then, for any file using less disk space than
  6150. would be expected from its length, @command{tar} searches the file for
  6151. consecutive stretches of zeros. It then records in the archive for
  6152. the file where the consecutive stretches of zeros are, and only
  6153. archives the ``real contents'' of the file. On extraction (using
  6154. @option{--sparse} is not needed on extraction) any such
  6155. files have holes created wherever the continuous stretches of zeros
  6156. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  6157. won't take more space than the original.
  6158. A file is sparse if it contains blocks of zeros whose existence is
  6159. recorded, but that have no space allocated on disk. When you specify
  6160. the @option{--sparse} option in conjunction with the @option{--create}
  6161. (@option{-c}) operation, @command{tar} tests all files for sparseness
  6162. while archiving. If @command{tar} finds a file to be sparse, it uses a
  6163. sparse representation of the file in the archive. @xref{create}, for
  6164. more information about creating archives.
  6165. @option{--sparse} is useful when archiving files, such as dbm files,
  6166. likely to contain many nulls. This option dramatically
  6167. decreases the amount of space needed to store such an archive.
  6168. @quotation
  6169. @strong{Please Note:} Always use @option{--sparse} when performing file
  6170. system backups, to avoid archiving the expanded forms of files stored
  6171. sparsely in the system.
  6172. Even if your system has no sparse files currently, some may be
  6173. created in the future. If you use @option{--sparse} while making file
  6174. system backups as a matter of course, you can be assured the archive
  6175. will never take more space on the media than the files take on disk
  6176. (otherwise, archiving a disk filled with sparse files might take
  6177. hundreds of tapes). @xref{Incremental Dumps}.
  6178. @end quotation
  6179. @command{tar} ignores the @option{--sparse} option when reading an archive.
  6180. @table @option
  6181. @item --sparse
  6182. @itemx -S
  6183. Files stored sparsely in the file system are represented sparsely in
  6184. the archive. Use in conjunction with write operations.
  6185. @end table
  6186. However, users should be well aware that at archive creation time,
  6187. @GNUTAR{} still has to read whole disk file to
  6188. locate the @dfn{holes}, and so, even if sparse files use little space
  6189. on disk and in the archive, they may sometimes require inordinate
  6190. amount of time for reading and examining all-zero blocks of a file.
  6191. Although it works, it's painfully slow for a large (sparse) file, even
  6192. though the resulting tar archive may be small. (One user reports that
  6193. dumping a @file{core} file of over 400 megabytes, but with only about
  6194. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  6195. ELC, with full CPU utilization.)
  6196. This reading is required in all cases and is not related to the fact
  6197. the @option{--sparse} option is used or not, so by merely @emph{not}
  6198. using the option, you are not saving time@footnote{Well! We should say
  6199. the whole truth, here. When @option{--sparse} is selected while creating
  6200. an archive, the current @command{tar} algorithm requires sparse files to be
  6201. read twice, not once. We hope to develop a new archive format for saving
  6202. sparse files in which one pass will be sufficient.}.
  6203. Programs like @command{dump} do not have to read the entire file; by
  6204. examining the file system directly, they can determine in advance
  6205. exactly where the holes are and thus avoid reading through them. The
  6206. only data it need read are the actual allocated data blocks.
  6207. @GNUTAR{} uses a more portable and straightforward
  6208. archiving approach, it would be fairly difficult that it does
  6209. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  6210. 1990-12-10:
  6211. @quotation
  6212. What I did say is that you cannot tell the difference between a hole and an
  6213. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  6214. best tells you how many holes there are; it doesn't tell you @emph{where}.
  6215. Just as programs may, conceivably, care what @code{st_blocks} is (care
  6216. to name one that does?), they may also care where the holes are (I have
  6217. no examples of this one either, but it's equally imaginable).
  6218. I conclude from this that good archivers are not portable. One can
  6219. arguably conclude that if you want a portable program, you can in good
  6220. conscience restore files with as many holes as possible, since you can't
  6221. get it right.
  6222. @end quotation
  6223. @node Attributes
  6224. @section Handling File Attributes
  6225. @UNREVISED
  6226. When @command{tar} reads files, it updates their access times. To
  6227. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  6228. reset the access time retroactively or avoid changing it in the first
  6229. place.
  6230. Handling of file attributes
  6231. @table @option
  6232. @opindex atime-preserve
  6233. @item --atime-preserve
  6234. @itemx --atime-preserve=replace
  6235. @itemx --atime-preserve=system
  6236. Preserve the access times of files that are read. This works only for
  6237. files that you own, unless you have superuser privileges.
  6238. @option{--atime-preserve=replace} works on most systems, but it also
  6239. restores the data modification time and updates the status change
  6240. time. Hence it doesn't interact with incremental dumps nicely
  6241. (@pxref{Backups}), and it can set access or data modification times
  6242. incorrectly if other programs access the file while @command{tar} is
  6243. running.
  6244. @option{--atime-preserve=system} avoids changing the access time in
  6245. the first place, if the operating system supports this.
  6246. Unfortunately, this may or may not work on any given operating system
  6247. or file system. If @command{tar} knows for sure it won't work, it
  6248. complains right away.
  6249. Currently @option{--atime-preserve} with no operand defaults to
  6250. @option{--atime-preserve=replace}, but this is intended to change to
  6251. @option{--atime-preserve=system} when the latter is better-supported.
  6252. @opindex touch
  6253. @item -m
  6254. @itemx --touch
  6255. Do not extract data modification time.
  6256. When this option is used, @command{tar} leaves the data modification times
  6257. of the files it extracts as the times when the files were extracted,
  6258. instead of setting it to the times recorded in the archive.
  6259. This option is meaningless with @option{--list} (@option{-t}).
  6260. @opindex same-owner
  6261. @item --same-owner
  6262. Create extracted files with the same ownership they have in the
  6263. archive.
  6264. This is the default behavior for the superuser,
  6265. so this option is meaningful only for non-root users, when @command{tar}
  6266. is executed on those systems able to give files away. This is
  6267. considered as a security flaw by many people, at least because it
  6268. makes quite difficult to correctly account users for the disk space
  6269. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6270. files are easily and silently lost when files are given away.
  6271. When writing an archive, @command{tar} writes the user id and user name
  6272. separately. If it can't find a user name (because the user id is not
  6273. in @file{/etc/passwd}), then it does not write one. When restoring,
  6274. it tries to look the name (if one was written) up in
  6275. @file{/etc/passwd}. If it fails, then it uses the user id stored in
  6276. the archive instead.
  6277. @opindex no-same-owner
  6278. @item --no-same-owner
  6279. @itemx -o
  6280. Do not attempt to restore ownership when extracting. This is the
  6281. default behavior for ordinary users, so this option has an effect
  6282. only for the superuser.
  6283. @opindex numeric-owner
  6284. @item --numeric-owner
  6285. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6286. without user/group name information or such information to be ignored
  6287. when extracting. It effectively disables the generation and/or use
  6288. of user/group name information. This option forces extraction using
  6289. the numeric ids from the archive, ignoring the names.
  6290. This is useful in certain circumstances, when restoring a backup from
  6291. an emergency floppy with different passwd/group files for example.
  6292. It is otherwise impossible to extract files with the right ownerships
  6293. if the password file in use during the extraction does not match the
  6294. one belonging to the file system(s) being extracted. This occurs,
  6295. for example, if you are restoring your files after a major crash and
  6296. had booted from an emergency floppy with no password file or put your
  6297. disk into another machine to do the restore.
  6298. The numeric ids are @emph{always} saved into @command{tar} archives.
  6299. The identifying names are added at create time when provided by the
  6300. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6301. used when moving archives between a collection of machines using
  6302. a centralized management for attribution of numeric ids to users
  6303. and groups. This is often made through using the NIS capabilities.
  6304. When making a @command{tar} file for distribution to other sites, it
  6305. is sometimes cleaner to use a single owner for all files in the
  6306. distribution, and nicer to specify the write permission bits of the
  6307. files as stored in the archive independently of their actual value on
  6308. the file system. The way to prepare a clean distribution is usually
  6309. to have some Makefile rule creating a directory, copying all needed
  6310. files in that directory, then setting ownership and permissions as
  6311. wanted (there are a lot of possible schemes), and only then making a
  6312. @command{tar} archive out of this directory, before cleaning
  6313. everything out. Of course, we could add a lot of options to
  6314. @GNUTAR{} for fine tuning permissions and ownership.
  6315. This is not the good way, I think. @GNUTAR{} is
  6316. already crowded with options and moreover, the approach just explained
  6317. gives you a great deal of control already.
  6318. @opindex same-permissions, short description
  6319. @opindex preserve-permissions, short description
  6320. @item -p
  6321. @itemx --same-permissions
  6322. @itemx --preserve-permissions
  6323. Extract all protection information.
  6324. This option causes @command{tar} to set the modes (access permissions) of
  6325. extracted files exactly as recorded in the archive. If this option
  6326. is not used, the current @code{umask} setting limits the permissions
  6327. on extracted files. This option is by default enabled when
  6328. @command{tar} is executed by a superuser.
  6329. This option is meaningless with @option{--list} (@option{-t}).
  6330. @opindex preserve
  6331. @item --preserve
  6332. Same as both @option{--same-permissions} and @option{--same-order}.
  6333. The @option{--preserve} option has no equivalent short option name.
  6334. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6335. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)
  6336. Neither do I. --Sergey}
  6337. @end table
  6338. @node Standard
  6339. @section Basic Tar Format
  6340. @UNREVISED
  6341. While an archive may contain many files, the archive itself is a
  6342. single ordinary file. Like any other file, an archive file can be
  6343. written to a storage device such as a tape or disk, sent through a
  6344. pipe or over a network, saved on the active file system, or even
  6345. stored in another archive. An archive file is not easy to read or
  6346. manipulate without using the @command{tar} utility or Tar mode in
  6347. @acronym{GNU} Emacs.
  6348. Physically, an archive consists of a series of file entries terminated
  6349. by an end-of-archive entry, which consists of two 512 blocks of zero
  6350. bytes. A file
  6351. entry usually describes one of the files in the archive (an
  6352. @dfn{archive member}), and consists of a file header and the contents
  6353. of the file. File headers contain file names and statistics, checksum
  6354. information which @command{tar} uses to detect file corruption, and
  6355. information about file types.
  6356. Archives are permitted to have more than one member with the same
  6357. member name. One way this situation can occur is if more than one
  6358. version of a file has been stored in the archive. For information
  6359. about adding new versions of a file to an archive, see @ref{update}.
  6360. @FIXME-xref{To learn more about having more than one archive member with the
  6361. same name, see -backup node, when it's written.}
  6362. In addition to entries describing archive members, an archive may
  6363. contain entries which @command{tar} itself uses to store information.
  6364. @xref{label}, for an example of such an archive entry.
  6365. A @command{tar} archive file contains a series of blocks. Each block
  6366. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  6367. of as being on magnetic tape, other media are often used.
  6368. Each file archived is represented by a header block which describes
  6369. the file, followed by zero or more blocks which give the contents
  6370. of the file. At the end of the archive file there are two 512-byte blocks
  6371. filled with binary zeros as an end-of-file marker. A reasonable system
  6372. should write such end-of-file marker at the end of an archive, but
  6373. must not assume that such a block exists when reading an archive. In
  6374. particular @GNUTAR{} always issues a warning if it does not encounter it.
  6375. The blocks may be @dfn{blocked} for physical I/O operations.
  6376. Each record of @var{n} blocks (where @var{n} is set by the
  6377. @option{--blocking-factor=@var{512-size}} (@option{-b @var{512-size}}) option to @command{tar}) is written with a single
  6378. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  6379. such a write is a single record. When writing an archive,
  6380. the last record of blocks should be written at the full size, with
  6381. blocks after the zero block containing all zeros. When reading
  6382. an archive, a reasonable system should properly handle an archive
  6383. whose last record is shorter than the rest, or which contains garbage
  6384. records after a zero block.
  6385. The header block is defined in C as follows. In the @GNUTAR{}
  6386. distribution, this is part of file @file{src/tar.h}:
  6387. @smallexample
  6388. @include header.texi
  6389. @end smallexample
  6390. All characters in header blocks are represented by using 8-bit
  6391. characters in the local variant of ASCII. Each field within the
  6392. structure is contiguous; that is, there is no padding used within
  6393. the structure. Each character on the archive medium is stored
  6394. contiguously.
  6395. Bytes representing the contents of files (after the header block
  6396. of each file) are not translated in any way and are not constrained
  6397. to represent characters in any character set. The @command{tar} format
  6398. does not distinguish text files from binary files, and no translation
  6399. of file contents is performed.
  6400. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  6401. @code{gname} are null-terminated character strings. All other fields
  6402. are zero-filled octal numbers in ASCII. Each numeric field of width
  6403. @var{w} contains @var{w} minus 1 digits, and a null.
  6404. The @code{name} field is the file name of the file, with directory names
  6405. (if any) preceding the file name, separated by slashes.
  6406. @FIXME{how big a name before field overflows?}
  6407. The @code{mode} field provides nine bits specifying file permissions
  6408. and three bits to specify the Set UID, Set GID, and Save Text
  6409. (@dfn{sticky}) modes. Values for these bits are defined above.
  6410. When special permissions are required to create a file with a given
  6411. mode, and the user restoring files from the archive does not hold such
  6412. permissions, the mode bit(s) specifying those special permissions
  6413. are ignored. Modes which are not supported by the operating system
  6414. restoring files from the archive will be ignored. Unsupported modes
  6415. should be faked up when creating or updating an archive; e.g., the
  6416. group permission could be copied from the @emph{other} permission.
  6417. The @code{uid} and @code{gid} fields are the numeric user and group
  6418. ID of the file owners, respectively. If the operating system does
  6419. not support numeric user or group IDs, these fields should be ignored.
  6420. The @code{size} field is the size of the file in bytes; linked files
  6421. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6422. particular the @option{--incremental} (@option{-G}) option.}
  6423. The @code{mtime} field is the data modification time of the file at
  6424. the time it was archived. It is the ASCII representation of the octal
  6425. value of the last time the file's contents were modified, represented
  6426. as an integer number of
  6427. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6428. The @code{chksum} field is the ASCII representation of the octal value
  6429. of the simple sum of all bytes in the header block. Each 8-bit
  6430. byte in the header is added to an unsigned integer, initialized to
  6431. zero, the precision of which shall be no less than seventeen bits.
  6432. When calculating the checksum, the @code{chksum} field is treated as
  6433. if it were all blanks.
  6434. The @code{typeflag} field specifies the type of file archived. If a
  6435. particular implementation does not recognize or permit the specified
  6436. type, the file will be extracted as if it were a regular file. As this
  6437. action occurs, @command{tar} issues a warning to the standard error.
  6438. The @code{atime} and @code{ctime} fields are used in making incremental
  6439. backups; they store, respectively, the particular file's access and
  6440. status change times.
  6441. The @code{offset} is used by the @option{--multi-volume} (@option{-M}) option, when
  6442. making a multi-volume archive. The offset is number of bytes into
  6443. the file that we need to restart at to continue the file on the next
  6444. tape, i.e., where we store the location that a continued file is
  6445. continued at.
  6446. The following fields were added to deal with sparse files. A file
  6447. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6448. represented as zeros, i.e., no useful data. A test to see if a file
  6449. is sparse is to look at the number blocks allocated for it versus the
  6450. number of characters in the file; if there are fewer blocks allocated
  6451. for the file than would normally be allocated for a file of that
  6452. size, then the file is sparse. This is the method @command{tar} uses to
  6453. detect a sparse file, and once such a file is detected, it is treated
  6454. differently from non-sparse files.
  6455. Sparse files are often @code{dbm} files, or other database-type files
  6456. which have data at some points and emptiness in the greater part of
  6457. the file. Such files can appear to be very large when an @samp{ls
  6458. -l} is done on them, when in truth, there may be a very small amount
  6459. of important data contained in the file. It is thus undesirable
  6460. to have @command{tar} think that it must back up this entire file, as
  6461. great quantities of room are wasted on empty blocks, which can lead
  6462. to running out of room on a tape far earlier than is necessary.
  6463. Thus, sparse files are dealt with so that these empty blocks are
  6464. not written to the tape. Instead, what is written to the tape is a
  6465. description, of sorts, of the sparse file: where the holes are, how
  6466. big the holes are, and how much data is found at the end of the hole.
  6467. This way, the file takes up potentially far less room on the tape,
  6468. and when the file is extracted later on, it will look exactly the way
  6469. it looked beforehand. The following is a description of the fields
  6470. used to handle a sparse file:
  6471. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6472. sparse} contains two 12-character strings which represent an offset
  6473. into the file and a number of bytes to be written at that offset.
  6474. The offset is absolute, and not relative to the offset in preceding
  6475. array element.
  6476. The header can hold four of these @code{struct sparse} at the moment;
  6477. if more are needed, they are not stored in the header.
  6478. The @code{isextended} flag is set when an @code{extended_header}
  6479. is needed to deal with a file. Note that this means that this flag
  6480. can only be set when dealing with a sparse file, and it is only set
  6481. in the event that the description of the file will not fit in the
  6482. allotted room for sparse structures in the header. In other words,
  6483. an extended_header is needed.
  6484. The @code{extended_header} structure is used for sparse files which
  6485. need more sparse structures than can fit in the header. The header can
  6486. fit 4 such structures; if more are needed, the flag @code{isextended}
  6487. gets set and the next block is an @code{extended_header}.
  6488. Each @code{extended_header} structure contains an array of 21
  6489. sparse structures, along with a similar @code{isextended} flag
  6490. that the header had. There can be an indeterminate number of such
  6491. @code{extended_header}s to describe a sparse file.
  6492. @table @asis
  6493. @item @code{REGTYPE}
  6494. @itemx @code{AREGTYPE}
  6495. These flags represent a regular file. In order to be compatible
  6496. with older versions of @command{tar}, a @code{typeflag} value of
  6497. @code{AREGTYPE} should be silently recognized as a regular file.
  6498. New archives should be created using @code{REGTYPE}. Also, for
  6499. backward compatibility, @command{tar} treats a regular file whose name
  6500. ends with a slash as a directory.
  6501. @item @code{LNKTYPE}
  6502. This flag represents a file linked to another file, of any type,
  6503. previously archived. Such files are identified in Unix by each
  6504. file having the same device and inode number. The linked-to name is
  6505. specified in the @code{linkname} field with a trailing null.
  6506. @item @code{SYMTYPE}
  6507. This represents a symbolic link to another file. The linked-to name
  6508. is specified in the @code{linkname} field with a trailing null.
  6509. @item @code{CHRTYPE}
  6510. @itemx @code{BLKTYPE}
  6511. These represent character special files and block special files
  6512. respectively. In this case the @code{devmajor} and @code{devminor}
  6513. fields will contain the major and minor device numbers respectively.
  6514. Operating systems may map the device specifications to their own
  6515. local specification, or may ignore the entry.
  6516. @item @code{DIRTYPE}
  6517. This flag specifies a directory or sub-directory. The directory
  6518. name in the @code{name} field should end with a slash. On systems where
  6519. disk allocation is performed on a directory basis, the @code{size} field
  6520. will contain the maximum number of bytes (which may be rounded to
  6521. the nearest disk block allocation unit) which the directory may
  6522. hold. A @code{size} field of zero indicates no such limiting. Systems
  6523. which do not support limiting in this manner should ignore the
  6524. @code{size} field.
  6525. @item @code{FIFOTYPE}
  6526. This specifies a FIFO special file. Note that the archiving of a
  6527. FIFO file archives the existence of this file and not its contents.
  6528. @item @code{CONTTYPE}
  6529. This specifies a contiguous file, which is the same as a normal
  6530. file except that, in operating systems which support it, all its
  6531. space is allocated contiguously on the disk. Operating systems
  6532. which do not allow contiguous allocation should silently treat this
  6533. type as a normal file.
  6534. @item @code{A} @dots{} @code{Z}
  6535. These are reserved for custom implementations. Some of these are
  6536. used in the @acronym{GNU} modified format, as described below.
  6537. @end table
  6538. Other values are reserved for specification in future revisions of
  6539. the P1003 standard, and should not be used by any @command{tar} program.
  6540. The @code{magic} field indicates that this archive was output in
  6541. the P1003 archive format. If this field contains @code{TMAGIC},
  6542. the @code{uname} and @code{gname} fields will contain the ASCII
  6543. representation of the owner and group of the file respectively.
  6544. If found, the user and group IDs are used rather than the values in
  6545. the @code{uid} and @code{gid} fields.
  6546. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6547. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6548. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6549. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6550. @node Extensions
  6551. @section @acronym{GNU} Extensions to the Archive Format
  6552. @UNREVISED
  6553. The @acronym{GNU} format uses additional file types to describe new types of
  6554. files in an archive. These are listed below.
  6555. @table @code
  6556. @item GNUTYPE_DUMPDIR
  6557. @itemx 'D'
  6558. This represents a directory and a list of files created by the
  6559. @option{--incremental} (@option{-G}) option. The @code{size} field gives the total
  6560. size of the associated list of files. Each file name is preceded by
  6561. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6562. (The file is a directory, or is not stored in the archive.) Each file
  6563. name is terminated by a null. There is an additional null after the
  6564. last file name.
  6565. @item GNUTYPE_MULTIVOL
  6566. @itemx 'M'
  6567. This represents a file continued from another volume of a multi-volume
  6568. archive created with the @option{--multi-volume} (@option{-M}) option. The original
  6569. type of the file is not given here. The @code{size} field gives the
  6570. maximum size of this piece of the file (assuming the volume does
  6571. not end before the file is written out). The @code{offset} field
  6572. gives the offset from the beginning of the file where this part of
  6573. the file begins. Thus @code{size} plus @code{offset} should equal
  6574. the original size of the file.
  6575. @item GNUTYPE_SPARSE
  6576. @itemx 'S'
  6577. This flag indicates that we are dealing with a sparse file. Note
  6578. that archiving a sparse file requires special operations to find
  6579. holes in the file, which mark the positions of these holes, along
  6580. with the number of bytes of data to be found after the hole.
  6581. @item GNUTYPE_VOLHDR
  6582. @itemx 'V'
  6583. This file type is used to mark the volume header that was given with
  6584. the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option when the archive was created. The @code{name}
  6585. field contains the @code{name} given after the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option.
  6586. The @code{size} field is zero. Only the first file in each volume
  6587. of an archive should have this type.
  6588. @end table
  6589. You may have trouble reading a @acronym{GNU} format archive on a
  6590. non-@acronym{GNU} system if the options @option{--incremental} (@option{-G}),
  6591. @option{--multi-volume} (@option{-M}), @option{--sparse} (@option{-S}), or @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) were
  6592. used when writing the archive. In general, if @command{tar} does not
  6593. use the @acronym{GNU}-added fields of the header, other versions of
  6594. @command{tar} should be able to read the archive. Otherwise, the
  6595. @command{tar} program will give an error, the most likely one being a
  6596. checksum error.
  6597. @node cpio
  6598. @section Comparison of @command{tar} and @command{cpio}
  6599. @UNREVISED
  6600. @FIXME{Reorganize the following material}
  6601. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6602. pathname lengths. The binary and old ASCII formats have a max path
  6603. length of 256, and the new ASCII and CRC ASCII formats have a max
  6604. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6605. with arbitrary pathname lengths, but other @command{cpio} implementations
  6606. may crash unexplainedly trying to read them.
  6607. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6608. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6609. in System V prior to SVR4, and some vendors may have added symlinks
  6610. to their system without enhancing @command{cpio} to know about them.
  6611. Others may have enhanced it in a way other than the way I did it
  6612. at Sun, and which was adopted by AT&T (and which is, I think, also
  6613. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6614. into a later BSD release---I think I gave them my changes).
  6615. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6616. can handle @command{tar} format input, and write it on output, and it
  6617. probably handles symbolic links. They may not have bothered doing
  6618. anything to enhance @command{tar} as a result.)
  6619. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6620. @command{tar} comes with V7, System III, System V, and BSD source;
  6621. @command{cpio} comes only with System III, System V, and later BSD
  6622. (4.3-tahoe and later).
  6623. @command{tar}'s way of handling multiple hard links to a file can handle
  6624. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6625. @command{cpio}s way requires you to play some games (in its "binary"
  6626. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6627. they're 18 bits---it would have to play games with the "file system ID"
  6628. field of the header to make sure that the file system ID/i-number pairs
  6629. of different files were always different), and I don't know which
  6630. @command{cpio}s, if any, play those games. Those that don't might get
  6631. confused and think two files are the same file when they're not, and
  6632. make hard links between them.
  6633. @command{tar}s way of handling multiple hard links to a file places only
  6634. one copy of the link on the tape, but the name attached to that copy
  6635. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6636. way puts one copy for every link, but you can retrieve it using any
  6637. of the names.
  6638. @quotation
  6639. What type of check sum (if any) is used, and how is this calculated.
  6640. @end quotation
  6641. See the attached manual pages for @command{tar} and @command{cpio} format.
  6642. @command{tar} uses a checksum which is the sum of all the bytes in the
  6643. @command{tar} header for a file; @command{cpio} uses no checksum.
  6644. @quotation
  6645. If anyone knows why @command{cpio} was made when @command{tar} was present
  6646. at the unix scene,
  6647. @end quotation
  6648. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6649. generally-available version of UNIX had @command{tar} at the time. I don't
  6650. know whether any version that was generally available @emph{within AT&T}
  6651. had @command{tar}, or, if so, whether the people within AT&T who did
  6652. @command{cpio} knew about it.
  6653. On restore, if there is a corruption on a tape @command{tar} will stop at
  6654. that point, while @command{cpio} will skip over it and try to restore the
  6655. rest of the files.
  6656. The main difference is just in the command syntax and header format.
  6657. @command{tar} is a little more tape-oriented in that everything is blocked
  6658. to start on a record boundary.
  6659. @quotation
  6660. Is there any differences between the ability to recover crashed
  6661. archives between the two of them. (Is there any chance of recovering
  6662. crashed archives at all.)
  6663. @end quotation
  6664. Theoretically it should be easier under @command{tar} since the blocking
  6665. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6666. However, modern @command{cpio}'s and variations have an option to just
  6667. search for the next file header after an error with a reasonable chance
  6668. of resyncing. However, lots of tape driver software won't allow you to
  6669. continue past a media error which should be the only reason for getting
  6670. out of sync unless a file changed sizes while you were writing the
  6671. archive.
  6672. @quotation
  6673. If anyone knows why @command{cpio} was made when @command{tar} was present
  6674. at the unix scene, please tell me about this too.
  6675. @end quotation
  6676. Probably because it is more media efficient (by not blocking everything
  6677. and using only the space needed for the headers where @command{tar}
  6678. always uses 512 bytes per file header) and it knows how to archive
  6679. special files.
  6680. You might want to look at the freely available alternatives. The
  6681. major ones are @command{afio}, @GNUTAR{}, and
  6682. @command{pax}, each of which have their own extensions with some
  6683. backwards compatibility.
  6684. Sparse files were @command{tar}red as sparse files (which you can
  6685. easily test, because the resulting archive gets smaller, and
  6686. @acronym{GNU} @command{cpio} can no longer read it).
  6687. @node Media
  6688. @chapter Tapes and Other Archive Media
  6689. @UNREVISED
  6690. A few special cases about tape handling warrant more detailed
  6691. description. These special cases are discussed below.
  6692. Many complexities surround the use of @command{tar} on tape drives. Since
  6693. the creation and manipulation of archives located on magnetic tape was
  6694. the original purpose of @command{tar}, it contains many features making
  6695. such manipulation easier.
  6696. Archives are usually written on dismountable media---tape cartridges,
  6697. mag tapes, or floppy disks.
  6698. The amount of data a tape or disk holds depends not only on its size,
  6699. but also on how it is formatted. A 2400 foot long reel of mag tape
  6700. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6701. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6702. Magnetic media are re-usable---once the archive on a tape is no longer
  6703. needed, the archive can be erased and the tape or disk used over.
  6704. Media quality does deteriorate with use, however. Most tapes or disks
  6705. should be discarded when they begin to produce data errors. EXABYTE
  6706. tape cartridges should be discarded when they generate an @dfn{error
  6707. count} (number of non-usable bits) of more than 10k.
  6708. Magnetic media are written and erased using magnetic fields, and
  6709. should be protected from such fields to avoid damage to stored data.
  6710. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6711. not a good idea.
  6712. @menu
  6713. * Device:: Device selection and switching
  6714. * Remote Tape Server::
  6715. * Common Problems and Solutions::
  6716. * Blocking:: Blocking
  6717. * Many:: Many archives on one tape
  6718. * Using Multiple Tapes:: Using Multiple Tapes
  6719. * label:: Including a Label in the Archive
  6720. * verify::
  6721. * Write Protection::
  6722. @end menu
  6723. @node Device
  6724. @section Device Selection and Switching
  6725. @UNREVISED
  6726. @table @option
  6727. @item -f [@var{hostname}:]@var{file}
  6728. @itemx --file=[@var{hostname}:]@var{file}
  6729. Use archive file or device @var{file} on @var{hostname}.
  6730. @end table
  6731. This option is used to specify the file name of the archive @command{tar}
  6732. works on.
  6733. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6734. input (when listing or extracting), or writes it to standard output
  6735. (when creating). If the @samp{-} file name is given when updating an
  6736. archive, @command{tar} will read the original archive from its standard
  6737. input, and will write the entire new archive to its standard output.
  6738. If the file name contains a @samp{:}, it is interpreted as
  6739. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6740. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  6741. either case, @command{tar} will invoke the command @command{rsh} (or
  6742. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6743. machine. If you give an alternate login name, it will be given to the
  6744. @command{rsh}.
  6745. Naturally, the remote machine must have an executable
  6746. @command{/usr/libexec/rmt}. This program is free software from the
  6747. University of California, and a copy of the source code can be found
  6748. with the sources for @command{tar}; it's compiled and installed by default.
  6749. The exact path to this utility is determined when configuring the package.
  6750. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6751. your installation prefix. This location may also be overridden at
  6752. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  6753. ---rmt-command}, for detailed description of this option. @xref{Remote
  6754. Tape Server}, for the description of @command{rmt} command).
  6755. If this option is not given, but the environment variable @env{TAPE}
  6756. is set, its value is used; otherwise, old versions of @command{tar}
  6757. used a default archive name (which was picked when @command{tar} was
  6758. compiled). The default is normally set up to be the @dfn{first} tape
  6759. drive or other transportable I/O medium on the system.
  6760. Starting with version 1.11.5, @GNUTAR{} uses
  6761. standard input and standard output as the default device, and I will
  6762. not try anymore supporting automatic device detection at installation
  6763. time. This was failing really in too many cases, it was hopeless.
  6764. This is now completely left to the installer to override standard
  6765. input and standard output for default device, if this seems
  6766. preferable. Further, I think @emph{most} actual usages of
  6767. @command{tar} are done with pipes or disks, not really tapes,
  6768. cartridges or diskettes.
  6769. Some users think that using standard input and output is running
  6770. after trouble. This could lead to a nasty surprise on your screen if
  6771. you forget to specify an output file name---especially if you are going
  6772. through a network or terminal server capable of buffering large amounts
  6773. of output. We had so many bug reports in that area of configuring
  6774. default tapes automatically, and so many contradicting requests, that
  6775. we finally consider the problem to be portably intractable. We could
  6776. of course use something like @samp{/dev/tape} as a default, but this
  6777. is @emph{also} running after various kind of trouble, going from hung
  6778. processes to accidental destruction of real tapes. After having seen
  6779. all this mess, using standard input and output as a default really
  6780. sounds like the only clean choice left, and a very useful one too.
  6781. @GNUTAR{} reads and writes archive in records, I
  6782. suspect this is the main reason why block devices are preferred over
  6783. character devices. Most probably, block devices are more efficient
  6784. too. The installer could also check for @samp{DEFTAPE} in
  6785. @file{<sys/mtio.h>}.
  6786. @table @option
  6787. @opindex force-local, short description
  6788. @item --force-local
  6789. Archive file is local even if it contains a colon.
  6790. @opindex rsh-command
  6791. @item --rsh-command=@var{command}
  6792. Use remote @var{command} instead of @command{rsh}. This option exists
  6793. so that people who use something other than the standard @command{rsh}
  6794. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6795. When this command is not used, the shell command found when
  6796. the @command{tar} program was installed is used instead. This is
  6797. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6798. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6799. The installer may have overridden this by defining the environment
  6800. variable @env{RSH} @emph{at installation time}.
  6801. @item -[0-7][lmh]
  6802. Specify drive and density.
  6803. @opindex multi-volume, short description
  6804. @item -M
  6805. @itemx --multi-volume
  6806. Create/list/extract multi-volume archive.
  6807. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6808. that may be larger than will fit on the medium used to hold it.
  6809. @xref{Multi-Volume Archives}.
  6810. @opindex tape-length, short description
  6811. @item -L @var{num}
  6812. @itemx --tape-length=@var{num}
  6813. Change tape after writing @var{num} x 1024 bytes.
  6814. This option might be useful when your tape drivers do not properly
  6815. detect end of physical tapes. By being slightly conservative on the
  6816. maximum tape length, you might avoid the problem entirely.
  6817. @opindex info-script, short description
  6818. @opindex new-volume-script, short description
  6819. @item -F @var{file}
  6820. @itemx --info-script=@var{file}
  6821. @itemx --new-volume-script=@var{file}
  6822. Execute @file{file} at end of each tape. This implies
  6823. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  6824. description of this option.
  6825. @end table
  6826. @node Remote Tape Server
  6827. @section The Remote Tape Server
  6828. @cindex remote tape drive
  6829. @pindex rmt
  6830. In order to access the tape drive on a remote machine, @command{tar}
  6831. uses the remote tape server written at the University of California at
  6832. Berkeley. The remote tape server must be installed as
  6833. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6834. want to use. @command{tar} calls @command{rmt} by running an
  6835. @command{rsh} or @command{remsh} to the remote machine, optionally
  6836. using a different login name if one is supplied.
  6837. A copy of the source for the remote tape server is provided. It is
  6838. Copyright @copyright{} 1983 by the Regents of the University of
  6839. California, but can be freely distributed. It is compiled and
  6840. installed by default.
  6841. @cindex absolute file names
  6842. Unless you use the @option{--absolute-names} (@option{-P}) option,
  6843. @GNUTAR{} will not allow you to create an archive that contains
  6844. absolute file names (a file name beginning with @samp{/}.) If you try,
  6845. @command{tar} will automatically remove the leading @samp{/} from the
  6846. file names it stores in the archive. It will also type a warning
  6847. message telling you what it is doing.
  6848. When reading an archive that was created with a different
  6849. @command{tar} program, @GNUTAR{} automatically
  6850. extracts entries in the archive which have absolute file names as if
  6851. the file names were not absolute. This is an important feature. A
  6852. visitor here once gave a @command{tar} tape to an operator to restore;
  6853. the operator used Sun @command{tar} instead of @GNUTAR{},
  6854. and the result was that it replaced large portions of
  6855. our @file{/bin} and friends with versions from the tape; needless to
  6856. say, we were unhappy about having to recover the file system from
  6857. backup tapes.
  6858. For example, if the archive contained a file @file{/usr/bin/computoy},
  6859. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6860. relative to the current directory. If you want to extract the files in
  6861. an archive to the same absolute names that they had when the archive
  6862. was created, you should do a @samp{cd /} before extracting the files
  6863. from the archive, or you should either use the @option{--absolute-names}
  6864. option, or use the command @samp{tar -C / @dots{}}.
  6865. @cindex Ultrix 3.1 and write failure
  6866. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6867. can claim that a short write near the end of a tape succeeded,
  6868. when it actually failed. This will result in the -M option not
  6869. working correctly. The best workaround at the moment is to use a
  6870. significantly larger blocking factor than the default 20.
  6871. In order to update an archive, @command{tar} must be able to backspace the
  6872. archive in order to reread or rewrite a record that was just read (or
  6873. written). This is currently possible only on two kinds of files: normal
  6874. disk files (or any other file that can be backspaced with @samp{lseek}),
  6875. and industry-standard 9-track magnetic tape (or any other kind of tape
  6876. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6877. This means that the @option{--append}, @option{--concatenate}, and
  6878. @option{--delete} commands will not work on any other kind of file.
  6879. Some media simply cannot be backspaced, which means these commands and
  6880. options will never be able to work on them. These non-backspacing
  6881. media include pipes and cartridge tape drives.
  6882. Some other media can be backspaced, and @command{tar} will work on them
  6883. once @command{tar} is modified to do so.
  6884. Archives created with the @option{--multi-volume}, @option{--label}, and
  6885. @option{--incremental} (@option{-G}) options may not be readable by other version
  6886. of @command{tar}. In particular, restoring a file that was split over
  6887. a volume boundary will require some careful work with @command{dd}, if
  6888. it can be done at all. Other versions of @command{tar} may also create
  6889. an empty file whose name is that of the volume header. Some versions
  6890. of @command{tar} may create normal files instead of directories archived
  6891. with the @option{--incremental} (@option{-G}) option.
  6892. @node Common Problems and Solutions
  6893. @section Some Common Problems and their Solutions
  6894. @ifclear PUBLISH
  6895. @format
  6896. errors from system:
  6897. permission denied
  6898. no such file or directory
  6899. not owner
  6900. errors from @command{tar}:
  6901. directory checksum error
  6902. header format error
  6903. errors from media/system:
  6904. i/o error
  6905. device busy
  6906. @end format
  6907. @end ifclear
  6908. @node Blocking
  6909. @section Blocking
  6910. @UNREVISED
  6911. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6912. is also confusing to the expert reader. On the other hand, readers
  6913. who are new to the field have a fresh mind, and they may safely skip
  6914. the next two paragraphs, as the remainder of this manual uses those
  6915. two terms in a quite consistent way.
  6916. John Gilmore, the writer of the public domain @command{tar} from which
  6917. @GNUTAR{} was originally derived, wrote (June 1995):
  6918. @quotation
  6919. The nomenclature of tape drives comes from IBM, where I believe
  6920. they were invented for the IBM 650 or so. On IBM mainframes, what
  6921. is recorded on tape are tape blocks. The logical organization of
  6922. data is into records. There are various ways of putting records into
  6923. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6924. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6925. to a block), @code{VB} (variable size records, @var{n} to a block),
  6926. @code{VSB} (variable spanned blocked: variable sized records that can
  6927. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6928. parameter specified this to the operating system.
  6929. The Unix man page on @command{tar} was totally confused about this.
  6930. When I wrote @code{PD TAR}, I used the historically correct terminology
  6931. (@command{tar} writes data records, which are grouped into blocks).
  6932. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  6933. here), and now Fran@,{c}ois has migrated that terminology back
  6934. into the source code too.
  6935. @end quotation
  6936. The term @dfn{physical block} means the basic transfer chunk from or
  6937. to a device, after which reading or writing may stop without anything
  6938. being lost. In this manual, the term @dfn{block} usually refers to
  6939. a disk physical block, @emph{assuming} that each disk block is 512
  6940. bytes in length. It is true that some disk devices have different
  6941. physical blocks, but @command{tar} ignore these differences in its own
  6942. format, which is meant to be portable, so a @command{tar} block is always
  6943. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6944. The term @dfn{logical block} often represents the basic chunk of
  6945. allocation of many disk blocks as a single entity, which the operating
  6946. system treats somewhat atomically; this concept is only barely used
  6947. in @GNUTAR{}.
  6948. The term @dfn{physical record} is another way to speak of a physical
  6949. block, those two terms are somewhat interchangeable. In this manual,
  6950. the term @dfn{record} usually refers to a tape physical block,
  6951. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6952. It is true that archives may be put on disk or used with pipes,
  6953. but nevertheless, @command{tar} tries to read and write the archive one
  6954. @dfn{record} at a time, whatever the medium in use. One record is made
  6955. up of an integral number of blocks, and this operation of putting many
  6956. disk blocks into a single tape block is called @dfn{reblocking}, or
  6957. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6958. the logical organization of many characters into something meaningful
  6959. to the application. The term @dfn{unit record} describes a small set
  6960. of characters which are transmitted whole to or by the application,
  6961. and often refers to a line of text. Those two last terms are unrelated
  6962. to what we call a @dfn{record} in @GNUTAR{}.
  6963. When writing to tapes, @command{tar} writes the contents of the archive
  6964. in chunks known as @dfn{records}. To change the default blocking
  6965. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  6966. @var{512-size}}) option. Each record will then be composed of
  6967. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  6968. @xref{Standard}.) Each file written to the archive uses at least one
  6969. full record. As a result, using a larger record size can result in
  6970. more wasted space for small files. On the other hand, a larger record
  6971. size can often be read and written much more efficiently.
  6972. Further complicating the problem is that some tape drives ignore the
  6973. blocking entirely. For these, a larger record size can still improve
  6974. performance (because the software layers above the tape drive still
  6975. honor the blocking), but not as dramatically as on tape drives that
  6976. honor blocking.
  6977. When reading an archive, @command{tar} can usually figure out the
  6978. record size on itself. When this is the case, and a non-standard
  6979. record size was used when the archive was created, @command{tar} will
  6980. print a message about a non-standard blocking factor, and then operate
  6981. normally. On some tape devices, however, @command{tar} cannot figure
  6982. out the record size itself. On most of those, you can specify a
  6983. blocking factor (with @option{--blocking-factor}) larger than the
  6984. actual blocking factor, and then use the @option{--read-full-records}
  6985. (@option{-B}) option. (If you specify a blocking factor with
  6986. @option{--blocking-factor} and don't use the
  6987. @option{--read-full-records} option, then @command{tar} will not
  6988. attempt to figure out the recording size itself.) On some devices,
  6989. you must always specify the record size exactly with
  6990. @option{--blocking-factor} when reading, because @command{tar} cannot
  6991. figure it out. In any case, use @option{--list} (@option{-t}) before
  6992. doing any extractions to see whether @command{tar} is reading the archive
  6993. correctly.
  6994. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6995. putting them into records is to put a whole number of them (one or
  6996. more) into each record. @command{tar} records are all the same size;
  6997. at the end of the file there's a block containing all zeros, which
  6998. is how you tell that the remainder of the last record(s) are garbage.
  6999. In a standard @command{tar} file (no options), the block size is 512
  7000. and the record size is 10240, for a blocking factor of 20. What the
  7001. @option{--blocking-factor} option does is sets the blocking factor,
  7002. changing the record size while leaving the block size at 512 bytes.
  7003. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  7004. most tape drives these days prefer much bigger records in order to
  7005. stream and not waste tape. When writing tapes for myself, some tend
  7006. to use a factor of the order of 2048, say, giving a record size of
  7007. around one megabyte.
  7008. If you use a blocking factor larger than 20, older @command{tar}
  7009. programs might not be able to read the archive, so we recommend this
  7010. as a limit to use in practice. @GNUTAR{}, however,
  7011. will support arbitrarily large record sizes, limited only by the
  7012. amount of virtual memory or the physical characteristics of the tape
  7013. device.
  7014. @menu
  7015. * Format Variations:: Format Variations
  7016. * Blocking Factor:: The Blocking Factor of an Archive
  7017. @end menu
  7018. @node Format Variations
  7019. @subsection Format Variations
  7020. @cindex Format Parameters
  7021. @cindex Format Options
  7022. @cindex Options, archive format specifying
  7023. @cindex Options, format specifying
  7024. @UNREVISED
  7025. Format parameters specify how an archive is written on the archive
  7026. media. The best choice of format parameters will vary depending on
  7027. the type and number of files being archived, and on the media used to
  7028. store the archive.
  7029. To specify format parameters when accessing or creating an archive,
  7030. you can use the options described in the following sections.
  7031. If you do not specify any format parameters, @command{tar} uses
  7032. default parameters. You cannot modify a compressed archive.
  7033. If you create an archive with the @option{--blocking-factor} option
  7034. specified (@pxref{Blocking Factor}), you must specify that
  7035. blocking-factor when operating on the archive. @xref{Formats}, for other
  7036. examples of format parameter considerations.
  7037. @node Blocking Factor
  7038. @subsection The Blocking Factor of an Archive
  7039. @cindex Blocking Factor
  7040. @cindex Record Size
  7041. @cindex Number of blocks per record
  7042. @cindex Number of bytes per record
  7043. @cindex Bytes per record
  7044. @cindex Blocks per record
  7045. @UNREVISED
  7046. @opindex blocking-factor
  7047. The data in an archive is grouped into blocks, which are 512 bytes.
  7048. Blocks are read and written in whole number multiples called
  7049. @dfn{records}. The number of blocks in a record (ie. the size of a
  7050. record in units of 512 bytes) is called the @dfn{blocking factor}.
  7051. The @option{--blocking-factor=@var{512-size}} (@option{-b
  7052. @var{512-size}}) option specifies the blocking factor of an archive.
  7053. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  7054. can be specified at installation. To find out the blocking factor of
  7055. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  7056. This may not work on some devices.
  7057. Records are separated by gaps, which waste space on the archive media.
  7058. If you are archiving on magnetic tape, using a larger blocking factor
  7059. (and therefore larger records) provides faster throughput and allows you
  7060. to fit more data on a tape (because there are fewer gaps). If you are
  7061. archiving on cartridge, a very large blocking factor (say 126 or more)
  7062. greatly increases performance. A smaller blocking factor, on the other
  7063. hand, may be useful when archiving small files, to avoid archiving lots
  7064. of nulls as @command{tar} fills out the archive to the end of the record.
  7065. In general, the ideal record size depends on the size of the
  7066. inter-record gaps on the tape you are using, and the average size of the
  7067. files you are archiving. @xref{create}, for information on
  7068. writing archives.
  7069. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  7070. Archives with blocking factors larger than 20 cannot be read
  7071. by very old versions of @command{tar}, or by some newer versions
  7072. of @command{tar} running on old machines with small address spaces.
  7073. With @GNUTAR{}, the blocking factor of an archive is limited
  7074. only by the maximum record size of the device containing the archive,
  7075. or by the amount of available virtual memory.
  7076. Also, on some systems, not using adequate blocking factors, as sometimes
  7077. imposed by the device drivers, may yield unexpected diagnostics. For
  7078. example, this has been reported:
  7079. @smallexample
  7080. Cannot write to /dev/dlt: Invalid argument
  7081. @end smallexample
  7082. @noindent
  7083. In such cases, it sometimes happen that the @command{tar} bundled by
  7084. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  7085. requires an explicit specification for the block size,
  7086. which it cannot guess. This yields some people to consider
  7087. @GNUTAR{} is misbehaving, because by comparison,
  7088. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  7089. for example, might resolve the problem.
  7090. If you use a non-default blocking factor when you create an archive, you
  7091. must specify the same blocking factor when you modify that archive. Some
  7092. archive devices will also require you to specify the blocking factor when
  7093. reading that archive, however this is not typically the case. Usually, you
  7094. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  7095. reports a non-default record size and then lists the archive members as
  7096. it would normally. To extract files from an archive with a non-standard
  7097. blocking factor (particularly if you're not sure what the blocking factor
  7098. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  7099. specifying a blocking factor larger then the blocking factor of the archive
  7100. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  7101. @xref{list}, for more information on the @option{--list} (@option{-t})
  7102. operation. @xref{Reading}, for a more detailed explanation of that option.
  7103. @table @option
  7104. @item --blocking-factor=@var{number}
  7105. @itemx -b @var{number}
  7106. Specifies the blocking factor of an archive. Can be used with any
  7107. operation, but is usually not necessary with @option{--list} (@option{-t}).
  7108. @end table
  7109. Device blocking
  7110. @table @option
  7111. @item -b @var{blocks}
  7112. @itemx --blocking-factor=@var{blocks}
  7113. Set record size to @math{@var{blocks} * 512} bytes.
  7114. This option is used to specify a @dfn{blocking factor} for the archive.
  7115. When reading or writing the archive, @command{tar}, will do reads and writes
  7116. of the archive in records of @math{@var{block}*512} bytes. This is true
  7117. even when the archive is compressed. Some devices requires that all
  7118. write operations be a multiple of a certain size, and so, @command{tar}
  7119. pads the archive out to the next record boundary.
  7120. The default blocking factor is set when @command{tar} is compiled, and is
  7121. typically 20. Blocking factors larger than 20 cannot be read by very
  7122. old versions of @command{tar}, or by some newer versions of @command{tar}
  7123. running on old machines with small address spaces.
  7124. With a magnetic tape, larger records give faster throughput and fit
  7125. more data on a tape (because there are fewer inter-record gaps).
  7126. If the archive is in a disk file or a pipe, you may want to specify
  7127. a smaller blocking factor, since a large one will result in a large
  7128. number of null bytes at the end of the archive.
  7129. When writing cartridge or other streaming tapes, a much larger
  7130. blocking factor (say 126 or more) will greatly increase performance.
  7131. However, you must specify the same blocking factor when reading or
  7132. updating the archive.
  7133. Apparently, Exabyte drives have a physical block size of 8K bytes.
  7134. If we choose our blocksize as a multiple of 8k bytes, then the problem
  7135. seems to disappear. Id est, we are using block size of 112 right
  7136. now, and we haven't had the problem since we switched@dots{}
  7137. With @GNUTAR{} the blocking factor is limited only
  7138. by the maximum record size of the device containing the archive, or by
  7139. the amount of available virtual memory.
  7140. However, deblocking or reblocking is virtually avoided in a special
  7141. case which often occurs in practice, but which requires all the
  7142. following conditions to be simultaneously true:
  7143. @itemize @bullet
  7144. @item
  7145. the archive is subject to a compression option,
  7146. @item
  7147. the archive is not handled through standard input or output, nor
  7148. redirected nor piped,
  7149. @item
  7150. the archive is directly handled to a local disk, instead of any special
  7151. device,
  7152. @item
  7153. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  7154. invocation.
  7155. @end itemize
  7156. If the output goes directly to a local disk, and not through
  7157. stdout, then the last write is not extended to a full record size.
  7158. Otherwise, reblocking occurs. Here are a few other remarks on this
  7159. topic:
  7160. @itemize @bullet
  7161. @item
  7162. @command{gzip} will complain about trailing garbage if asked to
  7163. uncompress a compressed archive on tape, there is an option to turn
  7164. the message off, but it breaks the regularity of simply having to use
  7165. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  7166. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  7167. Gailly, by sending a copy of this message to him.
  7168. @item
  7169. @command{compress} does not show this problem, but as Jean-loup pointed
  7170. out to Michael, @samp{compress -d} silently adds garbage after
  7171. the result of decompression, which tar ignores because it already
  7172. recognized its end-of-file indicator. So this bug may be safely
  7173. ignored.
  7174. @item
  7175. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  7176. but will still return an exit status of 2 which tar reports in turn.
  7177. @command{tar} might ignore the exit status returned, but I hate doing
  7178. that, as it weakens the protection @command{tar} offers users against
  7179. other possible problems at decompression time. If @command{gzip} was
  7180. silently skipping trailing zeros @emph{and} also avoiding setting the
  7181. exit status in this innocuous case, that would solve this situation.
  7182. @item
  7183. @command{tar} should become more solid at not stopping to read a pipe at
  7184. the first null block encountered. This inelegantly breaks the pipe.
  7185. @command{tar} should rather drain the pipe out before exiting itself.
  7186. @end itemize
  7187. @opindex ignore-zeros, short description
  7188. @item -i
  7189. @itemx --ignore-zeros
  7190. Ignore blocks of zeros in archive (means EOF).
  7191. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  7192. of zeros in the archive. Normally a block of zeros indicates the
  7193. end of the archive, but when reading a damaged archive, or one which
  7194. was created by concatenating several archives together, this option
  7195. allows @command{tar} to read the entire archive. This option is not on
  7196. by default because many versions of @command{tar} write garbage after
  7197. the zeroed blocks.
  7198. Note that this option causes @command{tar} to read to the end of the
  7199. archive file, which may sometimes avoid problems when multiple files
  7200. are stored on a single physical tape.
  7201. @opindex read-full-records, short description
  7202. @item -B
  7203. @itemx --read-full-records
  7204. Reblock as we read (for reading 4.2BSD pipes).
  7205. If @option{--read-full-records} is used, @command{tar}
  7206. will not panic if an attempt to read a record from the archive does
  7207. not return a full record. Instead, @command{tar} will keep reading
  7208. until it has obtained a full
  7209. record.
  7210. This option is turned on by default when @command{tar} is reading
  7211. an archive from standard input, or from a remote machine. This is
  7212. because on BSD Unix systems, a read of a pipe will return however
  7213. much happens to be in the pipe, even if it is less than @command{tar}
  7214. requested. If this option was not used, @command{tar} would fail as
  7215. soon as it read an incomplete record from the pipe.
  7216. This option is also useful with the commands for updating an archive.
  7217. @end table
  7218. Tape blocking
  7219. @FIXME{Appropriate options should be moved here from elsewhere.}
  7220. @cindex blocking factor
  7221. @cindex tape blocking
  7222. When handling various tapes or cartridges, you have to take care of
  7223. selecting a proper blocking, that is, the number of disk blocks you
  7224. put together as a single tape block on the tape, without intervening
  7225. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  7226. with no information on it, used for decelerating the tape to a
  7227. full stop, and for later regaining the reading or writing speed.
  7228. When the tape driver starts reading a record, the record has to
  7229. be read whole without stopping, as a tape gap is needed to stop the
  7230. tape motion without loosing information.
  7231. @cindex Exabyte blocking
  7232. @cindex DAT blocking
  7233. Using higher blocking (putting more disk blocks per tape block) will use
  7234. the tape more efficiently as there will be less tape gaps. But reading
  7235. such tapes may be more difficult for the system, as more memory will be
  7236. required to receive at once the whole record. Further, if there is a
  7237. reading error on a huge record, this is less likely that the system will
  7238. succeed in recovering the information. So, blocking should not be too
  7239. low, nor it should be too high. @command{tar} uses by default a blocking of
  7240. 20 for historical reasons, and it does not really matter when reading or
  7241. writing to disk. Current tape technology would easily accommodate higher
  7242. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  7243. We were told that for some DLT drives, the blocking should be a multiple
  7244. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  7245. Other manufacturers may use different recommendations for the same tapes.
  7246. This might also depends of the buffering techniques used inside modern
  7247. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  7248. Others request blocking to be some exponent of two.
  7249. So, there is no fixed rule for blocking. But blocking at read time
  7250. should ideally be the same as blocking used at write time. At one place
  7251. I know, with a wide variety of equipment, they found it best to use a
  7252. blocking of 32 to guarantee that their tapes are fully interchangeable.
  7253. I was also told that, for recycled tapes, prior erasure (by the same
  7254. drive unit that will be used to create the archives) sometimes lowers
  7255. the error rates observed at rewriting time.
  7256. I might also use @option{--number-blocks} instead of
  7257. @option{--block-number}, so @option{--block} will then expand to
  7258. @option{--blocking-factor} unambiguously.
  7259. @node Many
  7260. @section Many Archives on One Tape
  7261. @FIXME{Appropriate options should be moved here from elsewhere.}
  7262. @findex ntape @r{device}
  7263. Most tape devices have two entries in the @file{/dev} directory, or
  7264. entries that come in pairs, which differ only in the minor number for
  7265. this device. Let's take for example @file{/dev/tape}, which often
  7266. points to the only or usual tape device of a given system. There might
  7267. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7268. name is the @emph{rewinding} version of the device, while the name
  7269. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7270. device.
  7271. A rewinding tape device will bring back the tape to its beginning point
  7272. automatically when this device is opened or closed. Since @command{tar}
  7273. opens the archive file before using it and closes it afterwards, this
  7274. means that a simple:
  7275. @smallexample
  7276. $ @kbd{tar cf /dev/tape @var{directory}}
  7277. @end smallexample
  7278. @noindent
  7279. will reposition the tape to its beginning both prior and after saving
  7280. @var{directory} contents to it, thus erasing prior tape contents and
  7281. making it so that any subsequent write operation will destroy what has
  7282. just been saved.
  7283. @cindex tape positioning
  7284. So, a rewinding device is normally meant to hold one and only one file.
  7285. If you want to put more than one @command{tar} archive on a given tape, you
  7286. will need to avoid using the rewinding version of the tape device. You
  7287. will also have to pay special attention to tape positioning. Errors in
  7288. positioning may overwrite the valuable data already on your tape. Many
  7289. people, burnt by past experiences, will only use rewinding devices and
  7290. limit themselves to one file per tape, precisely to avoid the risk of
  7291. such errors. Be fully aware that writing at the wrong position on a
  7292. tape loses all information past this point and most probably until the
  7293. end of the tape, and this destroyed information @emph{cannot} be
  7294. recovered.
  7295. To save @var{directory-1} as a first archive at the beginning of a
  7296. tape, and leave that tape ready for a second archive, you should use:
  7297. @smallexample
  7298. $ @kbd{mt -f /dev/nrtape rewind}
  7299. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  7300. @end smallexample
  7301. @cindex tape marks
  7302. @dfn{Tape marks} are special magnetic patterns written on the tape
  7303. media, which are later recognizable by the reading hardware. These
  7304. marks are used after each file, when there are many on a single tape.
  7305. An empty file (that is to say, two tape marks in a row) signal the
  7306. logical end of the tape, after which no file exist. Usually,
  7307. non-rewinding tape device drivers will react to the close request issued
  7308. by @command{tar} by first writing two tape marks after your archive, and by
  7309. backspacing over one of these. So, if you remove the tape at that time
  7310. from the tape drive, it is properly terminated. But if you write
  7311. another file at the current position, the second tape mark will be
  7312. erased by the new information, leaving only one tape mark between files.
  7313. So, you may now save @var{directory-2} as a second archive after the
  7314. first on the same tape by issuing the command:
  7315. @smallexample
  7316. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7317. @end smallexample
  7318. @noindent
  7319. and so on for all the archives you want to put on the same tape.
  7320. Another usual case is that you do not write all the archives the same
  7321. day, and you need to remove and store the tape between two archive
  7322. sessions. In general, you must remember how many files are already
  7323. saved on your tape. Suppose your tape already has 16 files on it, and
  7324. that you are ready to write the 17th. You have to take care of skipping
  7325. the first 16 tape marks before saving @var{directory-17}, say, by using
  7326. these commands:
  7327. @smallexample
  7328. $ @kbd{mt -f /dev/nrtape rewind}
  7329. $ @kbd{mt -f /dev/nrtape fsf 16}
  7330. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7331. @end smallexample
  7332. In all the previous examples, we put aside blocking considerations, but
  7333. you should do the proper things for that as well. @xref{Blocking}.
  7334. @menu
  7335. * Tape Positioning:: Tape Positions and Tape Marks
  7336. * mt:: The @command{mt} Utility
  7337. @end menu
  7338. @node Tape Positioning
  7339. @subsection Tape Positions and Tape Marks
  7340. @UNREVISED
  7341. Just as archives can store more than one file from the file system,
  7342. tapes can store more than one archive file. To keep track of where
  7343. archive files (or any other type of file stored on tape) begin and
  7344. end, tape archive devices write magnetic @dfn{tape marks} on the
  7345. archive media. Tape drives write one tape mark between files,
  7346. two at the end of all the file entries.
  7347. If you think of data as a series of records "rrrr"'s, and tape marks as
  7348. "*"'s, a tape might look like the following:
  7349. @smallexample
  7350. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7351. @end smallexample
  7352. Tape devices read and write tapes using a read/write @dfn{tape
  7353. head}---a physical part of the device which can only access one
  7354. point on the tape at a time. When you use @command{tar} to read or
  7355. write archive data from a tape device, the device will begin reading
  7356. or writing from wherever on the tape the tape head happens to be,
  7357. regardless of which archive or what part of the archive the tape
  7358. head is on. Before writing an archive, you should make sure that no
  7359. data on the tape will be overwritten (unless it is no longer needed).
  7360. Before reading an archive, you should make sure the tape head is at
  7361. the beginning of the archive you want to read. You can do it manually
  7362. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7363. that automatically (@pxref{Scripted Restoration}).
  7364. If you want to add new archive file entries to a tape, you should
  7365. advance the tape to the end of the existing file entries, backspace
  7366. over the last tape mark, and write the new archive file. If you were
  7367. to add two archives to the example above, the tape might look like the
  7368. following:
  7369. @smallexample
  7370. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7371. @end smallexample
  7372. @node mt
  7373. @subsection The @command{mt} Utility
  7374. @UNREVISED
  7375. @FIXME{Is it true that this only works on non-block devices?
  7376. should explain the difference, (fixed or variable).}
  7377. @xref{Blocking Factor}.
  7378. You can use the @command{mt} utility to advance or rewind a tape past a
  7379. specified number of archive files on the tape. This will allow you
  7380. to move to the beginning of an archive before extracting or reading
  7381. it, or to the end of all the archives before writing a new one.
  7382. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7383. together"?}
  7384. The syntax of the @command{mt} command is:
  7385. @smallexample
  7386. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7387. @end smallexample
  7388. where @var{tapename} is the name of the tape device, @var{number} is
  7389. the number of times an operation is performed (with a default of one),
  7390. and @var{operation} is one of the following:
  7391. @FIXME{is there any use for record operations?}
  7392. @table @option
  7393. @item eof
  7394. @itemx weof
  7395. Writes @var{number} tape marks at the current position on the tape.
  7396. @item fsf
  7397. Moves tape position forward @var{number} files.
  7398. @item bsf
  7399. Moves tape position back @var{number} files.
  7400. @item rewind
  7401. Rewinds the tape. (Ignores @var{number}).
  7402. @item offline
  7403. @itemx rewoff1
  7404. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7405. @item status
  7406. Prints status information about the tape unit.
  7407. @end table
  7408. @FIXME{Is there a better way to frob the spacing on the list?}
  7409. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7410. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  7411. @file{/dev/rmt12}.
  7412. @command{mt} returns a 0 exit status when the operation(s) were
  7413. successful, 1 if the command was unrecognized, and 2 if an operation
  7414. failed.
  7415. @node Using Multiple Tapes
  7416. @section Using Multiple Tapes
  7417. @UNREVISED
  7418. Often you might want to write a large archive, one larger than will fit
  7419. on the actual tape you are using. In such a case, you can run multiple
  7420. @command{tar} commands, but this can be inconvenient, particularly if you
  7421. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7422. Therefore, @command{tar} supports multiple tapes automatically.
  7423. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7424. then @command{tar} will, when it reaches the end of the tape, prompt
  7425. for another tape, and continue the archive. Each tape will have an
  7426. independent archive, and can be read without needing the other. (As
  7427. an exception to this, the file that @command{tar} was archiving when
  7428. it ran out of tape will usually be split between the two archives; in
  7429. this case you need to extract from the first archive, using
  7430. @option{--multi-volume}, and then put in the second tape when
  7431. prompted, so @command{tar} can restore both halves of the file.)
  7432. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7433. You need @GNUTAR{} at both ends to process them properly.
  7434. When prompting for a new tape, @command{tar} accepts any of the following
  7435. responses:
  7436. @table @kbd
  7437. @item ?
  7438. Request @command{tar} to explain possible responses
  7439. @item q
  7440. Request @command{tar} to exit immediately.
  7441. @item n @var{file-name}
  7442. Request @command{tar} to write the next volume on the file @var{file-name}.
  7443. @item !
  7444. Request @command{tar} to run a subshell. This option can be disabled
  7445. by giving @option{--restrict} command line option to @command{tar}.
  7446. @item y
  7447. Request @command{tar} to begin writing the next volume.
  7448. @end table
  7449. (You should only type @samp{y} after you have changed the tape;
  7450. otherwise @command{tar} will write over the volume it just finished.)
  7451. @cindex End-of-archive info script
  7452. @cindex Info script
  7453. @anchor{info-script}
  7454. @opindex info-script
  7455. @opindex new-volume-script
  7456. If you want more elaborate behavior than this, give @command{tar} the
  7457. @option{--info-script=@var{script-name}}
  7458. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7459. @var{script-name}}) option. The file @var{script-name} is expected to
  7460. be a program (or shell script) to be run instead of the normal
  7461. prompting procedure. It is executed without any command line
  7462. arguments. Additional data is passed to it via the following
  7463. environment variables:
  7464. @table @env
  7465. @vrindex TAR_VERSION, info script environment variable
  7466. @item TAR_VERSION
  7467. @GNUTAR{} version number.
  7468. @vrindex TAR_ARCHIVE, info script environment variable
  7469. @item TAR_ARCHIVE
  7470. The name of the archive @command{tar} is processing.
  7471. @vrindex TAR_VOLUME, info script environment variable
  7472. @item TAR_VOLUME
  7473. Ordinal number of the volume @command{tar} is about to start.
  7474. @vrindex TAR_SUBCOMMAND, info script environment variable
  7475. @item TAR_SUBCOMMAND
  7476. Short option describing the operation @command{tar} is executed.
  7477. @xref{Operations}, for a complete list of subcommand options.
  7478. @vrindex TAR_FORMAT, info script environment variable
  7479. @item TAR_FORMAT
  7480. Format of the archive being processed. @xref{Formats}, for a complete
  7481. list of archive format names.
  7482. @end table
  7483. The info script can instruct @command{tar} to use new archive name,
  7484. by writing in to file descriptor 3 (see below for an
  7485. example).
  7486. If the info script fails, @command{tar} exits; otherwise, it begins
  7487. writing the next volume.
  7488. The method @command{tar} uses to detect end of tape is not perfect, and
  7489. fails on some operating systems or on some devices. You can use the
  7490. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7491. @command{tar} can't detect the end of the tape itself. This option
  7492. selects @option{--multi-volume} (@option{-M}) automatically. The
  7493. @var{size} argument should then be the usable size of the tape in
  7494. units of 1024 bytes. But for many devices, and floppy disks in
  7495. particular, this option is never required for real, as far as we know.
  7496. @cindex Volume number file
  7497. @cindex volno file
  7498. @anchor{volno-file}
  7499. @opindex volno-file
  7500. The volume number used by @command{tar} in its tape-change prompt
  7501. can be changed; if you give the
  7502. @option{--volno-file=@var{file-of-number}} option, then
  7503. @var{file-of-number} should be an unexisting file to be created, or
  7504. else, a file already containing a decimal number. That number will be
  7505. used as the volume number of the first volume written. When
  7506. @command{tar} is finished, it will rewrite the file with the
  7507. now-current volume number. (This does not change the volume number
  7508. written on a tape label, as per @ref{label}, it @emph{only} affects
  7509. the number used in the prompt.)
  7510. If you want @command{tar} to cycle through a series of files or tape
  7511. drives, there are three approaches to choose from. First of all, you
  7512. can give @command{tar} multiple @option{--file} options. In this case
  7513. the specified files will be used, in sequence, as the successive
  7514. volumes of the archive. Only when the first one in the sequence needs
  7515. to be used again will @command{tar} prompt for a tape change (or run
  7516. the info script). Secondly, you can use the @samp{n} response to the
  7517. tape-change prompt, and, finally, you can use an info script, that
  7518. writes new archive name to file descriptor. The following example
  7519. illustrates this approach:
  7520. @smallexample
  7521. @group
  7522. #! /bin/sh
  7523. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7524. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7525. case $TAR_SUBCOMMAND in
  7526. -c) ;;
  7527. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7528. ;;
  7529. *) exit 1
  7530. esac
  7531. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7532. @end group
  7533. @end smallexample
  7534. Each volume of a multi-volume archive is an independent @command{tar}
  7535. archive, complete in itself. For example, you can list or extract any
  7536. volume alone; just don't specify @option{--multi-volume}
  7537. (@option{-M}). However, if one file in the archive is split across
  7538. volumes, the only way to extract it successfully is with a
  7539. multi-volume extract command @option{--extract --multi-volume}
  7540. (@option{-xM}) starting on or before the volume where the file begins.
  7541. For example, let's presume someone has two tape drives on a system
  7542. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7543. to switch to the second drive when it needs to write the
  7544. second tape, and then back to the first tape, etc., just do either of:
  7545. @smallexample
  7546. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7547. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7548. @end smallexample
  7549. @menu
  7550. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7551. * Tape Files:: Tape Files
  7552. * Tarcat:: Concatenate Volumes into a Single Archive
  7553. @end menu
  7554. @node Multi-Volume Archives
  7555. @subsection Archives Longer than One Tape or Disk
  7556. @cindex Multi-volume archives
  7557. @UNREVISED
  7558. @opindex multi-volume
  7559. To create an archive that is larger than will fit on a single unit of
  7560. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7561. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7562. archive can be manipulated like any other archive (provided the
  7563. @option{--multi-volume} option is specified), but is stored on more
  7564. than one tape or disk.
  7565. When you specify @option{--multi-volume}, @command{tar} does not report an
  7566. error when it comes to the end of an archive volume (when reading), or
  7567. the end of the media (when writing). Instead, it prompts you to load
  7568. a new storage volume. If the archive is on a magnetic tape, you
  7569. should change tapes when you see the prompt; if the archive is on a
  7570. floppy disk, you should change disks; etc.
  7571. You can read each individual volume of a multi-volume archive as if it
  7572. were an archive by itself. For example, to list the contents of one
  7573. volume, use @option{--list}, without @option{--multi-volume} specified.
  7574. To extract an archive member from one volume (assuming it is described
  7575. that volume), use @option{--extract}, again without
  7576. @option{--multi-volume}.
  7577. If an archive member is split across volumes (ie. its entry begins on
  7578. one volume of the media and ends on another), you need to specify
  7579. @option{--multi-volume} to extract it successfully. In this case, you
  7580. should load the volume where the archive member starts, and use
  7581. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7582. volumes as it needs them. @xref{extracting archives}, for more
  7583. information about extracting archives.
  7584. @option{--info-script=@var{script-name}}
  7585. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7586. @var{script-name}}) (@pxref{info-script}) is like
  7587. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7588. not prompt you directly to change media volumes when a volume is
  7589. full---instead, @command{tar} runs commands you have stored in
  7590. @var{script-name}. For example, this option can be used to eject
  7591. cassettes, or to broadcast messages such as @samp{Someone please come
  7592. change my tape} when performing unattended backups. When
  7593. @var{script-name} is done, @command{tar} will assume that the media
  7594. has been changed.
  7595. Multi-volume archives can be modified like any other archive. To add
  7596. files to a multi-volume archive, you need to only mount the last
  7597. volume of the archive media (and new volumes, if needed). For all
  7598. other operations, you need to use the entire archive.
  7599. If a multi-volume archive was labeled using
  7600. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7601. (@pxref{label}) when it was created, @command{tar} will not
  7602. automatically label volumes which are added later. To label
  7603. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7604. in conjunction with the @option{--append}, @option{--update} or
  7605. @option{--concatenate} operation.
  7606. @cindex Labeling multi-volume archives
  7607. @FIXME{example}
  7608. @FIXME{There should be a sample program here, including an exit
  7609. before end. Is the exit status even checked in tar? :-(}
  7610. @table @option
  7611. @item --multi-volume
  7612. @itemx -M
  7613. Creates a multi-volume archive, when used in conjunction with
  7614. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7615. archive, specify @option{--multi-volume} in conjunction with that
  7616. operation.
  7617. @item --info-script=@var{program-file}
  7618. @itemx --new-volume-script=@var{program-file}
  7619. @itemx -F @var{program-file}
  7620. Creates a multi-volume archive via a script. Used in conjunction with
  7621. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7622. @end table
  7623. Beware that there is @emph{no} real standard about the proper way, for
  7624. a @command{tar} archive, to span volume boundaries. If you have a
  7625. multi-volume created by some vendor's @command{tar}, there is almost
  7626. no chance you could read all the volumes with @GNUTAR{}.
  7627. The converse is also true: you may not expect
  7628. multi-volume archives created by @GNUTAR{} to be
  7629. fully recovered by vendor's @command{tar}. Since there is little
  7630. chance that, in mixed system configurations, some vendor's
  7631. @command{tar} will work on another vendor's machine, and there is a
  7632. great chance that @GNUTAR{} will work on most of
  7633. them, your best bet is to install @GNUTAR{} on all
  7634. machines between which you know exchange of files is possible.
  7635. @node Tape Files
  7636. @subsection Tape Files
  7637. @UNREVISED
  7638. To give the archive a name which will be recorded in it, use the
  7639. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7640. option. This will write a special block identifying
  7641. @var{volume-label} as the name of the archive to the front of the
  7642. archive which will be displayed when the archive is listed with
  7643. @option{--list}. If you are creating a multi-volume archive with
  7644. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7645. volume label will have @samp{Volume @var{nnn}} appended to the name
  7646. you give, where @var{nnn} is the number of the volume of the archive.
  7647. (If you use the @option{--label=@var{volume-label}}) option when
  7648. reading an archive, it checks to make sure the label on the tape
  7649. matches the one you give. @xref{label}.
  7650. When @command{tar} writes an archive to tape, it creates a single
  7651. tape file. If multiple archives are written to the same tape, one
  7652. after the other, they each get written as separate tape files. When
  7653. extracting, it is necessary to position the tape at the right place
  7654. before running @command{tar}. To do this, use the @command{mt} command.
  7655. For more information on the @command{mt} command and on the organization
  7656. of tapes into a sequence of tape files, see @ref{mt}.
  7657. People seem to often do:
  7658. @smallexample
  7659. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7660. @end smallexample
  7661. or such, for pushing a common date in all volumes or an archive set.
  7662. @node Tarcat
  7663. @subsection Concatenate Volumes into a Single Archive
  7664. @pindex tarcat
  7665. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7666. archive to a single @command{tar} archive. Simply concatenating all
  7667. volumes into one will not work, since each volume carries an additional
  7668. information at the beginning. @GNUTAR{} is shipped with the shell
  7669. script @command{tarcat} designed for this purpose.
  7670. The script takes a list of files comprising a multi-volume archive
  7671. and creates the resulting archive at the standard output. For example:
  7672. @smallexample
  7673. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  7674. @end smallexample
  7675. The script implements a simple heuristics to determine the format of
  7676. the first volume file and to decide how to process the rest of the
  7677. files. However, it makes no attempt to verify whether the files are
  7678. given in order or even if they are valid @command{tar} archives.
  7679. It uses @command{dd} and does not filter its standard error, so you
  7680. will usually see lots of spurious messages.
  7681. @FIXME{The script is not installed. Should we install it?}
  7682. @node label
  7683. @section Including a Label in the Archive
  7684. @cindex Labeling an archive
  7685. @cindex Labels on the archive media
  7686. @UNREVISED
  7687. @opindex label
  7688. To avoid problems caused by misplaced paper labels on the archive
  7689. media, you can include a @dfn{label} entry---an archive member which
  7690. contains the name of the archive---in the archive itself. Use the
  7691. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7692. option in conjunction with the @option{--create} operation to include
  7693. a label entry in the archive as it is being created.
  7694. @table @option
  7695. @item --label=@var{archive-label}
  7696. @itemx -V @var{archive-label}
  7697. Includes an @dfn{archive-label} at the beginning of the archive when
  7698. the archive is being created, when used in conjunction with the
  7699. @option{--create} operation. Checks to make sure the archive label
  7700. matches the one specified (when used in conjunction with any other
  7701. operation.
  7702. @end table
  7703. If you create an archive using both
  7704. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7705. and @option{--multi-volume} (@option{-M}), each volume of the archive
  7706. will have an archive label of the form @samp{@var{archive-label}
  7707. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7708. next, and so on. @xref{Using Multiple Tapes}, for information on
  7709. creating multiple volume archives.
  7710. @cindex Volume label, listing
  7711. @cindex Listing volume label
  7712. The volume label will be displayed by @option{--list} along with
  7713. the file contents. If verbose display is requested, it will also be
  7714. explicitely marked as in the example below:
  7715. @smallexample
  7716. @group
  7717. $ @kbd{tar --verbose --list --file=iamanarchive}
  7718. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7719. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  7720. @end group
  7721. @end smallexample
  7722. @opindex test-label
  7723. @anchor{--test-label option}
  7724. However, @option{--list} option will cause listing entire
  7725. contents of the archive, which may be undesirable (for example, if the
  7726. archive is stored on a tape). You can request checking only the volume
  7727. by specifying @option{--test-label} option. This option reads only the
  7728. first block of an archive, so it can be used with slow storage
  7729. devices. For example:
  7730. @smallexample
  7731. @group
  7732. $ @kbd{tar --test-label --file=iamanarchive}
  7733. iamalabel
  7734. @end group
  7735. @end smallexample
  7736. If @option{--test-label} is used with a single command line
  7737. argument, @command{tar} compares the volume label with the
  7738. argument. It exits with code 0 if the two strings match, and with code
  7739. 2 otherwise. In this case no output is displayed. For example:
  7740. @smallexample
  7741. @group
  7742. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  7743. @result{} 0
  7744. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  7745. @result{} 1
  7746. @end group
  7747. @end smallexample
  7748. If you request any operation, other than @option{--create}, along
  7749. with using @option{--label} option, @command{tar} will first check if
  7750. the archive label matches the one specified and will refuse to proceed
  7751. if it does not. Use this as a safety precaution to avoid accidentally
  7752. overwriting existing archives. For example, if you wish to add files
  7753. to @file{archive}, presumably labelled with string @samp{My volume},
  7754. you will get:
  7755. @smallexample
  7756. @group
  7757. $ @kbd{tar -rf archive --label 'My volume' .}
  7758. tar: Archive not labeled to match `My volume'
  7759. @end group
  7760. @end smallexample
  7761. @noindent
  7762. in case its label does not match. This will work even if
  7763. @file{archive} is not labelled at all.
  7764. Similarly, @command{tar} will refuse to list or extract the
  7765. archive if its label doesn't match the @var{archive-label}
  7766. specified. In those cases, @var{archive-label} argument is interpreted
  7767. as a globbing-style pattern which must match the actual magnetic
  7768. volume label. @xref{exclude}, for a precise description of how match
  7769. is attempted@footnote{Previous versions of @command{tar} used full
  7770. regular expression matching, or before that, only exact string
  7771. matching, instead of wildcard matchers. We decided for the sake of
  7772. simplicity to use a uniform matching device through
  7773. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  7774. the volume label matcher will also suffix @var{archive-label} by
  7775. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  7776. up. Since the volume numbering is automatically added in labels at
  7777. creation time, it sounded logical to equally help the user taking care
  7778. of it when the archive is being read.
  7779. The @option{--label} was once called @option{--volume}, but is not
  7780. available under that name anymore.
  7781. You can also use @option{--label} to get a common information on
  7782. all tapes of a series. For having this information different in each
  7783. series created through a single script used on a regular basis, just
  7784. manage to get some date string as part of the label. For example:
  7785. @smallexample
  7786. @group
  7787. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7788. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7789. --volume="Daily backup for `date +%Y-%m-%d`"}
  7790. @end group
  7791. @end smallexample
  7792. Also note that each label has its own date and time, which corresponds
  7793. to when @GNUTAR{} initially attempted to write it,
  7794. often soon after the operator launches @command{tar} or types the
  7795. carriage return telling that the next tape is ready. Comparing date
  7796. labels does give an idea of tape throughput only if the delays for
  7797. rewinding tapes and the operator switching them were negligible, which
  7798. is usually not the case.
  7799. @node verify
  7800. @section Verifying Data as It is Stored
  7801. @cindex Verifying a write operation
  7802. @cindex Double-checking a write operation
  7803. @table @option
  7804. @item -W
  7805. @itemx --verify
  7806. @opindex verify, short description
  7807. Attempt to verify the archive after writing.
  7808. @end table
  7809. This option causes @command{tar} to verify the archive after writing it.
  7810. Each volume is checked after it is written, and any discrepancies
  7811. are recorded on the standard error output.
  7812. Verification requires that the archive be on a back-space-able medium.
  7813. This means pipes, some cartridge tape drives, and some other devices
  7814. cannot be verified.
  7815. You can insure the accuracy of an archive by comparing files in the
  7816. system with archive members. @command{tar} can compare an archive to the
  7817. file system as the archive is being written, to verify a write
  7818. operation, or can compare a previously written archive, to insure that
  7819. it is up to date.
  7820. @opindex verify, using with @option{--create}
  7821. @opindex create, using with @option{--verify}
  7822. To check for discrepancies in an archive immediately after it is
  7823. written, use the @option{--verify} (@option{-W}) option in conjunction with
  7824. the @option{--create} operation. When this option is
  7825. specified, @command{tar} checks archive members against their counterparts
  7826. in the file system, and reports discrepancies on the standard error.
  7827. To verify an archive, you must be able to read it from before the end
  7828. of the last written entry. This option is useful for detecting data
  7829. errors on some tapes. Archives written to pipes, some cartridge tape
  7830. drives, and some other devices cannot be verified.
  7831. One can explicitly compare an already made archive with the file
  7832. system by using the @option{--compare} (@option{--diff}, @option{-d})
  7833. option, instead of using the more automatic @option{--verify} option.
  7834. @xref{compare}.
  7835. Note that these two options have a slightly different intent. The
  7836. @option{--compare} option checks how identical are the logical contents of some
  7837. archive with what is on your disks, while the @option{--verify} option is
  7838. really for checking if the physical contents agree and if the recording
  7839. media itself is of dependable quality. So, for the @option{--verify}
  7840. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7841. the archive, while it lets the speed optimization undisturbed for the
  7842. @option{--compare} option. If you nevertheless use @option{--compare} for
  7843. media verification, you may have to defeat the in-memory cache yourself,
  7844. maybe by opening and reclosing the door latch of your recording unit,
  7845. forcing some doubt in your operating system about the fact this is really
  7846. the same volume as the one just written or read.
  7847. The @option{--verify} option would not be necessary if drivers were indeed
  7848. able to detect dependably all write failures. This sometimes require many
  7849. magnetic heads, some able to read after the writes occurred. One would
  7850. not say that drivers unable to detect all cases are necessarily flawed,
  7851. as long as programming is concerned.
  7852. The @option{--verify} (@option{-W}) option will not work in
  7853. conjunction with the @option{--multi-volume} (@option{-M}) option or
  7854. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  7855. and @option{--delete} operations. @xref{Operations}, for more
  7856. information on these operations.
  7857. Also, since @command{tar} normally strips leading @samp{/} from file
  7858. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  7859. /tmp/foo.tar /etc} will work as desired only if the working directory is
  7860. @file{/}, as @command{tar} uses the archive's relative member names
  7861. (e.g., @file{etc/motd}) when verifying the archive.
  7862. @node Write Protection
  7863. @section Write Protection
  7864. Almost all tapes and diskettes, and in a few rare cases, even disks can
  7865. be @dfn{write protected}, to protect data on them from being changed.
  7866. Once an archive is written, you should write protect the media to prevent
  7867. the archive from being accidentally overwritten or deleted. (This will
  7868. protect the archive from being changed with a tape or floppy drive---it
  7869. will not protect it from magnet fields or other physical hazards).
  7870. The write protection device itself is usually an integral part of the
  7871. physical media, and can be a two position (write enabled/write
  7872. disabled) switch, a notch which can be popped out or covered, a ring
  7873. which can be removed from the center of a tape reel, or some other
  7874. changeable feature.
  7875. @node Changes
  7876. @appendix Changes
  7877. This appendix lists some important user-visible changes between
  7878. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  7879. version of this document is available at
  7880. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  7881. @GNUTAR{} documentation page}.
  7882. @table @asis
  7883. @item Use of globbing patterns when listing and extracting.
  7884. Previous versions of GNU tar assumed shell-style globbing when
  7885. extracting from or listing an archive. For example:
  7886. @smallexample
  7887. $ @kbd{tar xf foo.tar '*.c'}
  7888. @end smallexample
  7889. would extract all files whose names end in @samp{.c}. This behavior
  7890. was not documented and was incompatible with traditional tar
  7891. implementations. Therefore, starting from version 1.15.91, GNU tar
  7892. no longer uses globbing by default. For example, the above invocation
  7893. is now interpreted as a request to extract from the archive the file
  7894. named @file{*.c}.
  7895. To facilitate transition to the new behavior for those users who got
  7896. used to the previous incorrect one, @command{tar} will print a warning
  7897. if it finds out that a requested member was not found in the archive
  7898. and its name looks like a globbing pattern. For example:
  7899. @smallexample
  7900. $ @kbd{tar xf foo.tar '*.c'}
  7901. tar: Pattern matching characters used in file names. Please,
  7902. tar: use --wildcards to enable pattern matching, or --no-wildcards to
  7903. tar: suppress this warning.
  7904. tar: *.c: Not found in archive
  7905. tar: Error exit delayed from previous errors
  7906. @end smallexample
  7907. To treat member names as globbing patterns, use --wildcards option.
  7908. If you want to tar to mimic the behavior of versions prior to 1.15.91,
  7909. add this option to your @env{TAR_OPTIONS} variable.
  7910. @xref{Wildcards}, for the detailed discussion of the use of globbing
  7911. patterns by @GNUTAR{}.
  7912. @item Use of short option @option{-o}.
  7913. Earlier versions of @GNUTAR{} understood @option{-o} command line
  7914. option as a synonym for @option{--old-archive}.
  7915. @GNUTAR{} starting from version 1.13.90 understands this option as
  7916. a synonym for @option{--no-same-owner}. This is compatible with
  7917. UNIX98 @command{tar} implementations.
  7918. However, to facilitate transition, @option{-o} option retains its
  7919. old semantics when it is used with one of archive-creation commands.
  7920. Users are encouraged to use @option{--format=oldgnu} instead.
  7921. It is especially important, since versions of @acronym{GNU} Automake
  7922. up to and including 1.8.4 invoke tar with this option to produce
  7923. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  7924. of this issue and its implications.
  7925. @FIXME{Change the first argument to tar-formats if and when Automake
  7926. people accept my patch to the documentation, and the new Automake is
  7927. out --Sergey 2006-05-25}.
  7928. @xref{Options, tar-v7, Changing Automake's Behavior,
  7929. automake, GNU Automake}, for a description on how to use various
  7930. archive formats with @command{automake}.
  7931. Future versions of @GNUTAR{} will understand @option{-o} only as a
  7932. synonym for @option{--no-same-owner}.
  7933. @item Use of short option @option{-l}
  7934. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  7935. synonym for @option{--one-file-system}. Since such usage contradicted
  7936. to UNIX98 specification and harmed compatibility with other
  7937. implementation, it was declared deprecated in version 1.14. However,
  7938. to facilitate transition to its new semantics, it was supported by
  7939. versions 1.15 and 1.15.90. The present use of @option{-l} as a short
  7940. variant of @option{--check-links} was introduced in version 1.15.91.
  7941. @item Use of options @option{--portability} and @option{--old-archive}
  7942. These options are deprecated. Please use @option{--format=v7} instead.
  7943. @item Use of option @option{--posix}
  7944. This option is deprecated. Please use @option{--format=posix} instead.
  7945. @end table
  7946. @node Configuring Help Summary
  7947. @appendix Configuring Help Summary
  7948. Running @kbd{tar --help} displays the short @command{tar} option
  7949. summary (@pxref{help}). This summary is organised by @dfn{groups} of
  7950. semantically close options. The options within each group are printed
  7951. in the following order: a short option, eventually followed by a list
  7952. of corresponding long option names, followed by a short description of
  7953. the option. For example, here is an excerpt from the actual @kbd{tar
  7954. --help} output:
  7955. @verbatim
  7956. Main operation mode:
  7957. -A, --catenate, --concatenate append tar files to an archive
  7958. -c, --create create a new archive
  7959. -d, --diff, --compare find differences between archive and
  7960. file system
  7961. --delete delete from the archive
  7962. @end verbatim
  7963. @vrindex ARGP_HELP_FMT, environment variable
  7964. The exact visual representation of the help output is configurable via
  7965. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  7966. is a comma-separated list of @dfn{format variable} assignments. There
  7967. are two kinds of format variables. An @dfn{offset variable} keeps the
  7968. offset of some part of help output text from the leftmost column on
  7969. the screen. A @dfn{boolean} variable is a flag that toggles some
  7970. output feature on or off. Depending on the type of the corresponding
  7971. variable, there are two kinds of assignments:
  7972. @table @asis
  7973. @item Offset assignment
  7974. The assignment to an offset variable has the following syntax:
  7975. @smallexample
  7976. @var{variable}=@var{value}
  7977. @end smallexample
  7978. @noindent
  7979. where @var{variable} is the variable name, and @var{value} is a
  7980. numeric value to be assigned to the variable.
  7981. @item Boolean assignment
  7982. To assign @code{true} value to a variable, simply put this variable name. To
  7983. assign @code{false} value, prefix the variable name with @samp{no-}. For
  7984. example:
  7985. @smallexample
  7986. @group
  7987. # Assign @code{true} value:
  7988. dup-args
  7989. # Assign @code{false} value:
  7990. no-dup-args
  7991. @end group
  7992. @end smallexample
  7993. @end table
  7994. Following variables are declared:
  7995. @deftypevr {Help Output} boolean dup-args
  7996. If true, arguments for an option are shown with both short and long
  7997. options, even when a given option has both forms, for example:
  7998. @smallexample
  7999. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  8000. @end smallexample
  8001. If false, then if an option has both short and long forms, the
  8002. argument is only shown with the long one, for example:
  8003. @smallexample
  8004. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8005. @end smallexample
  8006. @noindent
  8007. and a message indicating that the argument is applicable to both
  8008. forms is printed below the options. This message can be disabled
  8009. using @code{dup-args-note} (see below).
  8010. The default is false.
  8011. @end deftypevr
  8012. @deftypevr {Help Output} boolean dup-args-note
  8013. If this variable is true, which is the default, the following notice
  8014. is displayed at the end of the help output:
  8015. @quotation
  8016. Mandatory or optional arguments to long options are also mandatory or
  8017. optional for any corresponding short options.
  8018. @end quotation
  8019. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  8020. variables @code{dup-args} or @code{dup-args-note} should be set.
  8021. @end deftypevr
  8022. @deftypevr {Help Output} offset short-opt-col
  8023. Column in which short options start. Default is 2.
  8024. @smallexample
  8025. @group
  8026. $ @kbd{tar --help|grep ARCHIVE}
  8027. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8028. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  8029. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8030. @end group
  8031. @end smallexample
  8032. @end deftypevr
  8033. @deftypevr {Help Output} offset long-opt-col
  8034. Column in which long options start. Default is 6. For example:
  8035. @smallexample
  8036. @group
  8037. $ @kbd{tar --help|grep ARCHIVE}
  8038. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8039. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  8040. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8041. @end group
  8042. @end smallexample
  8043. @end deftypevr
  8044. @deftypevr {Help Output} offset doc-opt-col
  8045. Column in which @dfn{doc options} start. A doc option isn't actually
  8046. an option, but rather an arbitrary piece of documentation that is
  8047. displayed in much the same manner as the options. For example, in
  8048. the description of @option{--format} option:
  8049. @smallexample
  8050. @group
  8051. -H, --format=FORMAT create archive of the given format.
  8052. FORMAT is one of the following:
  8053. gnu GNU tar 1.13.x format
  8054. oldgnu GNU format as per tar <= 1.12
  8055. pax POSIX 1003.1-2001 (pax) format
  8056. posix same as pax
  8057. ustar POSIX 1003.1-1988 (ustar) format
  8058. v7 old V7 tar format
  8059. @end group
  8060. @end smallexample
  8061. @noindent
  8062. the format names are doc options. Thus, if you set
  8063. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  8064. will look as follows:
  8065. @smallexample
  8066. @group
  8067. -H, --format=FORMAT create archive of the given format.
  8068. FORMAT is one of the following:
  8069. gnu GNU tar 1.13.x format
  8070. oldgnu GNU format as per tar <= 1.12
  8071. pax POSIX 1003.1-2001 (pax) format
  8072. posix same as pax
  8073. ustar POSIX 1003.1-1988 (ustar) format
  8074. v7 old V7 tar format
  8075. @end group
  8076. @end smallexample
  8077. @end deftypevr
  8078. @deftypevr {Help Output} offset opt-doc-col
  8079. Column in which option description starts. Default is 29.
  8080. @smallexample
  8081. @group
  8082. $ @kbd{tar --help|grep ARCHIVE}
  8083. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8084. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  8085. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8086. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  8087. -f, --file=ARCHIVE
  8088. use archive file or device ARCHIVE
  8089. @end group
  8090. @end smallexample
  8091. @noindent
  8092. Notice, that the description starts on a separate line if
  8093. @code{opt-doc-col} value is too small.
  8094. @end deftypevr
  8095. @deftypevr {Help Output} offset header-col
  8096. Column in which @dfn{group headers} are printed. A group header is a
  8097. descriptive text preceding an option group. For example, in the
  8098. following text:
  8099. @verbatim
  8100. Main operation mode:
  8101. -A, --catenate, --concatenate append tar files to
  8102. an archive
  8103. -c, --create create a new archive
  8104. @end verbatim
  8105. @noindent
  8106. @samp{Main operation mode:} is the group header.
  8107. The default value is 1.
  8108. @end deftypevr
  8109. @deftypevr {Help Output} offset usage-indent
  8110. Indentation of wrapped usage lines. Affects @option{--usage}
  8111. output. Default is 12.
  8112. @end deftypevr
  8113. @deftypevr {Help Output} offset rmargin
  8114. Right margin of the text output. Used for wrapping.
  8115. @end deftypevr
  8116. @node Genfile
  8117. @appendix Genfile
  8118. @include genfile.texi
  8119. @node Snapshot Files
  8120. @appendix Format of the Incremental Snapshot Files
  8121. @include snapshot.texi
  8122. @node Free Software Needs Free Documentation
  8123. @appendix Free Software Needs Free Documentation
  8124. @include freemanuals.texi
  8125. @node Copying This Manual
  8126. @appendix Copying This Manual
  8127. @menu
  8128. * GNU Free Documentation License:: License for copying this manual
  8129. @end menu
  8130. @include fdl.texi
  8131. @node Index of Command Line Options
  8132. @appendix Index of Command Line Options
  8133. This appendix contains an index of all @GNUTAR{} long command line
  8134. options. The options are listed without the preceeding double-dash.
  8135. @FIXME{@itemize
  8136. @item Make sure @emph{all} options are indexed.
  8137. @item Provide an index of short options
  8138. @end itemize}
  8139. @printindex op
  8140. @node Index
  8141. @appendix Index
  8142. @printindex cp
  8143. @summarycontents
  8144. @contents
  8145. @bye
  8146. @c Local variables:
  8147. @c texinfo-column-for-description: 32
  8148. @c End: