ArticleslgStudy

computer science

Compress (software)

Compress (software) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Compress (software) rather than just read about it. In short: compress is a shell command for compressing data based on the LZW algorithm. uncompress is a companion shell command that restores files to their original state (both content and metadata) from a file created with compress. Although once popular, compress has fallen out of favor because it uses the patented LZW algorithm.

Key takeaways

  • Compress (software) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Compress (software) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Compress (software) from memory before moving on to harder problems.

Reference excerpt

compress is a shell command for compressing data based on the LZW algorithm. uncompress is a companion shell command that restores files to their original state (both content and metadata) from a file created with compress. Although once popular, compress has fallen out of favor because it uses the patented LZW algorithm. Its use has been replaced by commands such as gzip and bzip2 that use other algorithms and provide better data compression. Compared to gzip at its fastest setting, compress is slightly slower at compression, slightly faster at decompression, and has a significantly lower compression ratio. 1.8 MiB of memory is used to compress the Hutter Prize data, slightly more than gzip at its slowest setting. compress and uncompress have maintained a presence on Unix and BSD systems and have been ported to IBM i. compress was standardized in X/Open CAE Specification in 1994, and further in The Open Group Base Specifications, Issue 6 and 7. Linux Standard Base does not require compress. compress is often excluded from the default installation of a Linux distribution but can be installed from a separate package. compress is available for FreeBSD, OpenBSD, MINIX, Solaris and AIX. compress is allowed for Point-to-Point Protocol in RFC 1977 and for HTTP/1.1 in RFC 9110, though it is rarely used in modern deployments as the better deflate/gzip is available.

Use Files compressed by compress are typically named with extension ".Z" and therefore sometimes called .Z files. The extension derives from the earlier pack program which used extension ".z". Most tar implementations support compression by piping data through compress when given the -Z command line option. gunzip can decompress .Z files.

Algorithm The LZW algorithm used in compress was patented by Sperry Research Center in 1983. Terry Welch published an IEEE article on the algorithm in 1984, but failed to note that he had applied for a patent on the algorithm. Spencer Thomas of the University of Utah took this article and implemented compress in 1984, without realizing that a patent was pending on the LZW algorithm. The GIF image format also incorporated LZW compression in this way, and Unisys later claimed royalties on implementations of GIF. Joseph M. Orost led the team and worked with Thomas et al. to create the final (4.0) version of compress and published it as free software to the net.sources USENET group in 1985. U.S. patent 4,558,302 was granted in 1985 – making compress unusable without paying royalties to Sperry Research (which later merged into Unisys). The US LZW patent expired in 2003, so it is now in the public domain in the United States. Today, all LZW patents worldwide are expired (see Graphics Interchange Format#Unisys and LZW patent enforcement). As of POSIX.1-2024 compress supports the DEFLATE algorithm used in gzip.

File format The compressed output consists of bit groups. Each bit group consists of codes with fixed amount of bits (9–16). Each group, except the last group, is aligned to the number of bits per code multiplied by 8 and right padded with zeroes. The last group is aligned to 8 bit octets and padded with zeroes. More information can be found at an issue on the ncompress GitHub repository. Example:

Suppose the output has ten 9-bit codes, five 10-bit codes, and thirteen 11-bit codes. There are three groups to output containing 90 bits, 50 bits, and 143 bits of data. First group will be 90 bits of data + 54 zero bits of padding in order to be aligned to 72 bits (9 bits × 8). Second group will be 50 bits of data + 30 zero bits of padding in order to be aligned to 80 bits (10 bits × 8). Third group will be 143 bits of data + 1 zero bit of padding in order to be aligned to 8 bits (since this is the last group in the output). The existence of padding bits is actually a bug, as LZW does not require any alignment. This bug existed for more than 35 years and was in the original UNIX compress, ncompress, gzip and the Windows port. All application/x-compress files were created using this bug. Some compress implementations write random bits from uninitialized buffer in paddings. There is no guarantee that the paddings will be zeroes. The decompressor must ignore the values in the paddings for compatibility.

See also Image compression List of POSIX commands

References

External links compress: compress data – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group compress(1) – Version 8 Unix Programmer's Manual compress(1) – FreeBSD General Commands Manual compress(1) – OpenBSD General Commands Manual compress(1) – Solaris 11.4 User Commands Reference Manual ncompress - public domain compress/uncompress implementation for POSIX systems compress - original Unix compress (in a compress'd archive) compress - original Unix compress executable (gzip'd) Source Code for compress v4.0 (gzip'd sharchives) ZIP File containing a Windows port of the compress utility source code to the current version of fcompress.c from compress bit groups alignment - Explanation of bit groups alignment. lzws - New library and CLI, implemented without legacy code. ruby-lzws - Ruby bindings with streaming support.

Worked examples

Example 1 — a first encounter with Compress (software)

Start with the simplest possible case. Write down what Compress (software) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Compress (software) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Compress (software) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Compress (software)

In research
Compress (software) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Compress (software) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Compress (software) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Data compression software, IBM i Qshell commands, Standard Unix programs, so understanding it makes those chapters shorter.
In everyday life
Look for Compress (software) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Compress (software)” →

How to study Compress (software) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Compress (software) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Compress (software) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Compress (software) in simple terms?

compress is a shell command for compressing data based on the LZW algorithm. uncompress is a companion shell command that restores files to their original state (both content and metadata) from a file created with compress. Although once popular, compress has fallen out of favor because it uses the…

Why does Compress (software) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Compress (software)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Compress (software).

Tags

  • Data compression software
  • IBM i Qshell commands
  • Standard Unix programs
  • Unix SUS2008 utilities
  • Unix archivers and compression-related utilities

Keep exploring