Linux and Command-Line Basics
Which of the following is what happens when "tar -czf proj.tar.gz proj/" is run?
- AIt bundles the whole proj directory into one file and creates proj.tar.gz compressed with gzip
- BIt extracts proj.tar.gz and puts the files it contains into the proj directory
- CIt compresses each file in the proj directory one by one into separate .gz files
Show answer and explanation
Answer: A. It bundles the whole proj directory into one file and creates proj.tar.gz compressed with gzip
tar is a command that bundles several files and directories into one file (an archive): -c means create, -z compression with gzip, and -f that the following argument is the archive file name. The original proj directory remains as it is. To extract, use -x instead of -c, as in "tar -xzf proj.tar.gz", and to list the contents use -t. gzip alone only compresses a single file, so it is combined with tar to send a whole directory.
- A. Correct. -c creates the archive and -z applies gzip compression.
- B. Extraction is done with -x. -c creates an archive.
- C. Compressing files one by one into .gz is what gzip -r does. tar bundles them into one archive.