Compressing and Archiving
95
hackersarise2
hackersarise3
Listing 9-1: Creating a tarball of three files
Let’s break down this command to better understand it. The archiving
command is
tar
, and we’re using it here with three options. The
c
option
means create,
v
(which stands for verbose and is optional) lists the files that
tar
is dealing with, and
f
means write to the following file. This last option
will also work for reading from files. Then we give the new archive the file-
name you want to create from the three scripts:
HackersArise.tar.
In full, this command will take all three files and create a single file,
HackersArise.tar, out of them. When you do another long listing of the direc-
tory, you will see that it also contains the new
.tar file, as shown next:
kali >
ls -l
--
snip
--
-rw-r--r-- 1 root root 40960 Nov 27 2018 13:32 HackersArise.tar
--
snip
--
kali >
Note the size of the tarball here: 40,960 bytes. When the three files are
archived,
tar
uses significant overhead to perform this operation: whereas the
sum of the three files before archiving was 35,094 bytes, after archiving, the
tarball had grown to 40,960 bytes. In other words, the archiv ing process has
added over 5,000 bytes. Although this overhead can be significant with small
files, it becomes less and less significant with larger and larger files.
We can
display those files from the tarball, without extracting them, by
using the
tar
command with the
-t
content list switch, as shown next:
kali >