gzexe
Compress executables and make them self-extracting
TLDR
Compress an executable file in-place
Decompress a compressed executable in-place (i.e. convert the shell script back to an uncompressed binary)
SYNOPSIS
gzexe [options] [executable_file ...]
PARAMETERS
-n
Do not change the file name suffix.
-d
Decompress the given files instead of compressing them. This is the same as running `gzip -d` on the file.
-v
Verbose mode. Print a message for each file compressed or decompressed.
-f
Force compression even if the file name already has a `.gz` suffix or if the file is already compressed.
-x
Extract the original executable file. The file will be renamed from file.gz to file.
-?
Display help information and exit.
--help
Display help information and exit.
--version
Display version information and exit.
DESCRIPTION
gzexe is a utility that compresses executable files to save disk space. When you run a gzexe-compressed executable, it is automatically decompressed into memory and executed. This process is transparent to the user. gzexe prepends a small decompression stub to the executable. When invoked, the stub first checks if the standard output is a tty. If so, it prints a message informing the user that the program is being decompressed. The stub then decompresses the original executable into a temporary file and executes it. Finally, the temporary file is deleted.
While gzexe was useful in the past when disk space was limited, it is now largely obsolete due to the low cost of disk space, the availability of better compression algorithms (like those used by squashfs or Docker images), and the potential security risks associated with dynamically decompressing code.
CAVEATS
Using gzexe modifies the original executable file. Executables compressed with gzexe may run slower due to the decompression overhead. Decompression to /tmp is a security risk, and could be intercepted.
SECURITY CONSIDERATIONS
Because gzexe decompresses the executable to a temporary file (typically in /tmp), it can introduce security vulnerabilities. An attacker might be able to overwrite or tamper with the temporary file while it is being created or executed. Modern systems use more secure methods for handling compressed executables, like dynamically linked libraries or containerization technologies.
HISTORY
gzexe has been around since the early days of Unix and Linux. It was originally developed as a way to save disk space, which was a scarce resource at the time. However, with the advent of larger and cheaper hard drives, as well as more efficient compression algorithms, gzexe has become less widely used. It still exists in some distributions for backwards compatibility.