Archive Tools Linux (tar, star, gzip, cpio, bzip2, zip)

First for the example please add directory and file as follows :

mkdir -p /tmp/diarycoding-dir/subdir1
mkdir -p /tmp/diarycoding-dir/subdir2
mkdir -p /tmp/diarycoding-dir/subdir3
mkdir -p /tmp/diaryextract-dir
touch /tmp/test-dir/subdir1/diaryfile1.txt
touch /tmp/test-dir/subdir1/diaryfile2.txt
touch /tmp/test-dir/subdir2/diaryfile3.txt
touch /tmp/test-dir/subdir2/diaryfile4.txt
touch /tmp/test-dir/subdir3/diaryfile5.txt
touch /tmp/test-dir/subdir3/diaryfile6.txt

the assume extract “diaryextract-dir” as directory empty.

Tar Method :

Create Archive

# cd /tmp
# tar -cvf archive1.tar diarycoding-dir

Check file

# tar -tvf /tmp/archive1.tar

Extract

# cd /tmp/diaryextract-dir
# tar -xvf /tmp/archive1.tar

Star Method :

Create Archive

# cd /tmp
# star -cv f=archive2.star diarycoding-dir

Check file

# star -tv f=/tmp/archive2.star

Extract

# cd /tmp/diaryextract-dir
# star -xv f=/tmp/archive2.star

Gzip Method :

Create Archive

# cd /tmp
# tar -cvf archive3.tar diarycoding-dir
# gzip archive3.tar

Check file

# gunzip archive3.tar.gz

Extract

# cd /tmp/diaryextract-dir
# tar -xvzf /tmp/archive3.tar.gz

Cpio Method :

Create Archive

# cd /tmp
# find diarycoding-dir | cpio -ov > archive6.cpio

Check file

# cpio -t < /tmp/archive6.cpio

Extract

# cd /tmp/diaryextract-dir
# cpio -idmv < /tmp/archive6.cpio

Bzip2 Method :

Create Archive

# cd /tmp
# tar -cvf archive4.tar diarycoding-dir
# bzip2 archive4.tar

Check file

# bunzip2 archive4.tar.bz2

Extract

# cd /tmp/diaryextract-dir
# tar -xvjf /tmp/archive4.tar.bz2

Zip Method :

Create Archive

# cd /tmp
# zip -r archive5.zip diarycoding-dir

Check file

# unzip -l archive5.zip

Extract

# cd /tmp/diaryextract-dir
# unzip /tmp/archive5.zip

www.diarycoding.com

Leave a Comment.