How To Create A Tar Archive

Table of contents:

How To Create A Tar Archive
How To Create A Tar Archive

Video: How To Create A Tar Archive

Video: How To Create A Tar Archive
Video: How to create .tar , .tar.gz files and extract them in Ubuntu Step By Step Tutorials 2024, December
Anonim

TAR archives are very often used in the Linux operating system. On some distributions, this is the same format used by package managers. But sometimes such an archive does not need to be unpacked, but created.

How to create a tar archive
How to create a tar archive

Instructions

Step 1

The first way to create a TAR archive is as follows. Find in the file system of your computer any archive of the same format (with the extension. TAR. GZ). Copy it (just copy it, not move it!) To a folder convenient for you. Then go to it using the Midnight Commander file manager as in a regular folder. Remove all content from it, except for any one file (if you make the archive empty, an error will be generated). Then copy the files you need into it. After that, delete the last file from the old contents of the archive. Finally, after exiting the archive, as from a folder, rename it as you like using the tools of the same Midnight Commander program. In this case, do not change the extension.

Step 2

The second way to create a TAR archive is to enter the required commands manually from the keyboard in the console. To do this, first create a new folder with the desired name. Copy the files that you want to archive into it. Then, from outside this folder, that is, one level up, enter the following command:

tar -cvf archive.tar / path / to / the / folder, where archive.tar is the name of the archive, / path / to / the / folder is the full path to the folder with the files. The archive will be created in a folder one level higher.

Step 3

If ordinary archivers compress them simultaneously with placing files in the archive, then here data compression must be done separately. To do this, issue a command like this:

gzip archive.tar

As a result, the file with the archive will be compressed, and a second extension, GZ, will be added to its name.

Step 4

If desired, replace the double extension. TAR. GZ for such a file with a single one - TGZ, which will allow, for example, to store it on machines running DOS, where double file extensions are not known to be supported.

Step 5

To extract the necessary files from the archive, simply enter it with the above-mentioned Midnight Commander program as in an ordinary folder, and then perform the desired operations with the files as if they were located not in the archive, but in the folder.

Recommended: