cpio basic extract command, 'tar xzvf' equivalent?

I've received a Unix software distribution as a compressed cpio file. What's the best command to extract the files?


gzip -cd foo.cpio.gz | cpio -idmv
  • i : extract (input)
  • d : create directories
  • m : preserve mtime
  • v : verbose

mkdir archive
cd archive
zcat ../archive.cpio.gz | cpio -idmv --no-absolute-filenames

While this is an old question, it shows up high on Google, so I thought I might update it. I agree with the accepted answer in general, but you should add "--no-absolute-filenames" unless you are intending to overwrite important system files on your machine. Also, personally, I prefer "zcat" over "gzip -cd" or "gunzip -c".

Finally, note that you need to run cpio as root (e.g. sudo) if you are extracting a root filesystem that contains device nodes.