bunzip2

file compressionLinux
The bunzip2 command is one of the most frequently used commands in Linux/Unix-like operating systems. bunzip2 Decompress files compressed with bzip2

Quick Reference

Command Name:

bunzip2

Category:

file compression

Platform:

Linux

Basic Usage:

bunzip2 [options] [arguments]

Common Use Cases

  • 1

    File decompression

    Decompress bzip2 compressed files

  • 2

    Archive extraction

    Extract files from bzip2 compressed archives

  • 3

    Data recovery

    Recover data from compressed backups

  • 4

    File processing

    Process compressed files in automated workflows

Syntax

bunzip2 [OPTIONS] [FILE...]

Options

Option Description
-c, --stdout Decompress to standard output
-d, --decompress Force decompression mode
-f, --force Force overwrite of output files
-k, --keep Keep input files after decompression
-s, --small Use less memory (at the expense of speed)
-t, --test Test compressed file integrity
-v, --verbose Show verbose output
-L, --license Display software license
-V, --version Display version information
-q, --quiet Suppress all warnings

Examples

How to Use These Examples

The examples below show common ways to use the bunzip2 command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

Decompress file.bz2 and remove the .bz2 extension
bunzip2 file.bz2
Decompress file.bz2 but keep the original compressed file
bunzip2 -k file.bz2
Decompress multiple files with verbose output
bunzip2 -v file1.bz2 file2.bz2

Advanced Examples:

Test the integrity of the compressed file without decompressing
bunzip2 -t archive.bz2
Force decompression even if output file already exists
bunzip2 -f file.bz2
Decompress to standard output and redirect to a file
bunzip2 -c file.bz2 > output.txt

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

The bunzip2 command is a decompression tool that extracts files compressed with bzip2 compression. It's part of the bzip2 compression utilities package. Key features of bunzip2: 1. **Efficient Decompression**: Restores files compressed with the bzip2 algorithm, which typically provides better compression than gzip. 2. **File Handling**: By default, bunzip2 removes the compressed file after successful decompression. Use the -k option to keep the original. 3. **File Integrity**: The -t option allows verifying the integrity of compressed files without actually decompressing them. 4. **Automatic Extension Handling**: bunzip2 automatically removes the .bz2 extension from decompressed files. 5. **Stream Support**: Can decompress data from standard input or output to standard output, making it useful in pipelines. Common use cases: - Decompressing downloaded software archives - Extracting compressed log files - Processing compressed data in shell scripts - Verifying the integrity of bzip2 archives bunzip2 is actually a symbolic link to the bzip2 program, which detects whether to compress or decompress based on how it's invoked. When called as bunzip2, it operates in decompression mode.

Common Use Cases

File decompression

Decompress bzip2 compressed files

Archive extraction

Extract files from bzip2 compressed archives

Data recovery

Recover data from compressed backups

File processing

Process compressed files in automated workflows

Storage optimization

Decompress files to save storage space

Related Commands

These commands are frequently used alongside bunzip2 or serve similar purposes:

Use Cases

1

File decompression

Decompress bzip2 compressed files

2

Archive extraction

Extract files from bzip2 compressed archives

3

Data recovery

Recover data from compressed backups

4

File processing

Process compressed files in automated workflows

5

Storage optimization

Decompress files to save storage space

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the bunzip2 command works in different scenarios.

$ bunzip2
View All Commands