- What is TGZ File and How To Extract TGZ In Windows and Linux?
- Tar.gz
- TGZ Exract Applications For Windows
- List TGZ File Information
- Extract TGZ For Linux
- Extract For Windows with 7zip
- UNIX / Linux Decompress tgz / tar.gz and extract files
- Linux decompress tgz file
- Unix decompress .tar.gz file
- How to decompressing .tar.bz2 file
- How to uncompress tar.gz/tgz/tar.bz2 file into a different directory
- How to to extract single file named foo.mp4 from the backup.tar.gz
- How to view a listing all files in tarball archive
- UNIX decompress tgz / tar.gz file
- Summary of tar command options
- Conclusion
- HowTo: Unpack .tgz File On a Linux
- Unpacking .tgz files command
- Examples
- tar command options
- linux-notes.org
- Распаковка .tgz файлов в Unix/Linux
- Bash script to extract all .tgz in directory [duplicate]
- 1 Answer 1
What is TGZ File and How To Extract TGZ In Windows and Linux?
TGZ file is a tar archive which is compressed with the Gzip compression algorithm. Linux operating systems provide tar and gzip by default. A tar archive is created in order to make multiple files and directories single file with a tar archive. And then gzip is used to compress this tar which will create a TGZ file.
Tar.gz
As stated previously TGZ is tar and gzipped file. TGZ can be also expressed as tar.gz . Tar is for tar archive and gz is gzip archive.
TGZ Exract Applications For Windows
There are a lot of tools which can be used to create or extract TGZ file. We will list the most popular application for TGZ below.
List TGZ File Information
We will start by printing the TGZ file information. We will use file command which will print information like file type, last modified time, original size etc.
List TGZ File Information
Extract TGZ For Linux
Linux distributions like Ubuntu, Debian, Mint, Kali, Fedora, CentOS, RedHat provides requires tools tar and gzip from applications repositories. These tools are installed by default.
Extract TGZ For Linux
Extract For Windows with 7zip
We will right click to the TGZ file and click Extract Here like below.
This will decompress gzip part and create a tar file. We will again Rigth Click and then click to the Extract Here which will decompress the tar file like below.
As we can see the decompressed file will not be deleted automatically.
Источник
UNIX / Linux Decompress tgz / tar.gz and extract files
Linux decompress tgz file
To open such file type the following tar command at Linux shell prompt (GNU tar syntax):
$ tar -zxvf filename.tgz
The above, command will extract the .tgz file into the current directory. To view files use the cd command and ls command:
ls -l
cd dir1
ls
Unix decompress .tar.gz file
Let us see how to extract .tar.gz files using Unix or Linux command line, run:
$ tar -zxvf filename.tar.gz
How to decompressing .tar.bz2 file
Run the following command to extract .tar.bz2 file on Unix or Linux:
$ tar -jxvf filename.tar.bz2
How to uncompress tar.gz/tgz/tar.bz2 file into a different directory
The syntax is:
tar -zxvf filename.tgz -C /path/to/dir1/
tar -zxvf filename.tar.gz /dir2/
tar -jxvf filename.tar.bz2 /path/to/dir3
How to to extract single file named foo.mp4 from the backup.tar.gz
Execute:
tar -xvzf backup.tar.gz foo.mp4
Extract dir2 from backup.tar.gz, run:
tar -xvzf backup.tar.gz dir2
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
How to view a listing all files in tarball archive
Again use the tar command as follows to see a listing of all files in backup.tar.gz:
tar -ztvf backup.tar.gz
UNIX decompress tgz / tar.gz file
Type the following command:
$ gzip -dc filename.tgz | tar xf —
$ gzip -dc filename.tar.gz | tar xf —
If file extension ends with .Z, enter:
$ zcat filename.tar.Z | tar xf —
Summary of tar command options
- z – Decompress/extract tar.gz or .tgz file
- j – Decompress/extract tar.bz2 or .tbz2 file
- x – Extract files
- v – Verbose output on screen
- t – List files stored inside given tarball archive
- f – Extract given filename.tar.gz and so on
Conclusion
This page showed how to extract (decompress) tar.gz/tgz files using Linux and Unix command line options.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
HowTo: Unpack .tgz File On a Linux
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | No |
Requirements | tar+gunzip |
Est. reading time | 2m |
Unpacking .tgz files command
The syntax is as follows:
tar zxvf fileNameHere.tgz
Or try the geeky bash pipe based syntax:
gunzip -c fileNameHere.tgz | tar xvf —
Examples
In this example, unpack a file called backups.tgz, enter:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
To unpack and put files in a different folder (directory) say /tmp/data, enter:
tar command options
- -z : Uncompress the resulting archive with gzip command.
- -x : Extract to disk from the archive.
- -v : Produce verbose output i.e. show progress and file names while extracting files.
- -f backup.tgz : Read the archive from the specified file called backup.tgz.
- -C /tmp/data : Unpack/extract files in /tmp/data instead of the default current directory.
See tar(1) command man page for more information.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
Hello.
You can try too:
It’s just what i have been looking for. Much thanks.
Thank you for the information, I was able to find what i was looking for in a jiff and i was able to understand the instructions.
Hi Folks.
i have created a Tarball
“softwaredevelopment.war.tgz” size 1.2G
while extracting it
i used all the above command mentioned on this page
tar zxvf fileNameHere.tgz
gunzip -c fileNameHere.tgz | tar xvf –
i have also installed GNU software… but still not working for me.
is there any solution for this… kindly help…!
Источник
linux-notes.org
Распаковка .tgz файлов в Unix/Linux
Сейчас расскажу как можно распаковать файлы которые запакованы в tgz, на готовом примере я покажу в своей статье «Распаковка .tgz файлов в Unix/Linux».
Я новый пользователь Linux. У меня некоторые проблемы с терминалом и я не знаю некоторые команды. И например, я забываю всегда как можно распаковать архив .tgz (tar.gz) на Linux с помощью параметров командной строки.
Распаковка .tgz файлов
Синтаксис выглядит следующим образом:
Или можно использовать синтаксис Bash который открывает «трубу» и распакует ваш архив:
Примеры
В этом примере, чтобы распаковать файл с именем my_backup.tgz, выполните:
Чтобы распаковать все файлы и поместить их в другую папку или каталог (например /usr/local/src), введите:
Можно посмотреть, имеются ли файлы в том каталоге:
Команды tar
-z : Распакует полученный архив с помощью команды GZIP.
-x : Извлечение файлов на диск из архива.
-v : Показывает сам процесс распаковки файлов при извлечении файлов.
-f my_backup.tgz : Read the archive from the specified file called my_backup.tgz.
-C /usr/local/src : Распаковка/ извлечение файлов в /usr/local/src вместо текущей директории по умолчанию.
Мне нравится еще использовать утилиту zcat:
Данный архив содержит файл с БД (sql), программа zcat открывает «трубу», после чего начнет распаковку и сразу же будет перенаправлять все данные в mysql (я указал в нужную мне базу).
Распаковка .tgz файлов в Unix/Linux закончена.
Источник
Bash script to extract all .tgz in directory [duplicate]
I have a directory with all tgz files. Currently, I have a script that I run that will
- take in the directory as first parameter
- extract the tgz
- cd into the extracted folder
- and then run my load script
- and go on to the next tgz..
Currently this script works, but it will fail if someone puts in a parameter other than just the directory name (e.g, ./myScript /whole/path/to/directory)
1 Answer 1
something that looks like this could work
obviously the echos are just for demonstration
The comment to avoid using ls is fair if you are not in control of your environment. Push your filter for files of interest further into a loop over a less specific collection.
depending on how little control you have, you may need more paranoid tests.
EDIT for comment to explain the if statement
first the char [ in bash is the same command as test you want to the keep spaces after [ and before ]
inside the [ . ] is an expression (a predicate) that evaluates to true or false
In this case we are using variable substitution
where the value of a shell variable, $tgz here,
is being modified before it is used
It is always safest to enclose the name of the variable after the $ in braces
However doing so also allows you to annotate the variable call
to substitute the normal variable value with a modified value
my quick and dirty mnemonic for remembering the annotations
and their functions is to look to either side of the $ key
(sorry non-english non-qwerty keyboard layouts)
and notice the # hash or pound character proceeds $
so $
of the regular expression
after the # and before the >
from the beginning of the variables value.
likewise the % is the key after $ and $
will delete the last match of the regular expression
from the value of the variable
Both annotations can be doubled ## or %% to mean:
delete the longest match of the regular expression
instead of the shortest.
so
«$
means delete everything up to and including the last dot
from the value in the variable $tgz and see if what remains
is exactly equal to the string «tgz»
web searches on «bash variable substitution»
and «bash test» will take you further
Источник