Sunday, November 29, 2009

Re: [LINUX_Newbies] tar.gz,bz etc

 

On Sun, Nov 29, 2009 at 00:26, kcdomapps <kcdomapps@yahoo.co.uk> wrote:
> Hi,can someone please compile an absolute idiots guide to installing programs that are downloaded as tar files etc.I have read on line that you have to create a folder etc but even that wasn't that clear!
> Thanks
> Kelvin

Sure... but first... Folders exist in Windows. Linux has Directories.
Not that I'm trying to sound deliberately difficult, but nomenclature
is important ;-)

More seriously though, think of it like this... a tarball is pretty
much the same thing as a Zip or RAR file. So first, definitions:

tarball, tar file, etc = archives made using the tar program (a
command that's way older than LInux, I might add)
.gz, .bz = files that were compressed using gzip or bzip respectively.
tar.gz, tar.bz = tarballs that have been compressed using gzip or bzip.

So there ya go... definitions.

You ever see those space saver bags that you can store your pillows
and sweaters and such in? They're sealable bags that you can put your
soft things in, then vacuum out all the air with a standard vacuum
cleaner which shrinks them down allowing you to pack more stuff in
your closet or under your bed.

So what's that got to do with your question? It's a analogy. I like
analogies. And at least I didn't use a car analogy...

So the tar file is like that bag. It's just something that stores
other things... either directories, or individual files. gzip and
bzip are like the vacuum cleaner.

So, lets say you have a directory full of text files that you want to
back up, or store, or ship off to someone else. To do that, you'd
create a tar file that is just an archive (or think of it like a
single file that is a backup of that entire directory, or think of it
like you stuck a copy of those text files in a bag). Now you've got
your bag full of text files, but it still takes up too much space. So
you want to vacuum all the air out to make it smaller.

That's where you bring in gzip or bzip. So you run gzip on your
tarball and now you have a much smaller, compressed archive of your
directory. And if you did it right, it's now named something like
myfiles.tar.gz.

But that's two commands you have to run... two tools to get the
result. Thankfully, for quite a long while now, tar has included
hooks to directly use gzip and bzip while it creates the tarball.

For instance: tar -c -f -z myfiles.tar.gz /home/user/files

will create a file called myfiles.tar.gz that contains every file in
the /home/user/files directory.

tar cfz myfiles.tar.gz /home/textfile1 /home/textfile2 /home/textfile3
/home/binaryfile1

will create a file called myfiles.tar.gz that contains those four files.

In both examples, the resulting tar file is compressed.

So hopefully that will make the next part clear.

You were told that you needed to create a folder. Yes and no. For
what it's worth, I always create a temporary folder to open tarballs
in...just because there have been too many times when I've opened one
that was just a bunch of files, only to have those files now littering
my home directory, or /etc or some other location.

So while you don't HAVE to create a separate directory, it's a good
idea to do so anyway, then move the files where you need them later...
or if the tarball contains source and a program, there's usually an
install.sh script that will install everything in the right place for
you.

so the "Dummies" version of unpacking a tarball...

1: create a temp directory
mkdir mytempdir

2: move or copy the tar.gz file into that directory
cp /path/to/mytarball.tar.gz /path/to/mytempdir

3: untar it
tar zxvf mytarball.tar.gz

and now you'll have either a directory full of stuff, or you'll have
lots of files... but that's all there is to it.

the zxvf in that command are flags. z tells tar to run the file
through gzip or gunzip, depending on whether you're asking tar to
create or extract a tarball.

the x is extract. In my first two examples, I used cfz. In those,
the c is for create.

the v is for verify.

the f tells tar to open the following filename

and there are many MANY more options for tar.

Open a console and type "man tar" and hit enter.

You can use tar for a LOT of things... creating archives, writing to
and reading from tape drives or other special devices, backing up and
restoring files and computers, etc...

I can't give you a full "Dummies Guide to Tar" because that would be,
and IS a book in and of itself. Yes there are entire books dedicated
to using Tar...

but hope that helps get you going...

Feel free to ask away if this gives you more questions, and sorry for
wandering, if I have... it's late, and I'm tired... :)

Cheers,

Jeff

--

Mike Ditka - "If God had wanted man to play soccer, he wouldn't have
given us arms." -
http://www.brainyquote.com/quotes/authors/m/mike_ditka.html

__._,_.___
To unsubscribe from this list, please email LINUX_Newbies-unsubscribe@yahoogroups.com & you will be removed.
.

__,_._,___

No comments:

Post a Comment