Compression and Extraction in Linux
Compression can be done using three methods: zip, jzip, bzip2. zip is rarely used in Linux, used mainly in Windows. jzip and bzip2 are exclusively used in Linux. Both are more efficient than zip. Out of jzip and bzip2, bzip2 is efficient. But for small files both have the same efficiency. bzip2 show its difference when file size is more than 2mb. Any number of files and sub-directories can be archived and compressed into a single .tar.gz or .taz file.
To archive a file:
tar cvf a.tar abcd
where c in cvf indicates the creation of file a.tar. abcd is the file to be archived.
To compress the archived file:
a file named a.tar.gz or a.taz will be created in the current directory.
In the extraction process we first unzip a.taz or a.tar.tz to get the archived file.
Now we get a file named a.tar, to make it a normal file:
tar xvf a.tar
Now we get the file abcd. x in xvf indicates the extraction process.
Archiving and Compression Together
tar cvfz a.tar.gz abcd
Extraction in Single Step
tar xvfz a.tar.gz