Making archive files in Linux |
|
The Linux tar utility is the preferred tool for building and extracting files from archives. The archives are referred to as “tarballs”.
To make a tarball, use this command:
tar -cvzf archname.tgz file...where archname is an arbitrary name, and each file can be either an ordinary file or a directory. If a directory, all the files and directories under that directory are included in the tarball.
Be sure to use relative path names for the files. If you use an absolute path name, that absolute path may not exist on some other system.
Here's an example. Your current working directory has a file in it named wapiti, and two subdirectories named tawny and bactrian. This command would combine all the file and directories into a tarball archive named elk.tgz:
tar -cvzf elk.tgz tawny bactrian wapiti
For the procedures you will use to extract some or all files from a tarball, see `Extracting archive files in Linux'.
For complete instructions for the tar command, see the man page for tar.