Working with Linux archives

We can distinguish many archives format and compressions methods however 3 the most used are Tar, Gz, Bzip archives. TAR command helps working with archives in linux where tar = tape archive and its the most commonLinux tar.gz archive used options are:

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


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


tar -xzvf tarname-you-want-to-unzip.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}


Install zip and unzip then use interactive method:

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