Pages

Sunday, March 20, 2016

Tar Command

Tar Command

The Linux “tar” stands for tape archive, which is used by large number of Linux/Unix system administrators to deal with tape drives backup.

Tar Usage and Options

c – create a archive file.
x – extract a archive file.
v – show the progress of archive file.
f – filename of archive file.
t – viewing content of archive file.
j – filter archive through bzip2.
z – filter archive through gzip.
r – append or update files or directories to existing archive file.
W – Verify a archive file.

tar examples:
# tar -cvf tecmint-14-09-12.tar /home/tecmint/

c – Creates a new .tar archive file.
v – Verbosely show the .tar file progress.
f – File name type of the archive file.

# tar cvzf MyImages-14-09-12.tar.gz /home/MyImages

c – Creates a new .tar archive file.
v – Verbosely show the .tar file progress.
z – filter archive through gzip.
f – File name type of the archive file.

untar examples:
# tar -xvf public_html-14-09-12.tar

x – extract a archive file.
v – Verbosely show the .tar file progress.
f – File name type of the archive file.

Untar files in specified Directory

# tar -xvf public_html-14-09-12.tar -C /home/public_html/videos/

Untar files in Current Directory

# tar -xvf public_html-14-09-12.tar

To tar multiple folders (in current directory):

# tar -cvf folders.tar folder1 folder2 folder3

To tar multiple folders (in different directories):

# tar -cvf folders.tar /path/to/folder1 /path/to/folder2 /path/to/folder3

# tar -cvf mergingtwo.tar.gz /u01/AAA /u03/BBB

No comments:

Post a Comment