Fireship · @fireship
gzip file compression in 100 Seconds
Uploaded July 15, 2022 · Length 2:18
Summary
gzip explained: a lossless file compression tool that reduces data size without losing information.
- gzip
- file compression
- lossless compression
- data compression
- linux utilities
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
gzip a lossless file compression tool
- 0:02
famous for making large chunks of data
- 0:04
smaller the files on a computer are
- 0:06
represented by bits on a silicon chip
- 0:08
but they often take up more space than
- 0:10
is actually necessary for example when
- 0:12
you write your screenplay in a text
- 0:14
document you produce a bunch of repeated
- 0:16
patterns many years ago computer
- 0:18
scientists realized we were wasting
- 0:19
space and wrote algorithms like lz77 to
- 0:22
address this problem by looping over the
- 0:24
contents of a file to identify repeated
- 0:26
sequences that can be replaced with
- 0:28
metadata or shorter sequences thus
- 0:30
reducing the total amount of bits
- 0:31
required to represent the information
- 0:33
most importantly no information is lost
- 0:36
this differs from lossy compression
- 0:37
algorithms like jpeg which can make an
- 0:39
image file smaller but information is
- 0:41
lost in the process gzip was developed
- 0:44
by jean-luc guys and mark alder in 1992
- 0:47
because the big evil tech corporations
- 0:48
held the patents on existing compression
- 0:50
technology their implementation is based
- 0:52
on the deflate compression algorithm
- 0:54
which is a combination of lz77 and
- 0:57
huffman coding gzip is not the only game
- 0:59
in town and other formats like zip 7zip
- 1:02
and rar solve similar problems on the
- 1:04
web gzip is the most common way to
- 1:06
implement end-to-end compression where a
- 1:08
file is compressed on the server then
- 1:10
decompressed by the browser to reduce
- 1:12
the amount of data sent over the network
- 1:14
although broadly is a newer compression
- 1:15
algorithm that's generally superior for
- 1:17
files on the web to get started open up
- 1:19
any linux machine where you'll find gzip
- 1:21
installed by default as one of the most
- 1:23
popular utilities of the gnu project to
- 1:25
compress a file use the gzip command
- 1:27
followed by the file name that creates a
- 1:29
new file ending in gz that should be
- 1:31
significantly smaller run the command
- 1:33
again with the l flag to print out the
- 1:35
compression ratio the higher the ratio
- 1:37
the more space that was saved now use
- 1:39
the d flag to decompress the file back
- 1:41
to its original form or better yet use
- 1:44
the gunzip command in the real world
- 1:46
though you'll often want to compress
- 1:47
multiple files at the same time gzip on
- 1:50
its own cannot compress an entire
- 1:51
directory for that you'll need to bring
- 1:53
in an archiver like tar its name is
- 1:55
derived from tape archive and what it
- 1:57
does is take multiple files and combine


