Linux and Command-Line Basics

Which of the following is what happens when "tar -czf proj.tar.gz proj/" is run?

  1. AIt bundles the whole proj directory into one file and creates proj.tar.gz compressed with gzip
  2. BIt extracts proj.tar.gz and puts the files it contains into the proj directory
  3. 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.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. After editing main.c, a file managed with Git, only git commit -m "fix" was run, and "no changes added to commit" was shown and nothing was committed. Which of the following is the reason?
  2. You ran git commit in Git, but the commit does not yet appear in the GitHub repository shared by the team. Which of the following is the reason?
  3. "build/" was written in the .gitignore of a project managed with Git, but changes to build/out.log, which was committed earlier, keep appearing in git status. Which of the following is the reason?
  4. Which of the following correctly pairs standard Linux directories with what is placed in them?
  5. Which of the following correctly describes the /proc directory on Linux?