Linux archives
		
		
		
		Jump to navigation
		Jump to search
		
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 tarname-to-extract.tar.gz
Extract single file from compressed .tar.gz
tar -xzvf backup_files.tar.gz myscript.txt
Extract single directory (here conf directory) from compressed .tar.gz
tar -xzvf backup_files.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