Contents / Previous / Next


Archiving with tar

When many files (and directories) are packed together into one, this packed file is called an archive.

Usually archives have the extension .tar, which stands for tape archive.

To create an archive of directories and files, use the tar command:
tar cf archive_name.tar  directory file ....
To list the table of contents of an archive do:
tar tf archive_name.tar  directory file ....
To restore it use the extract option of the tar:
tar xf archive_name.tar  directory file ....

Examples (write you home directory to an archive):

   tar cvf my_home.tar  ~

 "v" stands for verify (not necessary)

Compressed Archives

You man run gzip on a .tar file and create a file named:
archive_name.tar.gz or archive_name.tgz

You can also use tar directly to compress,
adding the "z" or "j" option for gzip or bzip2::
tar cjf archive_name.tar  directory file ....

Examples (write you home dir to an compressed archive):

   tar cjvf my_home.tar  ~