Compression on macOS and Windows¶
macOS¶
taris bsdtar (libarchive): reads and writes most formats and auto-detects compression. See universal extractors.zip,unzip,gzip,bzip2andxzare present; install the rest with Homebrew:brew install zstd lz4 p7zip pigz.- Finder's Compress creates zips that include
__MACOSX/folders and._*resource-fork files. Strip them on Linux withzip -d archive.zip '__MACOSX/*' '*/._*', or avoid them on the Mac:
# Create a zip from the command line, keeping macOS metadata in a sequestered form
ditto -c -k --sequesterRsrc --keepParent dir dir.zip
# Plain zip without macOS extras
COPYFILE_DISABLE=1 zip -r -X dir.zip dir/
# Plain tarball without ._ files
COPYFILE_DISABLE=1 tar czf dir.tar.gz dir/
# Extract preserving macOS metadata
ditto -x -k archive.zip dest/
.dmgdisk images:hdiutil attach file.dmg/hdiutil detach /Volumes/Name. On Linux,7z x file.dmgcan often extract them..pkginstallers are xar archives:pkgutil --expand file.pkg out/, orbsdtar -xf file.pkg/7z xon Linux.
Windows¶
tar.exe(bsdtar) has shipped with Windows 10 and 11 for years:
tar -xf file.tar.gz
tar -czf out.tar.gz dir
tar -xf file.zip # bsdtar reads zip too
- PowerShell handles zip only:
Compress-Archive -Path dir -DestinationPath out.zip
Compress-Archive -Path dir\* -DestinationPath out.zip -CompressionLevel Optimal
Expand-Archive out.zip -DestinationPath dest
- Recent Windows 11 builds open
.7z,.rar,.tar.*and other formats natively in File Explorer (via libarchive), and newer builds can create 7z and tar archives too. - 7-Zip remains the standard free GUI and CLI for everything else.
Moving archives between systems¶
| Problem | Cause | Fix |
|---|---|---|
| Files collide on extraction | Two names differing only in case on a case-insensitive filesystem | Rename before archiving |
| Text files look wrong | CRLF vs LF line endings | Configure editors/git; dos2unix |
| Scripts lose their execute bit | Zip tool didn't store or restore Unix modes | Use tar, or chmod +x after extracting |
| Garbled non-ASCII filenames | Legacy codepage in old zips | unar, 7z, or unzip -O CP437 |
| Symlinks become text files | Tool doesn't support links | Use tar, or zip -y and extract with Info-ZIP |
| Paths too long on Windows | 260-character legacy limit | Enable long paths, or extract closer to the drive root |
Reserved names (con, aux, nul) or : in names |
Not valid on Windows | Rename before archiving |
What to send¶
| Recipient | Format |
|---|---|
| Non-technical users on any OS | zip |
| Technical users | .zip or .tar.gz |
| Password-protected for humans | 7z with -mhe=on, or AES zip if they only have built-in tools |
| Yourself and your servers | .tar.zst |