How To Tar And Untar Files In Linux Using The Tar Command

Forums » Linux Systems » How To Tar And Untar Files In Linux Using The Tar Command
This Page Contains information about How To Tar And Untar Files In Linux Using The Tar Command By wallpaperama in category Linux Systems with 3 Replies. Last Upated: Thu May 15, 2014

How To Tar


compressing: www/ directory:
tar -pczf filename.tar.gz www/


How To UnTar


untaring filename.tar.gz
tar xvfz filename.tar.gz


Thats it, that the most simple way i can show you.

hope this helps
NAME
       tar - The GNU version of the tar archiving utility

SYNOPSIS
       tar <operation> [options]

       Operations:
       [-]A --catenate --concatenate
       [-]c --create
       [-]d --diff --compare
       [-]r --append
       [-]t --list
       [-]u --update
       [-]x --extract --get
       --delete

       Common Options:
       -C, --directory DIR
       -f, --file F
       -j, --bzip2
       -p, --preserve-permissions
       -v, --verbose
       -z, --gzip
DESCRIPTION
       This manual page documents the GNU version of tar, an archiving program designed  to
       store  and  extract files from an archive file known as a tarfile.  A tarfile may be
       made on a tape drive, however, it is also common to write  a  tarfile  to  a  normal
       file.  The first argument to tar must be one of the options Acdrtux, followed by any
       optional functions.  The final arguments to tar are the names of the files or direc-
       tories  which  should  be archived.  The use of a directory name always implies that
       the subdirectories below should be included in the archive.

EXAMPLES
       tar -xvf foo.tar
              verbosely extract foo.tar

       tar -xzf foo.tar.gz
              extract gzipped foo.tar.gz

       tar -cjf foo.tar.bz2 bar/
              create bzipped tar archive of the directory bar called foo.tar.bz2

       tar -xjf foo.tar.bz2 -C bar/
              extract bzipped foo.tar.bz2 after changing directory to bar

       tar -xzf foo.tar.gz blah.txt
              extract the file blah.txt from foo.tar.gz

FUNCTION LETTERS
       One of the following options must be used:

       -A, --catenate, --concatenate
              append tar files to 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

       -t, --list
              list the contents of an archive

       -u, --update
              only append files that are newer than the existing in archive

       -x, --extract, --get
              extract files from an archive

       --delete
              delete from the archive (not for use on mag tapes!)
COMMON OPTIONS
       -C, --directory DIR
              change to directory DIR

       -f, --file [HOSTNAME:]F
              use archive file or device F (default "-", meaning stdin/stdout)

       -j, --bzip2
              filter archive through bzip2, use to decompress .bz2 files

       -p, --preserve-permissions
              extract all protection information

       -v, --verbose
              verbosely list files processed

       -z, --gzip, --ungzip
              filter the archive through gzip

ALL OPTIONS
       --atime-preserve
              don't change access times on dumped files

       -b, --blocking-factor N
              block size of Nx512 bytes (default N=20)

       -B, --read-full-blocks
              reblock as we read (for reading 4.2BSD pipes)

       --backup BACKUP-TYPE
              backup files instead of deleting them using BACKUP-TYPE simple or numbered

       --block-compress
              block the output of compression program for tapes

       -C, --directory DIR
              change to directory DIR

       --check-links
              warn if number of hard links to the file on the filesystem mismatch the  num-
              ber of links recorded in the archive

       --checkpoint
              print directory names while reading the archive

       -f, --file [HOSTNAME:]F
              use archive file or device F (default "-", meaning stdin/stdout)

       -F, --info-script F --new-volume-script F
              run script at end of each tape (implies --multi-volume)


wallpaperama
this is how you would tar into a directory:

tar xvfz images.tar.gz -c /root/test_tar/files/

lets say i am in /root sending this command, then it will untar the files into this directory: /root/test_tar/files/
Iban
"Thats it, that the most simple way i can show you. hope this helps" Yes, it helped. It's just what I needed. Thanks.
japdatsme
Title: How To Tar And Untar Files In Linux Using The Tar Command [3049]
Tags: how to tar and untar files in linux
By
Comments 3
Visits 41440