How to List All Members of a Cpio Archive on Ubuntu
This guide explains how to view the contents of a cpio archive within the Ubuntu Linux environment. You will learn the specific command-line flags required to list all file members without extracting them. Whether you are managing backups or verifying archive integrity, knowing how to inspect cpio files efficiently is essential for system administration tasks.
The Basic List Command
To list the members of a cpio archive, use the cpio
command with the -t flag. This flag tells cpio to print the
table of contents. Since cpio reads from standard input, you must
redirect the archive file into the command.
Run the following command in your terminal:
cpio -t < archive.cpioReplace archive.cpio with the actual name of your file.
This will output a simple list of file paths stored within the
archive.
Viewing Detailed Information
If you require more details about each member, such as permissions,
owner, and file size, add the -v (verbose) flag. This works
similarly to the ls -l command for standard
directories.
cpio -tv < archive.cpioThis provides a comprehensive view of the archive structure without extracting any data to your disk.
Listing Compressed Archives
Many cpio archives are compressed using gzip. If your file ends with
.gz, you cannot redirect it directly. Instead, use
zcat or gunzip to decompress the stream and
pipe it into cpio.
zcat archive.cpio.gz | cpio -tFor verbose output on a compressed file, combine the flags:
zcat archive.cpio.gz | cpio -tvThese commands allow you to quickly verify the contents of both raw and compressed cpio archives on your Ubuntu system.