- [Instructor] In the previous video,
we looked at archiving with TAR.
In this video we're going to learn
about arching with cpio
to store files and directories in a file
with attributes such as permissions,
ownership, and so on.
Cpio is another archiving format similar to TAR.
It's used to store files and directories
in a file with attributes
such as permissions, ownership, and so on.
But it is not commonly used as much as TAR.
However cpio is used in rpm package archives
which I used in distros such as fedora.
In it ram fs files for the lynux kernel
which contain the kernel image and so on.
This video will give many more usage examples of cpio.
Let's now step ahead and see how to do it.
Cpio takes input file names through std in
and writes the archive to std out.
Here we have to redirect to std out
to a file to receive the std output cpo file as this.
So let's create the test files.
Now we can archive the test files with this command.
In order to list files in a cpio archive,
use this line.
Next, in order to extract files from the cpio archive,
we use this syntax.
Now, let's understand how it works.
For the archiving command,
minus O specifies the output,
minus V is used for printing a list of files archived.
By using cpio we can also archive
using files as absolute paths.
/user/sumdir is an absolute path
as it contains the full path starting from root,
ie slash.
A relative path will not start with slash
but starts the path from the current directory.
For example,
test/file means that there is a directory test
and the file is located inside the test directory.
While extracting, cpio extracts
to the absolute path itself,
but in case of TAR,
removes the slash in the absolute path
and converts it as a relative path.
In the command for listing all the files
in the given cpio archive,
minus I is for specifying the input,
minus T is for listing.
While using the command for extraction,
minus D stands for extracting
as cpio overwrites files without prompting.
Cool.
In this video we've learnt how to store files
and directories in a file with permissions,
ownership, and other attributes.
In the next video, we'll look at how to
compress data with gzip.