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 filenamelzop --fast filename |
| Best compression lzop offers (slower) | lzop -9 filenamelzop --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.lzolzop --decompress filename.lzo |
Extract (same as decompress; honors saved paths with -P) |
lzop -x filename.lzolzop --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.lzolzop --list filename.lzo |
| Test integrity (exit status 0 means OK) | lzop -t filename.lzolzop --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 filenamelzop --quiet filename |
| Print each file name as it is processed | lzop -v filenamelzop --verbose filename |
Help and version
| When to use | Command |
|---|---|
| Show built-in usage | lzop -hlzop --help |
| Show lzop and LZO library version | lzop -Vlzop --version |
lzop — command syntax
Synopsis from lzop --help on Ubuntu 25.04 (lzop 1.04):
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:
echo 'Hello lzop compression test line one.' > sample.txt
echo 'Second line for ratio demo.' >> sample.txt
lzop -v sample.txtSample output:
compressing sample.txt into sample.txt.lzoConfirm sizes and method with -l:
lzop -l sample.txt.lzoSample output:
method compressed uncompr. ratio uncompressed_name
LZO1X-1 66 66 100.0% sample.txtSmall 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:
rm -f sample.txt sample.txt.lzoOn 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:
echo 'restore me' > demo.txt
lzop demo.txt
rm demo.txt
lzop -d demo.txt.lzo
cat demo.txtSample output:
restore melzop -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:
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.txtSample output:
lzop: demo.txt: file already exists -- skipped
compressed payloadUse -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:
echo 'ok' > good.txt
lzop good.txt
lzop -t good.txt.lzo
lzop -t good.txtSample output:
testing good.txt.lzo OK
lzop: good.txt: not a lzop fileThe second line fails because good.txt is plain text, not an lzop archive.
rm -f good.txt good.txt.lzoCommon 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:
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.lzoSample output (sizes vary with random data):
-rw-r--r-- 1 root root 65584 ... best.lzo
-rw-r--r-- 1 root root 65584 ... fast.lzoOn random data the sizes are often close; on repetitive logs -9 usually wins more clearly.
rm -f big.bin fast.lzo best.lzoCommon 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:
echo 'pipe test' | lzop -c | wc -cSample output (byte count depends on payload):
130To 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:
echo 'only lzo remains' > once.txt
lzop -U once.txt
ls -l once.txt once.txt.lzo 2>&1Sample output:
ls: cannot access 'once.txt': No such file or directory
-rw-r--r-- 1 root root ... once.txt.lzoKeep backups before -U in production — the plain file is gone after a successful run.
rm -f once.txt.lzoAdvanced 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:
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-backupSample output:
-rw-r--r-- 1 root root ... /tmp/archive.lzo
-rw-r--r-- 1 root root ... data.log.lzo-backupClean up:
rm -f data.log data.log.lzo-backup /tmp/archive.lzolzop — when to use / when not
| Use lzop when | Use something else when |
|---|---|
|
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.
Related commands
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.
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 |
