How to unzip zip archive in linux

How to unzip zip archive in linux

Как распаковать Zip-архив в Linux

How to Unzip Files in Linux

В этом руководстве мы объясним, как разархивировать файлы в системах Linux через командную строку с помощью unzip команды.

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Установка unzip

unzip не устанавливается по умолчанию в большинстве дистрибутивов Linux, но вы можете легко установить его, используя менеджер пакетов вашего дистрибутива.

Установить unzip на Ubuntu и Debian

Установить unzip на CentOS и Fedora

Как распаковать ZIP файл

В простейшем случае unzip команда без каких-либо параметров извлекает все файлы из указанного ZIP-архива в текущий каталог.

ZIP-файлы не поддерживают информацию о владельце в стиле Linux. Извлеченные файлы принадлежат пользователю, который запускает команду.

У вас должны быть права на запись в каталог, в который вы распаковываете ZIP-архив.

Подавить вывод unzip команды

По умолчанию unzip печатает имена всех извлекаемых файлов и сводные данные, когда извлечение завершено.

Распакуйте ZIP-файл в другой каталог

Например, чтобы разархивировать архив WordPress latest.zip в /var/www/ каталог, вы должны использовать следующую команду:

Распакуйте ZIP-файл, защищенный паролем

Ввод пароля в командной строке небезопасен и его следует избегать. Более безопасным вариантом является обычное извлечение файла без указания пароля. Если файл ZIP зашифрован, unzip вам будет предложено ввести пароль:

unzip будет использовать один и тот же пароль для всех зашифрованных файлов, если он правильный.

Исключить файлы при распаковке ZIP-файла

Перезаписать существующие файлы

Допустим, вы уже распаковали ZIP-файл и снова запускаете ту же команду:

По умолчанию unzip вас спросят, хотите ли вы перезаписать только текущий файл, перезаписать все файлы, пропустить извлечение текущего файла, пропустить извлечение всех файлов или переименовать текущий файл.

Используйте эту опцию с осторожностью. Если вы внесли какие-либо изменения в файлы, изменения будут потеряны.

Распакуйте ZIP-файл без перезаписи существующих файлов

Допустим, вы уже распаковали ZIP-файл и внесли изменения в некоторые файлы, но случайно удалили несколько файлов. Вы хотите сохранить изменения и восстановить удаленные файлы из архива ZIP.

Распакуйте несколько ZIP-файлов

Вы можете использовать регулярные выражения для сопоставления нескольких архивов.

Например, если у вас есть несколько ZIP-файлов в вашем текущем рабочем каталоге, вы можете разархивировать все файлы, используя только одну команду:

Перечислите содержимое файла Zip

В приведенном ниже примере мы перечисляем все установочные файлы WordPress:

Вывод будет выглядеть так:

Вывод

unzip это утилита, которая помогает вам составлять список, тестировать и извлекать сжатые ZIP-архивы.

В этом руководстве мы объясним, как разархивировать файлы в системах Linux через командную строку с помощью unzip команды.

How To Unzip Files On Linux

Below we outline some common methods to unzipping files on the Linux environment.

Quick Tip!

Looking to quickly open zip archive without hassle? Use ezyZip! 😊
It runs in the browser, so no need to install any extra software. Just navigate to the unzip page and follow the given instructions. It’s FREE!

Using the GUI to unzip files on Linux

The simplest approach is to use the GUI. Below we show the steps involved when using the default desktop environment that comes with each linux distribution. If you are using a custom setup, then these steps might not apply. Use the command line unzip options if you are stuck!

Extract zip file with Ubuntu / Debian

Extract zip file with Mint

That’s it, you have successfully unzipped the file. Optionally you could also use the Gnome Archive Mananger, which offers more advanced options and support for other file types.

Other Linux unzip applications

There is a myriad of dedicated archive management applications that can be utilised for unzipping files. Some are packaged with the distribution and others can be installed separately.

Extract zip file with Archive Manager

Extract zip file with Ark

How to unzip on Linux using terminal

If you want to work like a pro and desire more powerful features, you have to move towards command line interface. Fire up your terminal and run one of the following commands to complete your desired task. The examples assume you have a filename called backup.zip.

Install unzip on Linux

If unzip command is not installed on your system, then you’ll need to do that first.
sudo apt install unzip

Unzip on the Linux command line

The simplest option that will extract the contents to current directory:
unzip backup.zip

If you don’t want to unzip the whole file, then add the specific files to extract at the end:
unzip backup.zip file1 subdirectory/file2

Unzip files on command line with unarchiver

A great free set of unarchiving command line utilities are supplied by the Unarchiver. There is a GUI too but that is currently only offered to MacOS users.

The best part about these utilities is that they support dozens of other file formats (e.g. rar, 7z, arj etc. ) and the command line syntax is the same for all of them.

Install unarchiver

Unarchive files

To uncompress a file:
unar backup.zip

Unzip tar.gz files on command line

Linux and other unix variants commonly use tar and gz to package collection of files into a single package (e.g. software packages). To use the GUI for opening tar.gz files, follow the zip file instructions above. The command line options however are slightly different:

First uncompress the gz file:
gunzip filename.tar.gz

The output of the above should be filename.tar. Now to extract the tar file contents:
tar xvf filename.tar

You can combine the above two commands by adding a «z» option:
tar zxvf filename.tar.gz

Alternately, you could use ezyZip to extract tar.gz files or open tar file individually.

Unzip 7z files on command line

Another compression format that you will often encounter is 7z.

Install p7zip (if needed)
sudo apt-get install p7zip-full

To extract a 7z archive:
7z e backup.7z

Unzip zipx files on command line

The zipx file format is commonly associated with WinZip and not available for linux users. However fear not, you can use the 7zip utility to open zipx files in linux!

Install p7zip (if needed)
sudo apt-get install p7zip-full

Как распаковать ZIP в Linux

В операционной системе Windows формат архивов ZIP считается чуть ли не стандартным, он даже поддерживается в этой операционной системе, что называется «из коробки». Если вы только перешли с Windows, то у вас, наверное, есть много таких архивов с различными файлами, также ZIP-архивы могут часто попадаться на просторах интернета. Поэтому работать с такими файлами в Linux вам однозначно придётся.

В этой небольшой статье мы рассмотрим, как распаковать ZIP Linux. Разберём несколько способов и воспользуемся несколькими утилитами, которые справятся с этой задачей.

Распаковка ZIP Linux

Утилита для распаковки ZIP называется unzip, она не всегда установлена по умолчанию. Но вы можете очень просто добавить её в свою систему из официальных репозиториев. Для этого в Ubuntu выполните:

sudo apt install unzip

А в системах, использующих формат пакетов Red Hat, команда будет выглядеть немного по-другому:

sudo yum install unzip zip

После установки большинство графических утилит для работы с архивами смогут распаковать архив ZIP Linux. Команда ZIP Linux установлена на случай, если вы захотите создавать ZIP-архивы.

Но этой утилите не нужны дополнительные оболочки для распаковки архива. Вы можете сделать всё прямо из консоли. Давайте рассмотрим синтаксис утилиты:

Теперь рассмотрим опции утилиты, поскольку она позволяет не только распаковывать архивы, но и выполнять с ними определённые действия:

Все самые основные опции рассмотрели, теперь давайте рассмотрим несколько примеров работы с программой в терминале. Чтобы распаковать ZIP Linux в текущую папку, достаточно набрать:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Причём расширение указывать не обязательно. Протестировать архив можно с помощью опции -t:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Вы можете протестировать все архивы в текущей папке, выполнив:

Если нужно распаковывать архив не в текущую папку, можно очень просто указать нужную:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Также можно распаковывать не весь архив, а только нужные файлы или файлы нужного формата:

С помощью опции -l вы можете посмотреть список файлов в архиве:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Утилиту unzip разобрали и теперь вы с ней точно справитесь. Но я говорил, что мы рассмотрим несколько способов, как выполняется распаковка ZIP Linux. Поэтому дальше мы поговорим об утилите 7z.

Демонстрация работы утилит zip и unzip в терминале:

Как распаковать ZIP Linux с помощью 7z

Для установки утилиты в Ubuntu или Debian выполните:

sudo apt install p7zip-full

А в Red Hat и CentOS:

sudo yum install p7zip

Теперь вы можете использовать контекстное меню вашего файлового менеджера, чтобы распаковать архив ZIP Linux. Также можно использовать программу в консоли. Синтаксис очень похож на unzip:

$ 7z команда опции имя_архива

Команда задаёт нужное действие. Нас будут интересовать только четыре команды:

Теперь рассмотрим самые полезные опции:

Ну и рассмотрим примеры работы с утилитой. Сначала проверим содержимое архива:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Распаковываем архив, сохраняя структуру подкаталогов:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Или распаковываем все файлы в одну папку, игнорируя подкаталоги:

Или вы можете указать папку, в которую нужно распаковать файлы с помощью опции -o:

Выводы

Last Updated: January 6th, 2020 by How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux Hitesh J in Guides, Linux

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Zip (or Unzip) is one of the most popular and most widely used tools that can be used to create compressed archive files.

You can easily Zip and Unzip single or multiple files using this tool. Unzipping is a process of extracting all the files from the zip archive. If files in the archive were also compressed, unzip command will also uncompress them.

In this tutorial, we will show you how to unzip a file in Linux with several examples.

Install Unzip

By default, unzip package is not installed in any Linux operating systems. So you will need to install it on your system.

To install unzip on Ubuntu/Debian operating system, run the following command:

To install unzip on CentOS/RHEL/Fedora operating system, run the following command:

After installing unzip, you can see the installed version of unzip using the following command:

You should get the following output:

Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip/ ;
see ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites.
Compiled with gcc 4.8.2 for Unix (Linux ELF) on Nov 9 2015.

UnZip special compilation options:
ACORN_FTYPE_NFS
COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)
SET_DIR_ATTRIB
SYMLINKS (symbolic links supported, if RTL and file system permit)
TIMESTAMP
UNIXBACKUP
USE_EF_UT_TIME
USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)
USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)
UNICODE_SUPPORT [wide-chars, char coding: UTF-8] (handle UTF-8 paths)
LARGE_FILE_SUPPORT (large files over 2 GiB supported)
ZIP64_SUPPORT (archives using Zip64 for large files supported)
USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version 1.0.6, 6-Sept-2010)
VMS_TEXT_CONV
WILD_STOP_AT_DIR
[decryption, version 2.11 of 05 Jan 2007]

UnZip and ZipInfo environment options:
UNZIP: [none]
UNZIPOPT: [none]
ZIPINFO: [none]
ZIPINFOOPT: [none]

Basic Syntax

The basic syntax of the unzip command is shown below:

unzip [OPTION] FILENAME

A brief explanation of each option are listed below:

How to Use Unzip

Here’s are several ways to Unzip a compressed zip file in Linux:

1. To unzip a single file use the unzip command without any option as shown below:

You should see the following output:

Archive: file1.zip
creating: file1/
extracting: file1/file1.txt
extracting: file1/file2.txt
extracting: file1/file3.txt

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

2. To unzip multiple file use the following command:

You should see the following output:

Archive: file1.zip
extracting: file1.txt
Archive: file2.zip
extracting: file2.txt
Archive: file3.zip
extracting: file3.txt
3 archives were successfully processed.

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

You should see the following output:

0 2020-01-02 13:06 apt/sources.list.d/
146 2020-01-02 13:06 apt/sources.list.d/mystic-mirage-pycharm-trusty.list
0 2020-01-02 13:06 apt/trusted.gpg.d/
364 2020-01-02 13:06 apt/trusted.gpg.d/ondrej-php.gpg
0 2020-01-02 13:06 apt/trusted.gpg.d/minecraft-installer-peeps-minecraft-installer.gpg

378 2020-01-02 13:06 apt/trusted.gpg.d/minecraft-installer-peeps-minecraft-installer.gpg
0 2020-01-02 13:06 apt/trusted.gpg.d/projectatomic-ppa.gpg

1137 2020-01-02 13:06 apt/trusted.gpg.d/projectatomic-ppa.gpg
353 2020-01-02 13:06 apt/trusted.gpg.d/osmoma-audio-recorder.gpg
6541 2020-01-02 13:06 apt/trusted.gpg.d/nilarimogard-webupd8.gpg
0 2020-01-02 13:06 apt/trusted.gpg.d/webupd8team-java.gpg

0 2020-01-02 13:06 apt/trusted.gpg.d/nilarimogard-webupd8.gpg

366 2020-01-02 13:06 apt/trusted.gpg.d/mystic-mirage-pycharm.gpg
7140 2020-01-02 13:06 apt/trusted.gpg.d/webupd8team-java.gpg
0 2020-01-02 13:06 apt/trusted.gpg.d/osmoma-audio-recorder.gpg

0 2020-01-02 13:06 apt/trusted.gpg.d/mystic-mirage-pycharm.gpg

0 2020-01-02 13:06 apt/trusted.gpg.d/ondrej-php.gpg

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

You should see the following output:

Archive: test.zip
testing: test/ OK
testing: test/file1.txt OK
testing: test/file2.txt OK
testing: test/file3.txt OK
No errors detected in compressed data of test.zip.

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

5. In some cases, you will need to unzip a zip file inside the specific directory. To unzip a zip file inside specific directory you can use -d option with unzip command as shown below:

You should see the following output:

Archive: test.zip
creating: /tmp/opt/test/
extracting: /tmp/opt/test/file1.txt
extracting: /tmp/opt/test/file2.txt
extracting: /tmp/opt/test/file3.txt

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

6. You can see more detail information of each file located inside the zip archive use the option -v with unzip command:

You should see the following output:

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

7. By default, unzip command will overwrite all the files in existing directory.To skip extraction of all existing files you can use -n option with unzip command as shown below:

By default, unzip command will prompt you whether you want to overwrite the existing file or not. To overwrite existing files without prompting you can use the option -o with unzip command as shown below:

You should see the following output:

Archive: test.zip
inflating: test/file1.txt
inflating: test/file2.txt
inflating: test/file3.txt

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

8. By default, unzip command will display all the files available inside the zip archive during the unzipping process. You can suppress this output using the option -q with unzip command:

Some zip file includes files, directories and sub-directories in the archive. Run unzip command without any option will create the same directory structure from the archive.

To unzip the zip archive without creating those directories use -j option with unzip command as shown below:

You should see the following output:

Archive: test.zip
extracting: 12
extracting: 1
extracting: file3.txt
extracting: 12
extracting: 122
extracting: file.txt
extracting: file1.txt
inflating: file1.txt
inflating: file2.txt
inflating: file3.txt

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

For example, to unzip the password protected file test.zip with password as admin run the following command:

You should see the following output:

Archive: test.zip
creating: test/
extracting: test/file1.txt
extracting: test/file2.txt
extracting: test/file3.txt

Example:

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

Conclusion

In the above tutorial, you learned how to unzip a zip archive in Linux with hands-on examples. You can now easily extract any zip file using unzip command. For more information, you can visit the unzip manual page at unzip.

How do I zip/unzip on the unix command line?

How can I create and extract zip archives from the command line?

9 Answers 9

Typically one uses tar to create an uncompressed archive and either gzip or bzip2 to compress that archive. The corresponding gunzip and bunzip2 commands can be used to uncompress said archive, or you can just use flags on the tar command to perform the uncompression.

If you are referring specifically to the Zip file format, you can simply use the zip and unzip commands.

or to zip a directory

this unzips it in your current working directory.

How to unzip zip archive in linux. Смотреть фото How to unzip zip archive in linux. Смотреть картинку How to unzip zip archive in linux. Картинка про How to unzip zip archive in linux. Фото How to unzip zip archive in linux

There are a truly vast number of different ways to compress and uncompress under UNIX derivatives so I’m going to assume you meant «zip» in the generic sense rather than a specific file format.

You can zip files up (in compressed format) with the GNU tar program:

To unzip that file, use:

That’s assuming of course that you have a tar capable of doing the compression as well as combining of files into one.

If you don’t have zip and unzip packages installed and you have java, you can use jar to unzip:

Well, when it comes to distributing files for a variety of operating systems, I’d recommend 7-zip.

I recommend this method in case Windows users can’t open 7z archives (in case you want to advice a tool for that: PeaZip).

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *