Compression Utility cpio tar gzip bzip - Create Extract Archive


cpio command is used to create and extract the archive file.
By using cpio command we can create extract archive file.
Example .
create the archive file with .c extension file
Compress: #find / -name *.c | cpio -o --format=tar > cfiles.tar
Extract : #cpio -i -F filename.tar

-o create the archive file.
--format mention the format
-i restore the file
#cpio -i -F cfile.tar
It Will extract and restore the file
Create the backup of the Home Directory
#fine /home | cpio -o --format=tar > homedir.tar

Backup utility tar command
tar - Tape Archive
-c create
-v verbose
-t table of content
-v verbose
-f file name
tar command syntax
Compress: #tar cvf [BACKUP.TAR] [SOURCE FILE]
Extract : #tar tvf filename.tar
#[root@jai xdata]#tar cvf cfile.tar *.c
Source file: *.c .c extension file
Destination Backup file: cfile.tar
How To View The Content of Tar file
[root@jai xdata]#tar tvf cfile.tar
-rw-rw-r-- nagios/nagios 5420 2008-11-30 12:22:59 xcddefault.c
-rw-rw-r-- nagios/nagios 7646 2008-11-30 12:22:59 xdddefault.c
-rw-rw-r-- nagios/nagios 581312 2010-03-29 10:51:38 xodtemplate.c
-rw-rw-r-- nagios/nagios 26785 2008-11-30 12:22:59 xpddefault.c
-rw-rw-r-- nagios/nagios 75607 2010-09-01 10:12:32 xrddefault.c
-rw-rw-r-- nagios/nagios 52664 2010-09-21 11:05:31 xsddefault.c

How to Extract the tar.bz2 file
#tar -jxvf file.tar.bz2
How to Extract the tar.gz file

#tar -zxvf file.tar.gz

using gzip we can compress only single file
compress: #gzip [SOURCE FILE NAME]
Extract : #gunzip filename.gz
it will compress file which file are having with the extension .c
After Compression
#gzip *.c
[root@jai xdata]#ll
-rw-rw-r-- 1 nagios nagios 1561 Nov 30 2008 xcddefault.c.gz
-rw-rw-r-- 1 nagios nagios 1509 Nov 30 2008 xcddefault.h
-rw-rw-r-- 1 nagios nagios 1948 Nov 30 2008 xdddefault.c.gz
-rw-rw-r-- 1 nagios nagios 1822 Nov 30 2008 xdddefault.h
#gunzip xdddefault.c.gz

bzip-bunzip- Compression
It will create the file with .bz2 extension compression.
Compress: #bzip2 [SOURCE FILE]
Extract : #bunzip2 [BACKUPFILE.bz2]
#bzip2 backup
#bunzip2 backup.bz2

No comments:
Write comments