How can you view the content of a compressed file with a .gz extension?

Explore the Linux Fundamentals Test. Revise with flashcards and multiple choice questions, each with hints and explanations. Prepare thoroughly for your Linux exam!

To view the content of a compressed file with a .gz extension, using the zcat command or the gzip -d command is effective because these commands are specifically designed to handle gzip compressed files. The zcat command allows you to read the contents of multiple compressed files, displaying the uncompressed data directly in the terminal without creating an intermediary uncompressed file.

On the other hand, running gzip with the -d option decompresses the file and outputs it to standard output. This way, you can see the contents in the terminal.

Using the cat command is not suitable for viewing .gz files since it does not decompress them and will output binary data that is not human-readable. The unzip command is designed for .zip files, not .gz files, so it wouldn't work for this task. Lastly, the ls command is for listing directory contents and doesn't interact with file contents or formats at all. Thus, option B is the appropriate choice for viewing the content of a .gz file.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy