December 6, 2020 - 2 minute read

Day 16 : Archive files

This is part of the #LinuxUpSkillChallenge. Don't forget to also check out the Official Instructions and the Reddit posts.

1. What is archiving?

Archiving is the process by which information is securely stored for longer periods of time.

The Linux “tar” stands for tape archive, which was used by a large number of Linux/Unix system administrators to deal with tape backup. Remember tapes? Well, they are not dead. In fact, they are very much alive.

The tar command rips a collection of files and directories into an archive file (often combined with a compression method) commonly called tarball or tar.

2. What is compressing?

File compression is used to reduce the file size of one or more files. When a file or a group of files is compressed, the resulting “archive” often takes up 50% to 90% less disk space than the original file(s).

The most used tools for compression in Linux are gzip, bzip2, and zip.

$ du -h big-file*
65M	big-file

$ gzip big-file
$ du -h big-file*
60M	big-file

$ gzip -d big-file.gz
$ du -h big-file*
65M	big-file

$

3. Your first tar ball

Options:

Creating tarballs:

$ du -h file*
8.0K	file1
36K	file2
12K	file3

$ tar cf target.tar file1 file2 file3
$ du -h file* target*
8.0K	file1
36K	file2
12K	file3
60K	target.tar

$ tar czf target.tar.gz file1 file2 file3
$ du -h file* target*
8.0K	file1
36K	file2
12K	file3
60K	target.tar
16K	target.tar.gz

$

4. Extracting files

For more detail on how I did each day, check out my log on Reddit. Follow me on Twitter for daily updates.