Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › backups

File Compression Tools on Linux Servers: A Beginner’s Guide

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Short answer: use tar to collect a directory and its metadata, then pair it with a compressor. For the broadest compatibility, create a .tar.gz archive with tar -czf. Choose .tar.zst for fast, modern internal transfers when every endpoint has zstd, or .tar.xz when the smallest practical archive matters more than CPU time. A plain tar file is an archive, not a compressed file.

This separation explains nearly every Linux compression command: tar handles file names, permissions, ownership, timestamps, links, and directory structure; gzip, bzip2, xz, or zstd compresses the resulting byte stream. The correct choice depends on compatibility, CPU, memory, transfer time, and the tools installed on the receiving system.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What tar, gzip, xz, zstd, and bzip2 each do

tar is the archive layer

GNU tar collects many files and directories into one sequential archive stream. It stores directory structure and metadata such as permissions, ownership, timestamps, and symbolic links. By itself, tar -cf backup.tar directory/ does not reduce the data size; it only packages the inputs into one file.

GNU Project documentation describes GNU tar as able to create and read compressed archives. Compression is enabled by passing a compressor option, or by using a filename suffix with automatic selection. Tar supports gzip, bzip2, lzip, lzma, lzop, zstd, xz, and traditional compress; the commonly used switches are -z for gzip, -j for bzip2, -J for xz, and --zstd for zstd.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

A compressor handles the byte stream

After tar serializes the archive, the compressor encodes that stream. The result is normally named with two suffixes: .tar.gz (also called .tgz), .tar.bz2, .tar.xz, or .tar.zst. The suffix is not cosmetic: it tells people and automation which decoder is required.

For one ordinary file, tar is unnecessary. Standalone commands such as gzip access.log, xz dump.sql, or zstd backup.img compress the file directly. A standalone compressor generally replaces the original with a compressed version unless you select an option that writes elsewhere, so confirm your retention policy before running it on production data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which Linux compression format should you choose?

There is no universal speed or compression-ratio winner. Results vary with file type, compressor implementation and version, compression level, CPU architecture, available memory, and whether the workload is compressing or decompressing. The comparisons below describe operational trade-offs rather than a benchmark promise.

Format Typical reason to use it Compatibility CPU and memory trade-off Parallel and integrity considerations
gzip (.tar.gz, .tgz) Safest general-purpose default Very broad support across Unix/Linux systems and older automation Usually a practical balance for routine backups and transfers; exact results depend on level and workload Simple stream workflow; use the gzip decoder on the receiving host
zstd (.tar.zst) New internal workflows where compression and decompression speed matter Use only when all endpoints have zstd-capable tar or a zstd utility installed Offers configurable speed/ratio trade-offs; resource use depends on selected level and threads Modern implementations can use parallelism; verify decoder availability before standardizing
xz (.tar.xz) Compact archives when extra CPU time is acceptable Common on current Linux distributions but less universal than gzip in old scripts and minimal systems Often requires more CPU and may require more memory at stronger settings XZ Utils exposes thread, integrity-check, and LZMA2 controls
bzip2 (.tar.bz2) Reading or producing an existing legacy archive Established support, especially in older ecosystems Usually a less attractive new default when gzip or zstd are accepted; workload-specific measurements still apply Keep for interoperability requirements rather than assuming it is faster or smaller

Package ecosystems illustrate why support matters: Debian package metadata lists gzip, xz, zstd, and bzip2 as supported compression choices. A format that is excellent on the sending server is still a poor operational choice if the restore host cannot decode it.

A practical decision rule

  • Choose gzip for archives that must open on the widest range of Linux/Unix systems or pass through older automation.
  • Choose zstd for new, controlled workflows where both ends support it and fast compression or extraction is important.
  • Choose xz when storage or transfer size is the priority and the additional CPU and memory cost is acceptable.
  • Choose bzip2 when an existing process or recipient explicitly requires .bz2.

Prerequisites before you compress a server directory

Run the commands as a user who can read every input file. If preserving ownership, ACLs, extended attributes, or files readable only by root is necessary, perform the archive with appropriate privileges and test the restore as the intended account. Confirm free space for the archive: creating it in the source filesystem can temporarily require room for both the original tree and the output.

Check that the needed utilities exist on the machine and on every restore destination:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
tar --version
gzip --version
xz --version
zstd --version
bzip2 --version

A missing optional utility produces an immediate failure for that format. Do not silently substitute another format in automation; that can leave a file with an unexpected suffix and break the consumer.

Decide whether the archive should contain an absolute path or a portable relative path. Running tar from the parent directory and naming the directory usually gives a cleaner restore layout:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
cd /srv
tar -czf /var/backups/site-backup.tar.gz site

That command stores the top-level name site, rather than embedding the full /srv path. Inspect the archive before deleting or moving the source.

How to compress a directory with gzip

Gzip is the beginner-friendly default for broad compatibility. Create an archive with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
tar -czf site-backup.tar.gz /srv/site

The options are combined short flags: -c creates, -z filters the stream through gzip, and -f says the next argument is the output filename. The command reads the directory recursively and writes one compressed archive.

List a gzip archive without extracting it

tar -tzf site-backup.tar.gz

-t lists members, -z selects gzip, and -f identifies the archive. Use this check to confirm expected top-level paths and to catch an obvious wrong-file or wrong-directory mistake.

Extract a gzip archive

tar -xzf site-backup.tar.gz

By default, tar extracts into the current working directory. To choose a destination, add -C followed by an existing directory:

mkdir -p /restore/site
tar -xzf site-backup.tar.gz -C /restore/site

Before extracting an archive from an untrusted party, list its names and inspect for unexpected absolute paths or parent-directory components. Extract into a dedicated directory rather than directly over a live application tree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to create and extract tar.bz2 archives

Use bzip2 when a legacy archive or receiving system requires it:

tar -cjf logs.tar.bz2 /var/log/myapp
tar -tjf logs.tar.bz2
tar -xjf logs.tar.bz2

The -j flag selects bzip2. The archive remains a tar stream with a bzip2-compressed outer layer; its metadata behavior is still governed by tar, not bzip2.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

How to create and extract tar.xz archives

XZ is appropriate when a smaller archive justifies more compression time:

tar -cJf source.tar.xz source/
tar -tJf source.tar.xz
tar -xJf source.tar.xz

XZ Utils exposes controls for threads, integrity checks, and LZMA2 settings. For example, the Linux kernel documentation shows this explicit command:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
xz --threads=1 --check=crc32 --lzma2=dict=512KiB inputfile

That example compresses one file directly with xz; it is not a tar command. Treat its settings as an example of available controls, not as a universally optimal server profile. Stronger settings can consume substantial CPU and memory, especially on large inputs or busy machines.

How to create and extract tar.zst archives

Zstandard is a strong option for controlled, modern workflows where rapid compression and decompression matter:

tar --zstd -cf build.tar.zst build/
tar --zstd -tf build.tar.zst
tar --zstd -xf build.tar.zst

GNU tar recognizes zstd with --zstd. Confirm that the installed tar was built with zstd support and that the restore host has a compatible implementation. A recipient with only an old tar may be unable to open the archive even though the filename is correct.

Let tar select the compressor from the filename

GNU tar’s automatic compression option, short form -a, selects a compressor from the output suffix:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
tar -caf site-backup.tar.gz /srv/site
tar -caf source.tar.xz source/
tar -caf build.tar.zst build/

Automatic selection reduces the chance of pairing a suffix with the wrong flag, but it does not install missing compressors. The suffix must be recognized by the tar version on that server, and the corresponding utility must still be available.

Compressing a single file without tar

Use the standalone tools when there is no directory tree or metadata set to bundle:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
gzip access.log
gzip -d access.log.gz
xz dump.sql
zstd backup.img

Gzip’s decompression forms include gzip -d and gunzip. The same conceptual distinction applies to xz and zstd: the standalone utility handles one compressed stream, while tar is what packages many paths and their metadata.

Preserving paths, metadata, and permissions

Tar records metadata, but successful restoration depends on the privileges and options used during extraction. A non-root user may not be able to recreate another account’s ownership. Test restores with the same privilege model used in production, and document whether ownership, modes, symbolic links, ACLs, and extended attributes are part of the recovery requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a controlled extraction directory and review the resulting tree before replacing a live service. For application deployments, stop or quiesce writers when a consistent point-in-time snapshot is required; tar cannot make changing database files transactionally consistent merely by reading them.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify an archive before trusting or deleting the source

Compressed streams have little redundancy. GNU tar warns that compressed files can be difficult to recover after only a few damaged blocks. Keep an independent copy and verify the destination rather than treating a successful command exit as proof that a disaster recovery copy is usable.

  1. List the archive with the correct format flag, such as tar -tzf site-backup.tar.gz, and check that expected paths appear.
  2. Extract into a temporary directory or test host using the same distribution family as the eventual restore system.
  3. Compare representative file sizes, permissions, links, and application-level checksums with the source.
  4. Record an archive checksum after creation and verify it after transfer or at scheduled intervals.
  5. Only then consider removing or rotating the source according to your backup policy.

Tar documents that compressed archives cannot be appended to, deleted from, or updated in place. If files change, recreate the archive rather than attempting an in-place modification. Plan rotation and retention around complete archive creation.

Automation practices for reliable server jobs

A production job should make its assumptions visible. Record the exact tar command, tar and compressor versions, chosen compression level, archive checksum, source path, destination, and creation time. Keep logs of exit status and transfer status, and alert on either failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a temporary output name while an archive is being written, then rename it atomically after tar exits successfully. This prevents another job from mistaking a partially written file for a complete backup. Store the checksum beside the archive or in an independent verification system, not only inside the same filesystem that could fail.

Run extraction tests on the same distribution family as the restore target and on any other platform that must consume the file. A format policy should state the minimum tar, gzip, xz, zstd, or bzip2 versions accepted by your environment, because “Linux” alone does not guarantee identical utility support.

Common failures and how to fix them

“tar: command not found” or a missing compressor

Install the distribution package that provides tar or the requested compressor, or select a format already supported on both endpoints. Do not rename a gzip file to .tar.zst; the bytes and decoder must match.

The archive extracts into an unexpected directory

List its members first with the appropriate -t command. Re-run extraction from the intended working directory or use -C /path. For future archives, create them from the parent directory so the stored top-level path is deliberate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Extraction reports an unexpected end or checksum error

Treat this as possible truncation or corruption. Recheck the archive checksum, compare the source and destination sizes, and copy the archive again from an independent copy. Do not delete the only remaining source until a clean extraction succeeds.

Permission or ownership errors occur during restore

Extract as an account with the required privileges, or accept that ownership will be mapped to the extracting user. Confirm the target filesystem supports the metadata you intend to preserve and test the resulting service behavior.

The job is too slow or affects production load

Compression level, input type, CPU contention, memory pressure, and storage throughput all influence runtime. Move heavy compression to a scheduled window, lower the selected level, or choose a faster format such as zstd when every endpoint supports it. Do not infer a universal percentage or time from another server’s result.

What compression cannot do

Already-compressed media, encrypted data, and many database or backup formats may shrink little. Tar also does not deduplicate repeated content, encrypt an archive, or provide a complete backup strategy by itself. If confidentiality is required, add an encryption layer with a separately managed key; if point-in-time database recovery is required, use the database’s consistent backup mechanism before archiving its output.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compression is also not a substitute for redundancy. Maintain independent copies, verify them, and periodically perform a full restoration exercise. A single compressed file on the same server as the source protects against neither disk failure nor a compromised host.

A compact format-selection checklist

  • Will an older Unix host or minimal recovery image need to read it? Select gzip unless a stricter compatibility requirement says otherwise.
  • Do all sending and receiving hosts provide zstd support? If yes, zstd is a sensible speed-focused choice for internal workflows.
  • Is minimizing stored or transferred bytes worth additional CPU and memory? Consider xz and measure on representative data.
  • Does an existing process mandate bzip2? Keep using .tar.bz2 for that interface rather than converting casually.
  • Have you listed the archive, tested extraction, recorded a checksum, and retained an independent copy? Complete those checks before deleting the source.

For most beginners, the dependable starting command is tar -czf backup.tar.gz directory/, followed by tar -tzf to inspect and tar -xzf to restore. Once compatibility and restore testing are established, select zstd or xz according to the measured CPU, memory, storage, and transfer trade-offs of your own server workload.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

backupsbzip2Command LineGzipLinuxserver administrationtarxzzstd

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.