Skip to main content

Tar

TAR basic options

tar options

Description

-x

Extract files from archive

-v

Verbose

-z

Filter the archive through gzip.
-z, --gzip, --gunzip, --ungzip

-f <file with extension .tar.gz>

Verbose

-c

Create a new archive

-C <Directory location>

Extract files to the specified directory location

-t

List the contents of the archive with out extracting

Archive with tar

Create archive of the folder

tar -czvf filename.tar.gz /path/to/directory

Create archive of multiple folders and files

tar -czvf filename.tar.gz /path/to/directory_1 dir_2 dir_3 file_1.txt file_2.pdf

list the content of the tar file

tar -ztvf filename.tar.gz

Extract with tar

Extract file with tar

tar -xzvf filename.tar.gz

Extract file with tar to specific folder

tar -xzvf filename.tar.gz -C /tmp/

The file will be extracted to /tmp folder