Using cpio to extract/create archives in Linux

Commands to create or extract cpio files in Linux.

To create a cpio archive from a list of files:
[bash]ls | cpio -ov > nameOfArchive.cpio[/bash]
usage:
[bash]ls #to list the files to pack
| #pipe to cpio
o #create pack
v #list the files
> #pack to name-of-archive[/bash]

To extract a cpio archive to a destination dir:
[bash]cpio -idv < nameOfArchive.cpio[/bash]
usage:
[bash]i #extract
d #create dirs
v #show status
< #extract from pack to current dir[/bash]

how to use jar file commands

To extract a jar file from the command-line:

  • jar xf myapp.jar -extract a jar-file into jar-file-name-dir (within same dir)
  • jar xf myapp.jar file1 file2 file3 -extractspecific files only
  • jar cf myapp.jar file1 file2 dir1 -create a jar-file from a path(s)
  • jar tf myapp.jar -list contents of a jar-file
  • jre -cp myapp.jar MyMainClass -execute main class within a jar-file
  • java -jar myapp.jar