LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2005, 12:52 AM   #1
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
curious: tar -xzvf ...


i always see something like
Code:
tar xzvf fluxbox-0.1.12.tar.gz
in posts and documentation, regarding the tar utility.. and can never remember the exact command.

this utility is used to compress and extract files or archives, correct?

the argument "xzvf" always gets me, and i can never remmeber it.. i looked up the command online and got what each argument means and am curious about it...

the first argument -x/--extract is always required as the first argument when extracting an archive...

"z" is used to "filter the archive through gzip".. is this only necessary for *.gz files?

"v" is for verbose, to display a list of files/directories involved.. and is probably just personal preferance, right?

"f" is apparently the option to specify the archive file... but in the documentation for this command it says that the last argument in this command is always the filename.. am i misunderstanding this? does that mean you dont need to specify -f?

the purpose of this is to basically simplify this command so i can remember it... im in windowz right now so i cant test it... but to me it looks like i can narrow down the above command to something like
Code:
tar -x fluxbox-0.1.12.tar.gz
or include the -z option also, if required for only .gz files?
 
Old 03-28-2005, 12:55 AM   #2
onelung02
Member
 
Registered: Oct 2003
Location: utah
Distribution: Slackware 10.0, Gentoo 2006.0
Posts: 289

Rep: Reputation: 30
Yea that will work, but I always like to do tar -xvf for mine, extract-verbose-force, just going x will work though. The reason that I like verbose is so that I can see where it is at in the extraction process.
 
Old 03-28-2005, 01:19 AM   #3
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
Re: curious: tar -xzvf ...

Quote:
Originally posted by nadroj
or include the -z option also, if required for only .gz files?
use j for bz2's:

tar xvfjp filename.tar.bz2
 
Old 03-28-2005, 01:29 AM   #4
Psycho(Clan)
Member
 
Registered: Mar 2005
Posts: 35

Rep: Reputation: 15
What do you think of tar -zxvf (document) to unrar it??
 
Old 03-28-2005, 02:53 AM   #5
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Quote:
Originally posted by Psycho(Clan)
What do you think of tar -zxvf (document) to unrar it??
UnTAR. Linux does not natively use RAR's.
 
Old 03-28-2005, 02:55 AM   #6
Psycho(Clan)
Member
 
Registered: Mar 2005
Posts: 35

Rep: Reputation: 15
It works with tar.gz files maybe it will work with tar.bz2 file too???
 
Old 03-28-2005, 03:02 AM   #7
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Re: Re: curious: tar -xzvf ...

Quote:
Originally posted by __J
use j for bz2's:

tar xvfjp filename.tar.bz2
 
Old 03-28-2005, 03:03 AM   #8
Psycho(Clan)
Member
 
Registered: Mar 2005
Posts: 35

Rep: Reputation: 15
so you can only do with the J??? hmm ok
 
Old 03-28-2005, 09:56 AM   #9
Padma
Member
 
Registered: Aug 2003
Location: Omaha, NE, USA
Distribution: PCLinuxOS 2007
Posts: 808

Rep: Reputation: 30
Re: curious: tar -xzvf ...

Quote:
Originally posted by nadroj
the first argument -x/--extract is always required as the first argument when extracting an archive...

"z" is used to "filter the archive through gzip".. is this only necessary for *.gz files?
Yes the "z" is only needed for tar.gz files. For tar.bz2 files, you need the "j" argument, as indicated in an earlier post.
Quote:
"v" is for verbose, to display a list of files/directories involved.. and is probably just personal preferance, right?
Yes, personal preference it is.
Quote:
"f" is apparently the option to specify the archive file... but in the documentation for this command it says that the last argument in this command is always the filename.. am i misunderstanding this? does that mean you dont need to specify -f?
So it would appear. I tried this last night on my PC at home, and when I didn't specify "f", the cursor just sat blinking at me, as if it was waiting for me to supply it with more info, even though the filename was on the command line.
YMMV
 
Old 03-28-2005, 08:52 PM   #10
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Nobody using tar 1.15? Reading changelogs? This is the second time I've mentioned this, but if you're using a newer version of tar, you don't need 'z' or 'j'. It magic's the file type and uses the appropriate tool. You still need to know the options if you want to write backwards-compatible shell scripts but for interactive use, it's as simple as 'eXtract File' now, along with a 'v' switch or not. Also, if the switches are really a problem for anybody, I guess you could always do 'alias untargz='tar xzvf'' and 'alias untarbz='tar xjvf'' or something.
 
Old 08-01-2021, 07:15 PM   #11
ropers
LQ Newbie
 
Registered: Jan 2009
Posts: 2

Rep: Reputation: 0
I realise this is an old post, but since it's still highly google-ranked, I might as well add this info:

The tar utility was originally exactly what's in its name: A tape archiver. It was designed as a program that dealt with storing things longer-term on magnetic tape as opposed to spinning rust (i.e. hard drives). That's why the program was made to default to using the tape archive device. (That might be something like /dev/rst0, depending on your operating system.) The -f parameter was included to allow users to override that default and archive to some other file somewhere in the file system instead. I don't know if there are any implementations out there that don't require the -f anymore, but I would strongly advise against getting used to not using the -f parameter, because especially if you're writing any hints or scripts that anyone else might use, omitting the -f is just creating potential portability problems for no good reasons. It's just asking for trouble.

I would also advise against omitting the -z, for similar reasons. While it's noob-friendly that some implementations of tar support autodetecting gz compression and proceeding without a -z, other implementations (e.g. on OpenBSD) will prompt the user that this seems to be a gzipped file and that they should specify a -z. So again, it's more compatible to include the parameter.

The inclusion of the -v (verbose) parameter is purely optional. It's just quieter without.

As for remembering the whole tar -xzvf thing, how about these mnemonics:
Xtract Ze Very File (-xzvf)
Xtract gZipped File (-xzf)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
Unable to use tar -xzvf with a abc.tar.gz file kakultech Linux - Software 6 11-08-2010 11:03 AM
samba install by tar xzvf wesleywest Linux - Newbie 6 11-01-2004 09:01 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration