Using the tar command on Debian Linux.

Posted: May 1, 2012. At: 11:56 AM. This was 5 years ago. Post ID: 3639

The Linux shell offers many ways to compress files for backup. The tar or tape archive program will concantenate many files into one.

tar --create --verbose myfile.tar file1 file2 file3 file4

Then you may use either the gzip or bzip commands to compress the myfile.tar file you have created and shrink it ready for backup.

gzip myfile.tar

A simplified way to create a tar archive is with the shortened arguments to the tar command.

tar -cvf myfile.tar  file1 file2 file3 file4

Another way to create the tar file involves the redirection feature of the Linux shell.

tar -cv  file1 file2 file3 file4 > myfile.tar

Unpacking the tar.gz file is very easy, the tar command may be used to unpack the file that it created.

tar -xvf myfile.tar.gz

Unpacking a tar.bz2 file requires a slightly different command.

tar -jxvf myfile.tar.bz2

If a folder containing other files is contained within the myfile.tar file, then this folder will be created where the tarball is extracted, so make sure that you extract it in a relatively empty folder where it will not overwrite anything. The tarball for the Linux kernel source code is about 70 megabytes but it will take occupy significantly more disk space when it is unpacked. Therefore you must make sure that you have a lot of disk space on the partition you want to unpack the kernel source to. And when it is compiled, it can take up a massive amount of hard disk space to build the kernel image and the many *.o files after the compilation of the kernel source code. This is rather like those zip bomb files that contain many, many large text files compressed recursively inside a small zip file that is only 42 kilobytes in size and will unpack to occupy 4.5 Petabytes. Learn more here: This is very malicious indeed, Linux could crash if the filesystem ran out of space. I have ran out of space on /tmp before when I had left recordmydesktop running and it is not a good thing to have happen. I was still able to use Midnight Commander to find and delete the temporary files that it had created.

No comments have been made. Use this form to start the conversation :)

Leave a Reply