Linux tar Command

Linux tar Command

Image not Found

File compression is an essential utility across all platforms. It helps you reduce file size and share files efficiently. And compressed files are also easier to copy to remote servers.

You can also compress older and rarely used files and save them for future use which helps you conserve disk space.

In this post, we’ll look at how to compress files with the tar command in Linux, along with some examples of tar in action.

Create a tar.gz file:

tar -czvf filename.tar.gz /path/to/dir1

Extract a .tar file:

tar -xvf foo.tar

Extract and uncompress a tar.gz file:

tar -xvzf foo.tar.gz

Extract and uncompress a tar.bz2 file:

tar -xvjf foo.tar.bz2

Tar archives can be split into multiple archives of a certain size, which is handy if you need to put a lot of content onto discs. It’s also useful if you have a huge archive that you need to upload, but would rather do it in chunks. In this guide, we’ll show you the commands you need in order to split tar archives into multiple blocks on a Linux system.

This will work regardless of what type of compression (or lack thereof) that you use. So files with extensions like .tar, tar.gz, tar.xz, etc. can all be split into chunks. We’ll also show you how to extract files from archives that have been split into numerous files.

make compress and split acrhive 4gb max per package:

tar czpvf - /path/to/archive | split -d -b 4096M - tardisk

Extract the split tar archive:

cat tardisk* | tar xzpvf -

make compress and split acrhive 200MB max per package:

tar cvzf - dir/ | split --bytes=200MB - sda1.backup.tar.gz.

Extract the split tar archive:

cat sda1.backup.tar.gz.* | tar xzvf -

with zip:

zip -0 -s 2g -r backup.zip directory
comments powered by Disqus

Lainnya yang kamu suka