Background:
The tar command was developed during the 90’s it was originally designed to backup I/O devices into tapes.
Nowadays it is commonly used for archiving files and folders into single file.
The popular switches you should use on a daily basis while using the tar command are:
Meaning
|
Switches
|
Save permissions
while compressing or decompressing
|
P
|
Create a tarball
|
c
|
Extract a tarball
|
x
|
shows
and lists all files processed (v stands for verbose)
|
v
|
Automatically
compress or uncompress it (calls the gzip method(
|
z
|
Deals with bzip
file, for example the linux kernel is compressed in bz2
(see http://www.kernel.org)
|
j
|
Specifies the
file name
|
f
|
Comment: You can use the –C for changing directory.
For example creating a tar with saving privileges and compressing the folder myData:
gil@ubuntu:~/myData$ sudo tar –pcvzf myCompressedFile.tar *
the * is a wildcard for grabbing everything in the myData folder
For example extracting a tar with saving privileges and decompressing the file myCompressedFile.tar:
gil@ubuntu:~/myData$ sudo tar –pxvzf myCompressedFile.tar
gz command (gzip)
A compressing/uncompressing tool which less used nowadays because of the increase usage of the tar command. It uses the famous Lempel-ziv algorithm (I’ll be talking about it in the close future)
Compressing syntax: sudo gzip
Decompressing syntax: sudo gunzip
That’s it for today’s lesson, now try it on your Linux distribution! J
No comments:
Post a Comment