how to unzip files in linux command line

In Linux, tar and gzip is the widely used archiving and compressing file format. Another most widely file compression file format is zip, which is more popular in other operating systems such as Windows.

However it does not mean that Linux does not support the zip format. There are utilities in Linux that you can use to uncompress zip files. According to the GNU manual, the unzip utility allows you to list, test and extract compressed files in a zip archive.

As zip is not widely used with in Linux, it is quite possible that the distro that you have does not come pre-installed with the zip utility. In that case you should be able to manually install the zip/unzip utility using the package manager that is specific to your distro.

list files in the zip archive

To list the contents of the zip archive, but not actually extract the files to the disk, you should use the -l option with the unzip command.

bash$ unzip -l

unzip all files to the current folder

The default behavior of the unzip command is to extract all the files, directories and sub-directories into the current working directory creating any sub-directory as needed. That means you don’t have to use any command line options with the unzip command

bash$ unzip

To extract all files into the current directory only, with out creating any sub-directories use the -j option. This will not create any sub-directories and all the files in the archive is extracted to the current working directory.

bash$ unzip -j

extract only updated files in the zip archive

If you want to extract only the newer versions of the files that is already in the current directory then you should use the -u option. This will update any existing file that are newer and create any files that do not exist on the disk.

bash$ unzip -u

overwriting files without prompting when extracting

If the file that is being extracted exist on the disk then the unzip utility will prompt you before overwriting the file. In most cases, you probably just want to overwrite the file and having to answer every prompt might be tedious.

bash$ unzip -uo

The -o option will overwrite any existing file without prompting.

the quiet option when extracting

You might have seen by now that the unzip command can be quite verbose. It will print out the files that is extracting along with the action it is performing. If you want the command to be less verbose, you can use the -q command line option. You can also use the -qq option if you want it to be even less verbose.

bash$ unzip -uoqq

The unzip command is all about listing, testing and extracting an existing zip archive file. If you want to compress files into an archive then you will need to use its companion utility named zip.