Handling IO with the UNIX ‘cpio’ command

David E Lares S
1 min readFeb 9, 2024

--

The cpio command copy files or folders to or from a directory, you can specify it will be an output or an input. This command is commonly used after a search result, a calculator, or a filtering-type command.

Here’s an example: find /etc -print | cpio -ov > etc.cpio

The -o specifies the output and the -v specify a detailed or verbose mode

This command can be quite tricky because can act as both input and output, so, it will depend strictly on how is used, to achieve a particular goal

In the example below, the find command will print and send to the output the resulting search under the /etc directory. That standard output will be piped as input to the cpio command that also will redirect the information as input for a etc.cpio (this will be created) with a bunch of content resulting from the previous results.

Here’s another example, applied directly but as input to the cpio command.

cpio -ivd < etc.cpio

--

--

David E Lares S
David E Lares S

Written by David E Lares S

Backend Developer, MalDev and InfoSec Student

No responses yet