LinuxCommandLibrary

atool

Extract, list, create, and check archive files

TLDR

List files in an archive

$ atool [[-l|--list]] [path/to/archive.zip]
copy

Extract an archive (safely creates a subdirectory if needed)
$ atool [[-x|--extract]] [archive.tar.gz]
copy

Extract an archive to a specific directory
$ atool [[-X|--extract-to]] [path/to/output_directory] [archive.rar]
copy

Display a specific file's content from an archive to stdout (like cat)
$ atool [[-c|--cat]] [archive.tar] [path/to/file_in_archive.txt]
copy

Create a new archive from specified files and/or directories
$ atool [[-a|--add]] [new_archive.zip] [path/to/file1 path/to/file2 ...]
copy

List files in an archive and send the output through a pager
$ atool [[-l|--list]] [[-p|--pager]] [large_archive.tar.bz2]
copy

Extract multiple archives at once (each to its own subdirectory if needed)
$ atool [[-x|--extract]] [[-e|--each]] [archive1.zip] [archive2.tar.gz] [*.rar]
copy

Repack an archive from one format to another (e.g., .tar.gz to .tar.7z)
$ atool [[-r|--repack]] [old_archive.tar.gz] [new_archive.tar.7z]
copy

SYNOPSIS

atool [options] {c|x|e|p|l|t|a|d} archive [files...]

PARAMETERS

-h, --help
    Display help message and exit

-V, --version
    Show version information and exit

-v, --verbose[=level]
    Increase verbosity (default level 1; 0=quiet, 2=more)

-q
    Shortcut for --verbose=0 (quiet mode)

-f, --force
    Overwrite existing files without prompting

-n, --simulate
    Dry run: show actions without executing

-D, --dir=DIR
    Change to directory DIR before processing

-F, --format=FORMAT
    Force specific archive format

-S, --program=PROG
    Use PROG as the archive handler

-o, --option=OPT
    Pass OPT to the backend program

--files-from=FILE
    Read list of files from FILE

-X, --exclude=PATTERN
    Exclude files matching PATTERN

--include=PATTERN
    Include only files matching PATTERN

--each
    Recurse into nested archives

--list-formats
    List all supported formats

--explain
    Explain detection and actions

--password=PASS
    Supply password for encrypted archives

DESCRIPTION

atool is a versatile Linux command-line script that provides a consistent interface for handling numerous archive and compression formats. It supports operations like creating (c), extracting (x or e), listing (l), testing (t), printing (p), adding (a), and deleting (d) files in archives such as tar, zip, rar, 7z, gzip, bzip2, xz, lzma, deb, rpm, and many more.

atool automatically detects archive types and invokes the appropriate backend tools (e.g., tar, unzip, unrar, 7za). This eliminates the need to learn syntax for each format. Options allow customization like verbosity control, directory changes, format overrides, and exclusion patterns. It preserves file permissions, timestamps, and handles passwords for encrypted archives.

Ideal for scripts and users dealing with mixed archive types, atool simplifies workflows in backups, package management, and file distribution. Verbose mode aids debugging, while simulation previews actions without changes.

CAVEATS

Requires backend tools installed (e.g., tar, unzip, unrar, 7z). Some formats limited by backend capabilities. No built-in compression selection for all cases; use options like --gzip.

COMMON COMMANDS

c: create archive
x|e: extract (x uses full paths)
l: list contents
t: test archive
p: print to stdout

SUPPORTED FORMATS

Over 50 types: tar, zip, rar, 7z, gz, bz2, xz, lzma, deb, rpm, ar, cab, lha, ace, zoo, jar, war, ear, slp, ha, z.
Use atool --list-formats for complete list.

HISTORY

Developed by Astrid in 1999 as part of her 'a*' tool suite. Initial release 0.10; evolved to support more formats. Latest stable 0.39.0 (2017), maintained in distributions like Debian.

SEE ALSO

tar(1), unzip(1), zip(1), 7z(1), unar(1), unrar(5)

Copied to clipboard