How to fix unzip command not found

Endrit Qerreti

Endrit Qerreti

If you tried to unzip a zip file recently and you couldn't get it done because of the errors " unzip command not found or "bash: /usr/bin/unzip: No such file or directory"

These errors indicate that unzip is either not installed on your system, or unzip could be broken if it's already installed on your computer.

Depending on the linux distro that you are using you may get different kind of errors when unzip command won't execute, even though the cause of the error may be the same.

In this tutorial, you will learn how to fix these issues. We are using Linux Mint 21.1 while troubleshooting this issue.

Step 1 - Check if unzip is installed

The first thing that we are going to check is that we need to know if unzip is installed on our system, and there are many ways to do that. However, we'll check where the source files of unzip are, by using the whereis or which command

whereis unzip
which unzip

This is the output we got

unzip:

Now this output, indicates that there's no unzip source path in our system, this means that unzip is not installed on the system.

Step 2 - Install Unzip

Unzip is a tool for extracting .zip files on Linux. unzip can be installed on your system easily by running the command below

sudo apt install unzip

After you run the command above, you'll be asked to confirm the installation, press the Y key and then press enter to start the installation of unzip.

Step 3 - Verify unzip installation

Another way checking if unzip is installed correctly on your system, is by using the -v argument to check for the version of unzip

unzip -v

In the first example we used the whereis command to check where the source files of unzip are located, assuming the tool was installed on the system and assuming that whereis command wasn't working.

Cases when whereis or which commands don't work is because the $PATH is not configured correctly, and system doesn't know where to look for the executable files.

Step 4 - Using unzip

If you try to unzip a file from your terminal, by using the unzip command and if this command doesn't work, then you can try to execute the binary file directly without executing the unzip command.

/usr/bin/unzip

Run the command above on your terminal and it should run unzip. If this is the case then you need to set the correct path for unzip. To set the $PATH variable in your system, run the command below

export PATH=$PATH:/usr/bin/

And see if unzip command works on the terminal. If it works, you need now to add the same path variable to your bashrc file in order to make this change permanent, so unzip command works after you log out from your system or reboot it.

  1. Open bashrc with a text editor
sudo nano ~/.bashrc

2. Add the $PATH variable below to bashrc file

export PATH="$PATH:/usr/bin"

3. bashrc file should look like this

4. Save changes

After adding the path variable, save changes by pressing CTRL + X, confirm with Y and then press enter.

How to unzip files with unzip

The syntax of unzipping a file with unzip is

unzip file.zip

replace file.zip with the zip file that you want to unzip, and it should unzip the file on the same path where youn ran the unzip command.

For example, we are uncompressing a file called file.zip which inside has a folder called delete-me, when you uncompress it, it should look like this

Conclusion

In this tutorial, you learned how to fix the error unzip command not found on Linux, that happens mostly when the package unzip is not installed on the system where you are trying to use unzip.