Tuncay Sahin

ICT Engineer | Docent ICT & Trainer

This document contains various TAR command  examples for creating and extracting (compressed) archive files.

Creating an archive using tar command

Creating a tar gzipped archive

# tar cvzf archive_name.tgz dirname/

The used options:-c option is used to create a new archive.
-v verbosely list files which are processed.
-f following is the archive file name.
-z filter the archive through gzip.

Extracting (untar) an archive using tar command

Extract a gzipped tar archive ( *.tgz ) using option xvzf

tar xvfz archive_name.tgz

Specify destination to extract.

tar -xvz –directory=/ -f /archive_name.tgz

The used options:-x extract files from archive.

Listing an archive using tar command

View the *.tgz file content without extracting using option tvzf

# tar tvfz archive_name.tar.gz

The used options:-t list the contents of an archive.

Extract a single file or directory

To extract a specific file from archive

# tar xvfz archive_file.tgz /path/to/file

To extract multiple directories from archive

# tar xvfz archive_file.tgz /path/to/dir1/ /path/to/dir2/

To extract a single directory

# tar xvfz archive_file.tgz /path/to/dir/

 

 

Meer informatie

Voor meer informatie of voor een persoonlijk adviesgesprek kunt u altijd vrijblijvend contact met mij opnemen.

E-Mail

info@tuncaysahin.nl