Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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
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.
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)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.