¿Cómo
hago...?
Usando Tar y Gzip:
Regresar
En Linux nos encontramos casi siempre con archivos que tienen
las siguientes extensiones:
.TAR, .TAR.GZ o .TGZ (entre otras que discutiremos luego).
La extensión .TAR nos indica que el file xxxx.TAR contiene
varios archivos. Estos archivos,
no están comprimidos, solo se han juntado en un archivo final.
El comando TAR, posee la característica de "juntar" varios
archivos en uno, guardando los
permisos,los
path, etc., o sea, no pierde ningun atributo de los archivos originales.
¿Que ganamos con esto?:
Simplemente crear un file archivo.TAR que contenga todos los archivos de
un directorio o
de varios directorios, o todo un árbol completo de directorios con sus
archivos.
¿Para que nos sirve?:
Para guardar en un solo archivo todos los archivos que queramos.
¿Como utilizo el comando TAR?:
El comando TAR, tiene su ayuda, si en la consola tecleamos:
$ tar --help <enter>
Nos dará algo como lo que sigue:
Usage: tar
[OPTION]... [FILE]...
Mandatory or optional arguments to long options are mandatory or optional
for short options too.
Main operation mode:
-t, --list list the contents of an archive
-x, --extract, --get extract files from an archive
-c, --create create a new archive
-d, --diff, --compare find differences between archive and file system
-r, --append append files to the end of an archive
-u, --update only append files newer than copy in archive
-A, --catenate append tar files to an archive
--concatenate same as -A
--delete delete from the archive (not on mag tapes!)
Operation mode modificators:
-W, --verify attempt to verify the archive after writing it
--remove-files remove files after adding them to the archive
-k, --keep-old-files don't overwrite existing files from archive
-S, --sparse handle sparse files efficiently
-O, --to-stdout extract files to standard output
-G, --incremental handle old GNU-format incremental backup
-g, --listed-incremental handle new GNU-format incremental backup
--ignore-failed-read do not exit with non-zero on unreadable files
Handling of file attributes:
--atime-preserve don't change access times on dumped files
-m, --modification-time don't extract file modified time
--same-owner create extracted files with the same ownership
-p, --same-permissions extract all protection information
--preserve-permissions same as -p
-s, --same-order sort names to extract to match archive
--preserve-order same as -s
--preserve same as both -p and -s
Device selection and switching:
-f, --file=[HOSTNAME:]FILE use archive file or device FILE on HOSTNAME
--force-local archive file is local even if has a colon
--rsh-command=COMMAND use remote COMMAND instead of rsh
-[0-7][lmh] specify drive and density
-M, --multi-volume create/list/extract multi-volume archive
-L, --tape-length=NUM change tape after writing NUM x 1024 bytes
-F, --info-script=FILE run script at end of each tape (implies -M)
--new-volume-script=FILE same as -F FILE
Device blocking:
-b, --block-size=BLOCKS block size of BLOCKS x 512 bytes
--block-compress block the output of compression for tapes
-i, --ignore-zeros ignore blocks of zeros in archive (means EOF)
-B, --read-full-blocks reblock as we read (for reading 4.2BSD pipes)
Archive format selection:
-V, --label=NAME create archive with volume name NAME
-o, --old-archive, --portability write a V7 format archive (not ANSI)
-z, --gzip, --ungzip filter the archive through gzip
-Z, --compress, --uncompress filter the archive through compress
--use-compress-program=PROG filter through PROG (must accept -d)
Local file selection:
-C, --directory DIR change to directory DIR
-T, --files-from=NAME get names to extract or create from file NAME
--null -T reads null-terminated names, disable -C
--exclude=FILE exclude file FILE
-X, --exclude-from=FILE exclude files listed in FILE
-P, --absolute-paths don't strip leading `/'s from file names
-h, --dereference dump instead the files symlinks point to
-l, --one-file-system stay in local file system when creating archive
-K, --starting-file=NAME begin at file NAME in the archive
-N, --newer=DATE only store files newer than DATE
--after-date=DATE same as -N
Informative output:
--help print this help, then exit
--version print tar program version number, then exit
-v, --verbose verbosely list files processed
--checkpoint print directory names while reading the archive
--totals print total bytes written while creating archive
-R, --record-number show record number within archive with each message
-w, --interactive ask for confirmation for every action
--confirmation same as -w
On *this* particular tar, the defaults are -f - and -b 20.
Como
podemos ver las opciones son muchísimas.
En este documento solo explicaré las que se utilizan básicamente,
luego
quien quiera experimentar con las demás, queda a su criterio.
Home Page