h1

All you need to remember about tar

February 10, 2011

The first thing to remember about tar is that tar is primarily for turning a directory into a file so you only have one thing to send rather than a direcotry with lots of things. Its second use is to then compress that file. So if you want to compress a single file, you first need to put it into a directory before using tar.

Most useful options:
1. Decide if you are creating or extracting to or from a tar and use one of the following…
c – create a tar from a dir
x – extract contents from a tar

2. Decide on the compression standard
z – gzip, the usual one
j – bz, makes smaller files but takes longer to process

3. Do you want lots of messgaes? Use v for verbose, usful to see that something is actually happening

4. Your options will always finish with f and after you specify the name of the tar file you are either creating or extracting from. File name convension is filename.tar.gz if using gzip or finish with bz if using the other compression option.

5. If you are creating a tar, finish with the name of the directory you want to tar.

Examples:
Turning directory mydir into a tar and compressing with gzip:
tar czvf mydir.tar.gz mydir

Extracting directory mydir from a tar which is compressed with gzip:
tar xzvf mydir.tar.gz

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: