Compress and Extract Files
Same handful of tasks — compress, list contents, extract, extract one file, password-protect — done with whichever archiver you’ve got or the target format requires. Each tool’s own flags and quirks live on its own page; this hub just frames the task and links out.
Compress a folder
- tar — the Unix-native default, no built-in compression on its own (paired with gzip/bzip2/xz in practice).
- tar.gz — tar plus gzip, the common compressed tarball.
- zip — cross-platform, what most non-Unix tools expect.
- 7zip — best compression ratio, native
.7zformat, can also read/write.zip.
List an archive’s contents without extracting
Every tool supports this — see each page’s “Show Files” section: tar, zip, 7zip.
Search inside an archive without extracting
Stream the contents to grep, or use rga/zipgrep — see
Search Inside Archives.
Extract everything, or just one file
All three support extracting to a specific location and pulling a single named file out of the archive without unpacking the rest — see each page’s “Extract” sections.
Password-protect an archive
tar has no native encryption — pipe through gpg or openssl instead
if you need this with tar. zip and 7zip both support a -e/-p
password flag directly — see their “Zip with Password” /
“Compress with Password” sections.
Which one should I actually use?
- Sending a file to someone on Windows who’ll just double-click it →
zip. - Best compression ratio, don’t care about cross-tool compatibility →
7zip. - Working entirely within Unix tooling, piping to/from other commands →
tar.