LinuxCommandLibrary

patool

Extract, create, test, and list archive contents

TLDR

Extract an archive

$ patool extract [path/to/archive]
copy

Create an archive
$ patool create [path/to/archive] [path/to/file_or_directory1 path/to/file_or_directory2 ...]
copy

List contents of an archive
$ patool list [path/to/archive]
copy

Compare the contents of two archives and display the differences in stdout
$ patool diff [path/to/archive1] [path/to/archive2]
copy

Search for a string inside the contents of an archive
$ patool search [path/to/archive]
copy

SYNOPSIS

patool [global-options...] command [command-options...] [archive] [files...]

PARAMETERS

-h, --help
    Show help message and exit

--version
    Show version information and exit

-v, --verbose
    Verbose output; repeat for more detail (-vv, -vvv)

-q, --quiet
    Suppress output; repeat for quieter (-qq)

-f, --force
    Overwrite files without prompting (extract/create)

-O, --outdir DIR
    Extract to specified directory

-z, --gzip
    Compress with gzip (create)

-j, --bzip2
    Compress with bzip2 (create)

-J, --xz
    Compress with xz (create)

--list, -l
    List archive contents (alias for 'list' command)

--password PWD, -p PWD
    Archive password

--backend BACKEND
    Force specific backend tool

DESCRIPTION

patool is a versatile command-line tool for handling various archive and compression formats with a unified interface. It supports extract, list, test, create, info, and repack operations on formats including 7z, ace, ar, arc, bzip2, cpio, deb, gz, iso, lha, lzh, lzma, rar, rpm, tar, uue, xz, zip, and zst.

patool automatically detects archive types and delegates to backend tools like 7z, unrar, unzip, or tar, ensuring portability across systems. It simplifies workflows by handling multi-part archives, passwords, and listing contents without extraction. Ideal for scripts and batch processing, it provides verbose output, progress indicators, and error handling.

Key benefits include no need for format-specific commands, support for wildcards in file lists, and options for output directories or overwrite protection. Requires Python 3 and respective backends for full functionality.

CAVEATS

Requires external backends (e.g., unrar for RAR, 7z for 7z); fails if missing. Multi-part archives need sequential naming. No built-in encryption for creation.

COMMANDS

extract: Unpack archive.
list: Show contents.
test: Verify integrity.
create: Make new archive.
info: Display archive details.
repack: Convert formats.

BACKENDS

Auto-detects: 7z/p7zip for 7z/xz; unrar for RAR; unzip for ZIP; tar for TAR variants; others via file(1). Install via package manager.

HISTORY

Developed by Claudio Satriani starting 2010 as Python script. Evolved into patool package (version 1.12+), focusing on cross-platform portability and backend abstraction. Widely used in Linux distros via repositories.

SEE ALSO

tar(1), unzip(1), unrar(1), 7z(1), pbzip2(1)

Copied to clipboard