BSD Guides :: Doing Stuff With FreeBSD, NetBSD, OpenBSD, & Mac OS X

Creating Compressed Archives
Updated: 11/14/2004


General Information

You've downloaded them, you've extracted them, you've liked them.  But how do you create them?  This guide will show you how to quickly and easily create a compressed archive in the form of *.tar.gz and *.tar.bz2.

Requirements

  1. Local access on the box.
  2. A SSH client such as puTTy or SecureCRT (if you are setting it up remotely).
  3. Files you want to archive.

Usage

# tar -cvf archive.tar file
The -c flag tells tar to create a new archive.  The -v flag tells tar to display the results while tarring.  The -f flag tells tar to create a file named archive.tar.  You can either tar directories or files specificied by file.  You can enter several files/directories separated by spaces if you want.

There are two common methods of compression:
#
#
tar -cvzf archive.tar.gz file
tar -cvjf archive.tar.bz2 file
The -z flag indicates to run the archive through gzip while the -j runs the archive through bzip2.

That's all there is to making your compressed archives.


Author: Jon LaBass
jon at bsdguides dot org

Find this guide useful?
Support the author: