How to Create & Extract tar.gz and tar.bz2 Files in Linux
>How to create a compressed tar.gz file from a folder or file in Linux?
tar czf new-tar-file-name.tar.gz file-or-folder-to-archive
Here is the command explanation:
- tar - the tar command.
- c - create new archive.
- z - compress the archive using gzip.
- f - use archive file.
- new-tar-file-name.tar.gz - the name of the tar.gz to create.
file-or-folder-to-archive - the name of the folder we want to archive.
>How to create a compressed tar.gz file from multiple files and folders in Linux?
tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2
>How to extract a compressed tar.gz file in Linux?
tar -xzf tar-file-name.tar.gz
Here is the command explanation:
- tar - the tar command.
- x - extract the archive.
- z - uncompress the archive using gzip.
- f - use archive file.
tar-file-name.tar.gz - the name of the tar.gz to create.
>How to extract a compressed tar.bz2 file in Linux?
Extracting tar.bz2 (bzip2 file) is very similar to the way you extract tar.gz file. Instead of using the -z flag you need to use the -j flag for the bzip2 format
tar -
xvzf tar-file-name.tar.gz
Here is the command explanation:
- tar - the tar command.
- x - extract the archive.
- j - filter the archive through bzip2
- f - use archive file.
tar-file-name.tar.gz - the name of the tar.gz to create.
Comments
Post a Comment