Difference between revisions of "Linux archives"

From Ever changing code
Jump to navigation Jump to search
(Created page with "= TAR, GZ, BZIP = Working with archives in linux where '''tar = tape archive''' and the most common used options are: :'''c''' - ''create'' a new tar file :'''x''' - ''extrac...")
 
Line 13: Line 13:
  tar –czvf only_conf_backup.tar.gz /path/to/*.confra
  tar –czvf only_conf_backup.tar.gz /path/to/*.confra
===Extract===
===Extract===
  tar -xzvf tarname-to-extract.tar.gz
  tar -xzvf archive.tar.gz
Extract '''single file''' from compressed .tar.gz  
A'''single file''' from compressed .tar.gz  
  tar -xzvf backup_files.tar.gz myscript.txt
  tar -xzvf archive.tar.gz myscript.txt
Extract '''single directory''' (here conf directory) from compressed .tar.gz  
A '''single directory''' (here '''conf''' directory) from compressed .tar.gz  
  tar -xzvf backup_files.tar.gz conf
  tar -xzvf archive.tar.gz conf


===Preview files inside archive===
===Preview files inside archive===

Revision as of 22:54, 8 June 2014

TAR, GZ, BZIP

Working with archives in linux where tar = tape archive and the most common used options are:

c - create a new tar file
x - extract file
t - list the contents of an archive
z - compress use gzip compress, extention .tar.gz
j - compress use bzip2 compress, extention .tar.bz2
v - verbose displays files to compress or uncompress
f - file specify the new archive name or an archive to extract from

Compress

tar -czvf new_tarname.tar.gz /directory/to/be/compressed/

Create compress .tar.gz archive

tar –czvf only_conf_backup.tar.gz /path/to/*.confra

Extract

tar -xzvf archive.tar.gz

Asingle file from compressed .tar.gz

tar -xzvf archive.tar.gz myscript.txt

A single directory (here conf directory) from compressed .tar.gz

tar -xzvf archive.tar.gz conf

Preview files inside archive

tar -tzvf {.tar.gz}
tar -tjvf {.tbz2}

Zip

Install zip and unzip then use interactive method:

Extract using default options, retaining directory structure
unzip file.zip
Compress file or directory
zip file-or-directory