Explore key concepts of Linux file compression and archiving with this quiz based on tar, zip, and gzip. Assess your understanding of practical command-line usage, file handling strategies, and the differences among common Linux utilities.
Which command creates a compressed archive named data.tar.gz from the files notes.txt and report.csv in Linux?
Explanation: The correct option uses 'tar -czf' to create (-c), compress with gzip (-z), and specify the output file (-f). This is the standard way to create a gzip-compressed tarball. The 'zip -c' command is incorrect syntax, as 'zip' archives rather than using tar. The 'gzip tar data.tar.gz' option is not a valid command structure and mixes up utilities. The 'tar -xzf' option is for extracting, not creating, an archive.
If you want to extract all files from an existing archive called backup.zip into the current directory, which command should you use?
Explanation: 'unzip backup.zip' is the correct command to extract files from a zip archive in Linux. The 'gunzip' command is only for files compressed with gzip, not zip archives. The 'tar -xf' option is used for tar archives, not .zip files. The 'zip -e' command is used to create encrypted zip archives, not for extraction.
After running 'gzip log.txt', what will be the result in your directory?
Explanation: The 'gzip' command compresses the file and replaces it with a '.gz' version, removing the original by default. Keeping both files would require an option like '-k', which is not mentioned. A tar archive, such as 'log.tar', is created using 'tar', not 'gzip'. Files are not automatically moved into a subfolder because gzip simply compresses the file in place.
When should you use the 'zip' utility instead of 'tar' or 'gzip' for your files?
Explanation: The 'zip' format is widely supported across different operating systems, making it ideal for creating archives to share between platforms. Tar and gzip are commonly used for archiving and compressing in Linux environments, especially for scripts or system backups, but are less universally supported outside of Unix-like systems. Tar-only archives do not offer built-in cross-platform features or compression. Archiving without compression would typically involve 'tar' alone, not 'zip'.
Which command displays the list of files inside the compressed archive archive.tar.gz without extracting them?
Explanation: 'tar -tzf' lists files in a compressed tar archive without unpacking them, which is often useful for previewing contents. The 'gzcat' command is for viewing the uncompressed data but does not list file names within the archive. 'zip -l' is only for listing contents in zip archives, not tarballs. 'gzip -L' is not a valid option for inspecting files in tar.gz archives.