Now this is Linux, and we know we're never restricted just to one command.
As well as being able to create our archives using the tar command,
we've got the cpio, or copy, input, output command, to create our archives.
Reading from output, from one command, we can create our archive,
and reading from input, we're able to extract our archive.
The best way to show this happening is by moving out to our command line,
where I hope you're going to follow me,
and we're going to take a look at the nitty‑gritty of the cpio command.
Okay, to begin with, we're going to start with our find command.
So I can go through, and, using find,
I can go through and take a look inside of the usr/share/doc subdirectory,
where the name of the file, and we'll have,
let's say, ends in *.html.
Now with that done,
I can hit the Enter key, and when we take a look, we're seeing a
full path through to the file. Where we're accessing it via a
full path, if we send this to the cpio utility, a restore would
put it back in the full path.
Whereas, if I change into my usr/share/doc directory, and if I rerun that find
command, but this time if I take out the path, then I'm searching my current
working directory, and when we look at the path, it's represented by the
directory dot at the top of the structure. A restore would restore to your
current working directory in much the same way as we're backing up from our
current working directory.
So if we go back up and just take a look at that command, and we'll now go
through and pipe the output to our cpio command, and we can then go through
and specify that we're working with the output, and we can redirect our output
through to, say, temp, and then we'll just call it, let's say, doc.cpio. So
that has created our backup file.
I can go through and just take a look at it inside of the temp directory.
We can go through and actually to run the listing. There's our archive, and
the default color coding is going to give me that red color,
which is typical of our archive files.
Now I'm going to go through and then just create a restore directory. Again,
I'm just going to restore into the temp directory,
move into my restore directory, and then I can go through and use the
cpio command. And we can read in this time from, and then the parent
directory, add, of course, then, the file that we sent our back up to,
the doc.cpio. If I just run it like this,
we're going to get failures, because we've got directory
structures that don't exist. But don't worry,
it's not a problem.
If I go through and include the d option,
then we're going to create directories as required.
It will have been restored to my current working directory
based on that path we were looking at before.
So if I run a listing here,
so we've got everything in subdirectories, so subdirectories have been created.
I've got the tree command installed, and we can then go through and expand
our tree output to see then that we've got the four web pages that have
been created in the correct directory structure.
So the cpio utility can be used. Very often, it's used by the
system, in days gone by, not so much on more modern systems, but
many of the boot files were actually cpio archives that were
expanded during the boot phase of Linux.
We're going to move out to our slides now so we can summarize just a
little bit of what we've looked at in this module.
Hopefully, you found it really interesting, and you'll like going through trying to remind yourselves of what we actually did cover.