lzop Command in Linux: Syntax, Options & Practical Examples

lzop compresses single files with the LZO algorithm and writes .lzo archives. It favors speed over the smallest possible size — useful when you need quick one-file compression without building a tar archive.

Published

Updated

Read time 10 min read

Reviewed byDeepak Prasad

lzop Command in Linux: Syntax, Options & Practical Examples
About lzop compresses single files with the LZO algorithm and writes .lzo archives. It favors speed over the smallest possible size — useful when you need quick one-file compression without building a tar archive.
Tested on Ubuntu 25.04 (Plucky Puffin); lzop 1.04; kernel 7.0.0-27-generic
Package lzop
Man page lzop(1)
Privilege none
Distros

Most Linux distros with the lzop package (Ubuntu, Debian, Fedora, RHEL).

Multi-file archives: tar, bzip2, xz.

lzop — quick reference

Compression

Compress regular files or symlinks into .lzo files — one input file becomes one .lzo output. Directories are skipped.

When to use Command
Compress a file (creates filename.lzo, keeps the original) lzop filename
Compress several files in one run lzop file1 file2 file3
Fastest compression (less size reduction) lzop -1 filename
lzop --fast filename
Best compression lzop offers (slower) lzop -9 filename
lzop --best filename
Overwrite an existing .lzo without prompting lzop -f filename
Write compressed data to stdout (pipe-friendly) lzop -c filename
Write output to a specific path lzop -o /path/out.lzo filename
Use a custom suffix instead of .lzo lzop -S .lzo-backup filename
Delete the original after a successful compress lzop -U filename

Decompression and extraction

Restore plain files from .lzo archives. -d and -x both decompress; -x can also restore saved paths when -P was used at compress time.

When to use Command
Decompress to the same directory lzop -d filename.lzo
lzop --decompress filename.lzo
Extract (same as decompress; honors saved paths with -P) lzop -x filename.lzo
lzop --extract filename.lzo
Decompress every .lzo in the current directory lzop -d *.lzo
Overwrite an existing plain file when decompressing lzop -f -d filename.lzo
Restore the original filename stored in the archive lzop -dN filename.lzo
Delete the .lzo after a successful decompress lzop -dU filename.lzo

Inspection

Check archive contents and integrity without writing a new plain file.

When to use Command
List method, sizes, and ratio lzop -l filename.lzo
lzop --list filename.lzo
Test integrity (exit status 0 means OK) lzop -t filename.lzo
lzop --test filename.lzo

Output control

Quiet or verbose runs — helpful in scripts and cron jobs.

When to use Command
Suppress warnings and most messages lzop -q filename
lzop --quiet filename
Print each file name as it is processed lzop -v filename
lzop --verbose filename

Help and version

When to use Command
Show built-in usage lzop -h
lzop --help
Show lzop and LZO library version lzop -V
lzop --version

lzop — command syntax

Synopsis from lzop --help on Ubuntu 25.04 (lzop 1.04):

text
Usage: lzop [-dxlthIVL19] [-qvcfFnNPkUp] [-o file] [-S suffix] [file..]

Commands:
  -1     compress faster                   -9    compress better
  -d     decompress                        -x    extract (same as -dPp)
  -l     list compressed file              -I    display system information
  -t     test compressed file              -V    display version number
  -h     give this help                    -L    display software license
Options:
  -q     be quiet                          -v       be verbose
  -c     write on standard output          -oFILE   write output to 'FILE'
  -p     write output to current dir       -pDIR    write to path 'DIR'
  -f     force overwrite of output files
  -n     do not restore the original file name (default)
  -N     restore the original file name
  -P     restore or save the original path and file name
  -S.suf use suffix .suf on compressed files
  -U     delete input files after successful operation (like gzip and bzip2)
  file.. files to (de)compress. If none given, try standard input.

lzop only compresses regular files and symbolic links — not directories. For many files in one archive, combine tar with gzip, bzip2, or xz — see the tar command.


lzop — command examples

Essential Compress a file and list the archive

Use this when you want a quick .lzo copy of one log or data file. lzop keeps the original and adds filename.lzo beside it.

Run the command:

bash
echo 'Hello lzop compression test line one.' > sample.txt
echo 'Second line for ratio demo.' >> sample.txt
lzop -v sample.txt

Sample output:

text
compressing sample.txt into sample.txt.lzo

Confirm sizes and method with -l:

bash
lzop -l sample.txt.lzo

Sample output:

text
method      compressed  uncompr. ratio uncompressed_name
LZO1X-1            66        66 100.0% sample.txt

Small files sometimes show a 100% ratio because the header overhead matches the payload — that is normal for tiny test files.

Clean up when you are done:

bash
rm -f sample.txt sample.txt.lzo

On very small inputs the ratio line often reads 100% — the header overhead cancels out any savings.

Essential Decompress when the plain file is missing

After compression you can remove the original and restore it later with -d.

Run the command:

bash
echo 'restore me' > demo.txt
lzop demo.txt
rm demo.txt
lzop -d demo.txt.lzo
cat demo.txt

Sample output:

text
restore me

lzop -d writes the plain file next to the .lzo in the current directory unless you used -o or -p when compressing.

Essential Decompress when the target file already exists

Without -f, lzop refuses to overwrite an existing plain file and prints an error. Force the write when you intend to replace the old file.

Run the command:

bash
echo 'old content' > demo.txt
echo 'compressed payload' | lzop -c > demo.txt.lzo
lzop -d demo.txt.lzo 2>&1 || true
lzop -f -d demo.txt.lzo
cat demo.txt

Sample output:

text
lzop: demo.txt: file already exists -- skipped
compressed payload

Use -f only when you are sure the on-disk file can be replaced.

Common Test a .lzo file and spot a wrong file type

Run -t in scripts or before copying archives off the host. Exit status 0 means the archive passed the check.

Run the command:

bash
echo 'ok' > good.txt
lzop good.txt
lzop -t good.txt.lzo
lzop -t good.txt

Sample output:

text
testing good.txt.lzo OK
lzop: good.txt: not a lzop file

The second line fails because good.txt is plain text, not an lzop archive.

bash
rm -f good.txt good.txt.lzo
Common Compare fast (-1) and best (-9) output size

Level -3 is the default. Use -1 for speed or -9 when you want the smallest .lzo lzop can produce.

Run the command:

bash
dd if=/dev/urandom of=big.bin bs=1K count=64 2>/dev/null
lzop -1 -f -o fast.lzo big.bin
lzop -9 -f -o best.lzo big.bin
ls -l fast.lzo best.lzo

Sample output (sizes vary with random data):

text
-rw-r--r-- 1 root root 65584 ... best.lzo
-rw-r--r-- 1 root root 65584 ... fast.lzo

On random data the sizes are often close; on repetitive logs -9 usually wins more clearly.

bash
rm -f big.bin fast.lzo best.lzo
Common Compress to stdout with -c

Pipe compressed bytes to another tool or remote copy without creating a temporary .lzo on disk first.

Run the command:

bash
echo 'pipe test' | lzop -c | wc -c

Sample output (byte count depends on payload):

text
130

To unpack from a pipe, decompress with lzop -d on a saved .lzo file or lzop -dc file.lzo to stdout.

Common Remove the original after compression (-U)

Like gzip -f, -U deletes the source file only after lzop succeeds — useful when disk space is tight.

Run the command:

bash
echo 'only lzo remains' > once.txt
lzop -U once.txt
ls -l once.txt once.txt.lzo 2>&1

Sample output:

text
ls: cannot access 'once.txt': No such file or directory
-rw-r--r-- 1 root root ... once.txt.lzo

Keep backups before -U in production — the plain file is gone after a successful run.

bash
rm -f once.txt.lzo
Advanced Custom output path and suffix

Send the archive to a fixed path or change the extension when .lzo does not fit your naming scheme.

Run the command:

bash
echo 'custom name' > data.log
lzop -o /tmp/archive.lzo data.log
lzop -S .lzo-backup -f data.log
ls -l /tmp/archive.lzo data.log.lzo-backup

Sample output:

text
-rw-r--r-- 1 root root ... /tmp/archive.lzo
-rw-r--r-- 1 root root ... data.log.lzo-backup

Clean up:

bash
rm -f data.log data.log.lzo-backup /tmp/archive.lzo

lzop — when to use / when not

Use lzop whenUse something else when
  • You need fast single-file compression
  • CPU time matters more than the last few percent of size
  • You already installed the small lzop package
  • You need one archive of a whole directory tree → tar plus gzip, bzip2, or xz
  • You must match Windows zip tools → zip utilities
  • You want the smallest possible size at any speed → xz or bzip2
  • The receiver only understands .gz → gzip

lzop vs gzip

lzop gzip
Algorithm LZO (speed-oriented) DEFLATE (widely deployed)
Typical extension .lzo .gz
Default tool on most distros Optional package Usually preinstalled
Best for Quick one-off compression Default interchange format

Both tools compress one file per invocation unless you wrap them in tar.


File compression and archiving on Linux — pick the tool that matches archive shape and compatibility.

Command One line
lzop Fast LZO single-file compression (this page)
tar Bundle many files before compressing

Browse the full index in our Linux commands reference.


lzop — interview corner

What is lzop used for in Linux?

lzop compresses individual files with the LZO algorithm. The name stands for Lempel-Ziv-Oberhumer Packer. Each compressed file usually gets a .lzo suffix while keeping the same owner, mode, and timestamps as the source.

Unlike tar, lzop does not bundle directories — it only handles regular files and symbolic links. Admins reach for lzop when they want speed more than the smallest possible archive.

A strong answer is:

"lzop is a fast single-file compressor using LZO. It writes .lzo files, keeps metadata, and suits quick compression when gzip or xz is too slow for the workflow."

How does lzop differ from gzip?

Both compress one file at a time, but they target different trade-offs:

lzop gzip
Speed Usually faster Moderate
Ratio Often larger than gzip on text Better default interchange
Extension .lzo .gz
Availability Extra package on many distros Nearly always installed

Use gzip when others must read the file without extra packages. Use lzop when your pipeline is CPU-bound and you already standardize on .lzo.

A strong answer is:

"gzip is the common interchange format; lzop favors speed with LZO and .lzo files. I pick lzop for internal fast compression and gzip when compatibility matters."

How do you verify a .lzo file is not corrupted?

Run lzop -t (or lzop --test) on the archive. A healthy file prints testing file.lzo OK and exits 0. Pointing -t at a plain text file fails with not a lzop file.

bash
lzop -t backup.log.lzo
echo $?

Use -t after network copies or before deleting the only uncompressed copy.

A strong answer is:

"I run lzop -t on the .lzo file and check exit status zero — it decompresses in memory without writing a new plain file."

Why does lzop refuse to decompress sometimes?

By default lzop will not overwrite an existing output file. If report.txt already exists, lzop -d report.txt.lzo skips the write and may print file already exists -- skipped.

Fix it intentionally with -f (force) or remove/rename the old plain file first. The same rule applies when compressing if file.lzo already exists.

A strong answer is:

"lzop skips overwriting existing outputs unless you pass -f. I use -f only when replacing the destination is deliberate."

What do lzop -1 and lzop -9 mean?

They set the compression level. -1 / --fast picks the quickest method (less CPU, often a larger file). -9 / --best spends more time for a smaller .lzo. The default is -3 when you run plain lzop file.

Levels are a speed-vs-size knob — not a security setting.

A strong answer is:

"-1 is fastest, -9 is best compression lzop offers, default is -3. I use -1 for hot paths and -9 when archives are stored long term."


Troubleshooting

Symptom Likely cause Fix
not a lzop file File is plain text or wrong format Confirm the path ends in .lzo and was created by lzop
file already exists -- skipped Output path already present lzop -f or remove the existing file
lzop: command not found Package not installed sudo apt install lzop on Ubuntu/Debian
Directory ignored lzop skips directories Archive with tar first
lzop -N skips decompress Plain file already exists rm the target or add -f
skipped with no message in scripts Missing -f and destination exists Add -f or choose a new -o path

Rohan Timalsina

is a technical writer and Linux enthusiast who writes practical guides on Linux commands and system administration. He focuses on simplifying complex topics through clear explanations.