How to check if a compression tool is available in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check for the availability of common compression tools in Linux. We will explore how to use the --version option with gzip and bzip2 to verify their installation and see their versions.

You will also learn how to inspect the /usr/bin directory to see where many executable binaries, including these compression tools, are located on your system.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/CompressionandArchivingGroup(["Compression and Archiving"]) linux(("Linux")) -.-> linux/PackagesandSoftwaresGroup(["Packages and Softwares"]) linux/BasicSystemCommandsGroup -.-> linux/help("Command Assistance") linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/CompressionandArchivingGroup -.-> linux/gzip("Gzip") linux/PackagesandSoftwaresGroup -.-> linux/software("Linux Software") subgraph Lab Skills linux/help -.-> lab-558702{{"How to check if a compression tool is available in Linux"}} linux/ls -.-> lab-558702{{"How to check if a compression tool is available in Linux"}} linux/gzip -.-> lab-558702{{"How to check if a compression tool is available in Linux"}} linux/software -.-> lab-558702{{"How to check if a compression tool is available in Linux"}} end

Check for gzip with gzip --version

In this step, we'll start exploring some common Linux utilities. Many Linux systems come with tools for compressing and decompressing files. Two popular ones are gzip and bzip2.

Let's check if gzip is installed and see its version. We can do this using the --version option.

Open your terminal if it's not already open. Remember, you can find the Xfce Terminal icon on the left side of your desktop.

Type the following command and press Enter:

gzip --version

You should see output similar to this, indicating that gzip is installed and showing its version information:

gzip (GNU gzip) 1.10
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

The exact version number might differ, but the presence of this output confirms that the gzip command is available on your system.

The --version option is a common way to check the version of many command-line tools in Linux. It's a quick way to see if a program is installed and which version you are using.

Click Continue to proceed to the next step.

Verify bzip2 with bzip2 --version

In the previous step, we checked the version of gzip. Now, let's do the same for bzip2, another common compression utility.

Like gzip, bzip2 also supports the --version option to display its version information.

In your terminal, type the following command and press Enter:

bzip2 --version

You should see output similar to this:

bzip2, a block-sorting file compressor.  Version 1.0.8, 13-July-2019.

   Copyright (C) 1996-2019 Julian Seward <[email protected]>.  All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:

   1. Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

   2. The origin of this software must not be misrepresented; you must
      not claim that you wrote the original software.  If you use this
      software in a product, an acknowledgment in the product
      documentation would be appreciated but is not required.

   This software is provided `as is'', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   arising from the use of this software.

   Julian Seward, Cambridge, UK.
   [email protected]

Again, the specific version number might be different, but this output confirms that bzip2 is installed and available for use.

Checking the version of a command is a fundamental skill in Linux. It helps you confirm that a program is installed and understand which version you are working with, which can be important for compatibility or troubleshooting.

Click Continue to move on.

Inspect binaries with ls /usr/bin

In Linux, executable programs (commands) are often stored in specific directories. One of the primary locations for system commands is /usr/bin.

Let's use the ls command to list the contents of the /usr/bin directory. The ls command is used to list files and directories.

In your terminal, type the following command and press Enter:

ls /usr/bin

You will see a long list of files. These are many of the commands and programs available on your system.

[... many lines of output ...]
a2ps
a2query
aa-enabled
aa-exec
aa-status
ab
abcde
abrt-action-analyze-ccpp
abrt-action-analyze-core
abrt-action-analyze-oops
[... many more lines ...]

This directory contains a vast number of executable files, ranging from basic utilities like ls itself to more complex applications. You might even spot gzip and bzip2 in this list if you scroll through it!

Listing the contents of directories like /usr/bin helps you understand where commands are stored and gives you a glimpse into the structure of the Linux file system.

Don't worry about understanding every single file in this list. The goal here is just to see where many commands reside.

Click Continue to finish this section of the lab.

Summary

In this lab, we learned how to check for the availability and version of common Linux compression tools. We used the --version option with both gzip and bzip2 to confirm their installation and view their version information. This demonstrated a standard method for verifying the presence and version of command-line utilities in Linux.