QA
Beginner LevelLinux Commands & SysAdmin

How do tar, gzip, and bzip2 create and extract compressed archives?

❓ Interview Prompt: Explain tar flags (-c, -x, -z, -j, -v, -f), creating tarballs (.tar.gz, .tar.bz2), and extracting archives.

The 'tar' (Tape Archive) utility bundles multiple files into a single archive file, combined with compression algorithms:

Common Flags:

•
'-c': Create archive | '-x': Extract archive
•
'-v': Verbose output | '-f': Archive filename
•
'-z': Use gzip compression ('.tar.gz' / '.tgz')
•
'-j': Use bzip2 compression ('.tar.bz2')

Code Implementation Example

bash
# Create compressed tar.gz archive of website directory
tar -czvf backup-2026.tar.gz /var/www/app

# Extract archive into target directory
tar -xzvf backup-2026.tar.gz -C /opt/restored/
💡Creating and extracting gzipped tar archives.
🎯 Interview Key Takeaway

Use tar -czvf to create .tar.gz compressed archives, and tar -xzvf to extract them.

#tar#gzip#Compression#Archives#Beginner
Back to all Linux Commands & SysAdmin Questions→

More Linux Commands & SysAdmin Interview Questions

Beginner LevelLinux Commands & SysAdmin

How do Linux File Permissions (chmod, chown, chgrp) work in Octal and Symbolic notation?

Beginner LevelLinux Commands & SysAdmin

What is the Linux Filesystem Hierarchy Standard (/bin, /etc, /var, /usr, /opt, /tmp)?

Beginner LevelLinux Commands & SysAdmin

What are File Descriptors (0=stdin, 1=stdout, 2=stderr) and Redirection (>, >>, 2>&1)?