- How to Create and Extract Zip Files to Specific Directory in Linux
- Create Zip Archive File in Linux
- Extract Zip File to Specific or Different Directory
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- How To Extract Zip, Gz, Tar, Bz2, 7z, Xz and Rar File in Linux
- Extract .zip file in Linux
- Extract .gz file in Linux
- Extract .tar file in Linux
- Extract .tar.gz file in Linux
- Extract .tar.xz file in Linux
- Extract .tar.bz2 file in Linux
- Extract .7z file in Linux
- Extract .rar file in Linux
- How to Unzip a Zip File in Linux [Beginner’s Tutorial]
- Unzip file in Linux command line
- Unzip to directory
- See the content of zip file without unzipping it
- Unzip files in Linux using GUI
- Как распаковать ZIP в Linux
- Распаковка ZIP Linux
- Как распаковать ZIP Linux с помощью 7z
- Выводы
How to Create and Extract Zip Files to Specific Directory in Linux
In one of our several articles about the tar command, we showed you how to extract tar files to a specific or different directory in Linux. This short guide explains to you how to extract/unzip .zip archive files to a specific or different directory in Linux.
Zip is a simple, cross-platform file packaging and compression utility for Unix-like systems including Linux and Windows OS; plus many other operating systems. The “zip” format is a common archiving file format used on Windows PC’s and most importantly, it enables you to specify the compression level between 1 and 9 as an option.
Create Zip Archive File in Linux
To create a .zip (packaged and compressed) file from the command line, you can run a similar command like the one below, The -r flag enables recursive reading of files directory structure.
Create Zip File in Linux
To unzip the tecmint_files.zip archive file you have just created above, you can run the unzip command as follows.
The above command will extract the files into the current working directory. What if you want to send the unzipped files into a specific or different directory – you can learn this in the next section.
Extract Zip File to Specific or Different Directory
To extract/unzip .zip archive files to specific or different directory from the command line, include the -d unzip command flag as shown below. We will use the same example above to demonstrate this.
This will extract the .zip file content into the /tmp directory:
Extract Zip Files to Specific Directory
For more usage information, read zip and unzip command man pages.
You may also like to read the following related articles.
In this short article, we have explained how to extract/unzip .zip archive files to a specific or different directory in Linux. You can add your thoughts to this article via the feedback form below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
How To Extract Zip, Gz, Tar, Bz2, 7z, Xz and Rar File in Linux
An archive file is a file composed of one or more files in compressed format. It’s useful for saving disk storage, managing a single file is easier than managing multiple files. This tutorial will help you to decompress or extract an archive file in the Linux system via command line. You can also list archive file content without extracting it.
Extract .zip file in Linux
This is the most common compression format used by various IT professions on many operating systems. For this you must of unzip binary installed on your system.
Extract .gz file in Linux
Gz files are compressed files created using the Gzip compression utility. In general, GZIP is better compared to ZIP, in terms of compression, especially when compressing a huge number of files. Use gunzip command to extract .gz archive file.
Extract .tar file in Linux
Tar is the sort of Tape Archive and also referred to as the tarball. This is another popular archiving method which is also known as the consolidated Unix archive format. To extract .tar file use following command
Extract .tar.gz file in Linux
TAR.GZ file is a combination of TAR and GZIP archives. If provides more compression format of data. You can use -z switch to extract these files.
Extract .tar.xz file in Linux
The XZ format is a single file compression format and does not offer archiving capabilities. It preserves the original data with no loss in quality. You can use -J switch to extract these files.
Extract .tar.bz2 file in Linux
Tar.bz2 is an combination of tar and bzip2 archive formats. You can use -j to filter the archive through bzip2. Use the following to extract .tar.bz2 compressed file.
The latest version fo tar automatically detects the archive format. So you can simply use the following command.
Extract .7z file in Linux
These files are 7zip archive files. This is not generally used on Linux systems, but sometimes you may need to extract some source files. You must have the 7zip package installed on your system. Use the following command to extract these files.
Extract .rar file in Linux
These are common archive format for Windows systems, but Linux users avoid to use this. Still you may need sometimes to extract .rar file on Linux. You can use 7z command to extract this or unrar.
Источник
How to Unzip a Zip File in Linux [Beginner’s Tutorial]
Last updated October 9, 2019 By Abhishek Prakash 9 Comments
Brief: This quick tip shows you how to unzip a file in Ubuntu and other Linux distributions. Both terminal and GUI methods have been discussed.
Zip is one of the most common and most popular way to create compressed archive files. It is also one of the older archive file format that was created in 1989. Since it is widely used, you’ll regularly come across a zip file.
In an earlier tutorial, I showed how to zip a folder in Linux. In this quick tutorial for beginner’s, I’ll show you how to unzip files in Linux.
Prerequisite: Verify if you have unzip installed
In order to unzip a zip archive file, you must have the unzip package installed in your system. Most modern Linux distributions come with uzip support but there is no harm in verifying it to avoid bad surprises later.
In Ubuntu and Debian based distributions, you can use the command below to install unzip. If it’s already installed, you’ll be notified about it.
Once you have made sure that your system has unzip support, it’s time to unzip a zip file in Linux.
You can use both command line and GUI for this purpose and I’ll show you both methods.
Unzip file in Linux command line
Using unzip command in Linux is absolutely simple. In the directory, where you have the zip file, use this command:
You can also provide the path to the zip file instead of going to the directory. You’ll see extracted files in the output:
There is a slight problem with the above command. It will extract all the contents of the zip file in the current directory. That’s not a pretty thing to do because you’ll have a handful of files leaving the current directory unorganized.
Unzip to directory
A good practice is to unzip to directory in Linux command line. This way, all the extracted files are stored in the directory you specified. If the directory doesn’t exist, it will create one.
Now all the contents of the zipped_file.zip will be extracted to unzipped_directory.
Since we are discussing good practices, another tip you can use is to have a look at the content of the zip file without actually extracting it.
See the content of zip file without unzipping it
You can check the content of the zip file without even extracting it with the option -l.
Here’s a sample output:
There are many other usage of the unzip command in Linux but I guess now you have enough knowledge to unzip files in Linux.
Unzip files in Linux using GUI
You don’t always have to go to the terminal if you are using desktop Linux. Let’s see how to unzip in Ubuntu Linux graphically. I am using GNOME desktop here with Ubuntu 18.04 but the process is pretty much the same in other desktop Linux distributions.
Open the file manager and go to the folder where your zip file is stored. Right click the file and you’ll see the option “extract here”. Select this one.
Unlike the unzip command, the extract here options create a folder of the same name as the zipped file and all the content of the zipped files are extracted to this newly created folder. I am glad that this is the default behavior instead of extracting everything in the current directory.
There is also the option of ‘extract to’ and with that you can specify the folder where you want to extract the files.
That’s it. Now you know how to unzip a file in Linux. Perhaps you might also be interested in learning about using 7zip in Linux.
If you have questions or suggestions, do let me know in the comment section.
Like what you read? Please share it with others.
Источник
Как распаковать ZIP в Linux
В операционной системе Windows формат архивов ZIP считается чуть ли не стандартным, он даже поддерживается в этой операционной системе, что называется «из коробки». Если вы только перешли с Windows, то у вас, наверное, есть много таких архивов с различными файлами, также ZIP-архивы могут часто попадаться на просторах интернета. Поэтому работать с такими файлами в Linux вам однозначно придётся.
В этой небольшой статье мы рассмотрим, как распаковать ZIP Linux. Разберём несколько способов и воспользуемся несколькими утилитами, которые справятся с этой задачей.
Распаковка ZIP Linux
Формат ZIP был создан в 1989 году на замену очень медленному формату ARC. Здесь используется сжатие deflate, и на то время оно работало намного быстрее чем ARC. Исторически сложилось так, что стандартным форматом для Linux стали TAR и GZ — это усовершенствованные алгоритмы сжатия и архивации. Многие графические распаковки воспринимают и ZIP-файлы. Но они обрабатывают архивы не сами, а дают команду предназначенным для этого формата утилитам.
Утилита для распаковки ZIP называется unzip, она не всегда установлена по умолчанию. Но вы можете очень просто добавить её в свою систему из официальных репозиториев. Для этого в Ubuntu выполните:
sudo apt install unzip
А в системах, использующих формат пакетов Red Hat, команда будет выглядеть немного по-другому:
sudo yum install unzip zip
После установки большинство графических утилит для работы с архивами смогут распаковать архив ZIP Linux. Команда ZIP Linux установлена на случай, если вы захотите создавать ZIP-архивы.
Но этой утилите не нужны дополнительные оболочки для распаковки архива. Вы можете сделать всё прямо из консоли. Давайте рассмотрим синтаксис утилиты:
$ unzip опции файл_архива.zip файлы -x исключить -d папка
- файл архива — это тот файл, с которым нам предстоит работать;
- файлы — здесь вы можете указать файлы, которые нужно извлечь, разделять имена файлов пробелом;
- исключить — файлы, которые извлекать не нужно;
- папка — папка, в которую будет распакован архив.
Теперь рассмотрим опции утилиты, поскольку она позволяет не только распаковывать архивы, но и выполнять с ними определённые действия:
- -l — вывести список файлов в архиве;
- -t — протестировать файл архива на ошибки;
- -u — обновить существующие файлы на диске;
- -z — вывести комментарий к архиву;
- -c — извлекать файлы на стандартный вывод, перед каждым файлом будет выводиться его имя;
- -p — то же самое, только имя выводится не будет;
- -f — извлечь только те файлы, которые уже существуют на диске, и файлы в архиве более новые;
- -v — вывести всю доступную информацию;
- -P — указать пароль для расшифровки архива;
- -n — не перезаписывать существующие файлы;
- -j — игнорировать структуру архива и распаковать всё в текущую папку;
- -q — выводить минимум информации.
Все самые основные опции рассмотрели, теперь давайте рассмотрим несколько примеров работы с программой в терминале. Чтобы распаковать ZIP Linux в текущую папку, достаточно набрать:
Причём расширение указывать не обязательно. Протестировать архив можно с помощью опции -t:
unzip -tq имя_файла.zip
Вы можете протестировать все архивы в текущей папке, выполнив:
Если нужно распаковывать архив не в текущую папку, можно очень просто указать нужную:
unzip имя_файла.zip -d /tmp
Также можно распаковывать не весь архив, а только нужные файлы или файлы нужного формата:
unzip имя_файла.zip \*.txt -d /tmp
С помощью опции -l вы можете посмотреть список файлов в архиве:
unzip -l file.zip
Утилиту unzip разобрали и теперь вы с ней точно справитесь. Но я говорил, что мы рассмотрим несколько способов, как выполняется распаковка ZIP Linux. Поэтому дальше мы поговорим об утилите 7z.
Демонстрация работы утилит zip и unzip в терминале:
Как распаковать ZIP Linux с помощью 7z
7z — это кроссплатформенный набор утилит для работы с архивами. Кроме собственного формата, здесь поддерживается большое количество других, в том числе tar и zip. Плюс этой утилиты — в контекстное меню файлового менеджера будет добавлен пункт, с помощью которого вы сможете распаковывать или создавать архивы.
Для установки утилиты в Ubuntu или Debian выполните:
sudo apt install p7zip-full
А в Red Hat и CentOS:
sudo yum install p7zip
Теперь вы можете использовать контекстное меню вашего файлового менеджера, чтобы распаковать архив ZIP Linux. Также можно использовать программу в консоли. Синтаксис очень похож на unzip:
$ 7z команда опции имя_архива
Команда задаёт нужное действие. Нас будут интересовать только четыре команды:
- e (Extract) — извлечь файлы из архива;
- x eXtract — извлечь файлы из архива, сохраняя полный путь;
- l (List) — список файлов архива;
- t (Test) — проверить архив.
Теперь рассмотрим самые полезные опции:
- -o — указать папку для распаковки;
- -p — указать пароль;
- -x — не извлекать эти файлы;
- -w — указать рабочую директорию;
- -y — отвечать положительно на все вопросы;
Ну и рассмотрим примеры работы с утилитой. Сначала проверим содержимое архива:
Распаковываем архив, сохраняя структуру подкаталогов:
Или распаковываем все файлы в одну папку, игнорируя подкаталоги:
Или вы можете указать папку, в которую нужно распаковать файлы с помощью опции -o:
7z x файл.zip -o /tmp/
Выводы
В этой статье была рассмотрена распаковка ZIP Linux, как видите, это ненамного сложнее, чем распаковка стандартных архивов TAR. Мы рассмотрели два способа ,и теперь вы точно будете знать, что делать, когда столкнетесь с такой ситуацией. Если у вас остались вопросы, спрашивайте в комментариях!
Источник