uudecode
Decode uuencoded files
TLDR
Decode a file that was encoded with uuencode and print the result to stdout
Decode a file that was encoded with uuencode and write the result to a file
SYNOPSIS
uudecode [OPTION]... [FILE]...
Decodes one or more uuencoded files. If no FILE is specified, or if FILE is '-', uudecode reads from standard input.
PARAMETERS
-o OUTFILE
Directs the decoded output to OUTFILE instead of the filename specified within the uuencoded data. This is useful for renaming the file or avoiding overwriting existing files.
-p
Sends the decoded output to standard output (stdout) rather than creating a file. This is useful for piping the output to another command or viewing the content directly.
FILE...
One or more input files containing uuencoded data. If no files are provided, or if '-' is specified, uudecode reads from standard input.
DESCRIPTION
uudecode is a command-line utility used to decode files that have been encoded using the uuencode utility or a similar binary-to-text encoding scheme. This encoding method, common in the early days of the internet, allowed binary data (such as executable programs, images, or archives) to be transmitted over communication channels that were primarily designed for text, like email or Usenet newsgroups.
The utility works by reading the uuencoded text, which typically starts with a "begin" line and ends with an "end" line, and reconstructing the original binary file. It also attempts to restore the original filename and file permissions embedded within the uuencoded block. While largely superseded by more robust and standardized encoding methods like MIME (Base64) for email attachments, uudecode remains useful for legacy systems, processing old archives, or in situations where plain text transfer is still required.
CAVEATS
Security Risk: uudecode creates files with the name and permissions specified in the encoded data. Decoding content from untrusted sources can lead to arbitrary file creation or permission changes on your system, potentially overwriting critical files or creating executable content. Always exercise caution.
Input Sensitivity: The decoding process is sensitive to malformed, truncated, or corrupted input. Errors in the 'begin' or 'end' lines, or in the data block itself, can cause decoding failures or result in corrupted output files.
FILE NAMING AND PERMISSIONS
A key characteristic of uudecode is its ability to extract and apply the original filename and file permissions from the uuencoded header. The header typically includes a line like 'begin MODE FILENAME', where MODE specifies the file permissions in octal (e.g., 644) and FILENAME is the intended name of the decoded file. This feature, while convenient, also poses a security risk if decoding untrusted input.
STRUCTURE OF UUENCODED DATA
A uuencoded block generally begins with a line similar to 'begin 644 my_file.tar.gz', followed by multiple lines of encoded data, and concludes with an 'end' line. Each data line contains 45 characters representing 45 bytes of encoded data, plus a checksum character and a newline. The encoding process translates 3 bytes of binary data into 4 ASCII characters.
HISTORY
The uudecode utility, along with its encoding counterpart uuencode, originated in the early 1980s as part of the UUCP (Unix-to-Unix Copy Program) suite. It was developed to facilitate the transfer of binary files (like executables and images) across text-only communication channels, such as dial-up modems and early email systems like Usenet, long before the widespread adoption of MIME standards for email attachments. Its simplicity made it a ubiquitous method for sharing non-text data in the nascent internet era.