Easy Tutorial
❮ Linux Comm Rwho Linux Comm Rmmod ❯

Linux tar Command

Linux Command Manual

The Linux tar (short for tape archive) command is used for backing up files.

tar is a tool for creating and restoring backup files. It can add to and extract files from backup archives.

Syntax

tar [-ABcdgGhiklmMoOpPrRsStuUvwWxzZ][-b &lt;block number>][-C &lt;destination directory>][-f &lt;backup file>][-F &lt;Script file>][-K <file>][-L &lt;media capacity>][-N &lt;date time>][-T &lt;template file>][-V &lt;volume name>][-X &lt;template file>][-&lt;device number>&lt;storage density>][--after-date=&lt;date time>][--atime-preserve][--backup=&lt;backup method>][--checkpoint][--concatenate][--confirmation][--delete][--exclude=&lt;template pattern>][--force-local][--group=&lt;group name>][--help][--ignore-failed-read][--new-volume-script=&lt;Script file>][--newer-mtime][--no-recursion][--null][--numeric-owner][--owner=&lt;user name>][--posix][--preserve][--preserve-order][--preserve-permissions][--record-size=&lt;block number>][--recursive-unlink][--remove-files][--rsh-command=<command>][--same-owner][--suffix=&lt;backup suffix string>][--totals][--use-compress-program=<command>][--version][--volno-file=&lt;number file>][files or directories...]

Parameters:

Examples

Compress file without packaging

# touch a.c       
# tar -czvf test.tar.gz a.c   // Compress a.c file to test.tar.gz
a.c

List the contents of the compressed file

# tar -tzvf test.tar.gz 
-rw-r--r-- root/root     0 2010-05-24 16:51:59 a.c

Extract files

# tar -xzvf test.tar.gz

tar -xzvf test.tar.gz

a.c

Linux Command Manual

❮ Linux Comm Rwho Linux Comm Rmmod ❯