LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to creat a Tar Ball (http://www.linuxquestions.org/questions/linux-general-1/how-to-creat-a-tar-ball-4175451713/)

Ztcoracat 02-25-2013 11:58 PM

How to creat a Tar Ball
 
Hi:

First time attempting "creating a tarball" and having trouble understanding what the terminal needs.

Read this page to help myself:
http://www.cyberciti.biz/faq/creatin...-command-line/

I'm wondering what else should be executed and what directory is generally the desired one to untar things in?

I went to my Home folder and created a new file 'TARS'
I than created a new empty document and titled it 'Practice'
This is what I have so far but have not a clue what the next step is that I should be initiating or what else I need to do-

Code:

ztcoracat:~$ tar cvzf tarfile.tar.gz TARS
TARS/
TARS/Practice
ztcoracat:~$

Where will Debian put this tar-ball that I have created and any other tar that I create in the future?

Does that depend on what directory I am in at the present or does that need to be indicated at the end of the new tar cmd ? Like so:
Quote:

tar cvzf tarfile.tar.gz ~/Pictures

evo2 02-26-2013 12:07 AM

Hi,

the tar-ball will be put exactly where you tell it to be put. In your example it will be put in the current directory (in that case your home directory). If you want to it to go somewhere else just specify it. Eg to put it in /tmp:
Code:

ztcoracat:~$ tar cvzf /tmp/tarfile.tar.gz TARS
Regarding where to untar things, that depends entirely on what it is you are untaring.

Evo2.

Ztcoracat 02-26-2013 12:18 AM

Thanks evo ;)

Quote:

that depends entirely on what it is you are untaring.
Let's say for example I download a tarball and it is an application that I want to install.
Is there a better suited directory other than downloads for this tarball?

evo2 02-26-2013 12:33 AM

Hi,

Quote:

Originally Posted by Ztcoracat (Post 4899836)
Let's say for example I download a tarball and it is an application that I want to install.
Is there a better suited directory other than downloads for this tarball?

Hmm, still depends on what it is, and who will be using it. For example, a common place for prepackaged binaries like this might be /opt/, or perhaps if it is only for one user, in that users home directory, or even ~/opt/. If the package follows the FHS then perhaps /usr/local or if just for a single user ~/local. It is always best to check the documentation for whatever it is you are untarring/installing.

Evo2.

Ztcoracat 02-26-2013 12:43 AM

Quote:

It is always best to check the documentation for whatever it is you are untarring/installing.
Agreed-
Could you recommend a tarball that I could go and download from the internet and check the 'Read Me' or 'Install' file to understand where I should untar?

evo2 02-26-2013 12:52 AM

Hi,
Quote:

Originally Posted by Ztcoracat (Post 4899854)
Could you recommend a tarball that I could go and download from the internet and check the 'Read Me' or 'Install' file to understand where I should untar?

sorry no. I'm happy to help you with specific problems, but I'm not going to generate homework exercises for you.

Evo2.

Ztcoracat 02-26-2013 01:06 AM

Quote:

Originally Posted by evo2 (Post 4899856)
Hi,

sorry no. I'm happy to help you with specific problems, but I'm not going to generate homework exercises for you.

Evo2.

This is not homework I am in my late 50's- and retired- -

I understand now how to create a tarball.
Now I just need to learn how to unzip or extract it-

I went to the tarfile.tar that I made and opened my home directory. Upon opening the home directory I right clicked on my newly created tar and the drop down menu gave me:
-open with Archive Manager
-make link
-rename
-encrypt
-Send to
-Extract here.....
Do I choose Extract here or open the terminal and use this cmd?
Code:

tar -zxvf (nameoftar) tar.gz

chrism01 02-26-2013 04:07 AM

Just try it :)

Basic cmd

Code:

tar -zxvf file.tar.gz
Have a read of http://linux.die.net/man/1/tar and basically play with the options.
That cyberciti link of yours pretty much covers the basics, but there's a lot more possibilities.

Ztcoracat 02-26-2013 01:04 PM

Code:

ztcoracat:~$ tar -zxvf tarfile.tar.gz
TARS/
TARS/Practice
ztcoracat:~$ tar -zxvf file.tar.gz
tar (child): file.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
ztcoracat:~$

I know it's not a good practice to assume but I'll assume the first try was correct because I used the name (tarfile) that I gave.

chrism01 02-26-2013 07:41 PM

Code:

tar (child): file.tar.gz: Cannot open: No such file or directory !!
Obviously you can't just make stuff up ;)

Incidentally, tar is just a generic archiving tool. The content can be anything, so you have to un-tar it to find/read the (content specific) docs (if any ...)

Ztcoracat 02-26-2013 10:06 PM

Quote:

The content can be anything,
Didn't know that...I appreciate you telling me that-

Thanks for that link. That man-page helps and I now understand and things make more sense;)

What directory do most folks untar in? (or) does (like Evo said) depend on what it is?

chrism01 02-27-2013 12:27 AM

Pretty much yes...
Normally if you're eg installing some tool, then the web page will make a recommendation.
Alternately, I usually go for /opt/. This is just to unroll the tar file. Once its unpacked, the accompanying docs (if any) usually tell whether you can specify final install dir (if you can change it).
Typically for a src code set (usually in C), you invoke the make cmd and specify a config prefix; see the docs.

If its a backup you made, you should know where to put it :)
Check the -P option if you are doing this ;)

Basically, as you can see, there's a LOT of options to this cmd. Easiest is to google through a load of examples and check the flags used until you feel comfortable.

Mr. Alex 02-27-2013 12:21 PM

I don't like using “z” option. Much easier to use “a” (auto) and specify compression by extension (you won't need to remember all options for all compression methods):

Code:

tar cavf this-is-my-ultra-compressed-archive.tar.xz file1 file2 fil3 some-dir
  • *.tar.gz for gzip (poor compression)
  • *.tar.bz2 for bzip2 (middle compression)
  • *.tar.lzma for LZMA (best compression)
  • *.tar.xz for XZ (best compression)

They all have different letters as options (“-z”, “-j”, “--lzma”, “-J”) but “a” will work for all.

Ztcoracat 02-27-2013 09:41 PM

Chrism01 & Mr. Alex:

I wrote everything down that you posted- -

Thank you both; very much!:)

chrism01 02-28-2013 11:34 PM

Actually most (all?) of those tools have an option to specify how efficiently to compress (usually a range from 1 - 9, default 6), so those comparisons don't follow.

As for switches, if I can remember the correct file extension, I reckon I can remember the matching switch :)
Besides, most people pick a compression tool/option & use the same one most of the time.


All times are GMT -5. The time now is 03:19 AM.