Bird
0
0

You want to create a compressed archive of the logs directory using the best compression ratio available with tar. Which command should you use?

hard📝 Application Q15 of 15
Linux CLI - Archiving and Compression
You want to create a compressed archive of the logs directory using the best compression ratio available with tar. Which command should you use?
Atar -cJf logs.tar.xz logs
Btar -cjf logs.tar.bz2 logs
Ctar -czf logs.tar.gz logs
Dtar -cf logs.tar logs
Step-by-Step Solution
Solution:
  1. Step 1: Identify compression types and their ratios

    Gzip (-z) is fast but less compressed, bzip2 (-j) is better, and xz (-J) offers the best compression ratio.
  2. Step 2: Choose the best compression flag

    Using -cJf creates an xz compressed archive, which has the best compression ratio.
  3. Final Answer:

    tar -cJf logs.tar.xz logs -> Option A
  4. Quick Check:

    Best compression = xz = -J flag [OK]
Quick Trick: Use -J for best compression with tar [OK]
Common Mistakes:
  • Choosing gzip or bzip2 for best compression
  • Forgetting compression flag
  • Using uncompressed tar by mistake

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes