To tar and untar a file
Nov 13, †Ј A TAR file is a Consolidated Unix Archive format file. Open one with 7-Zip, B1 Online Archiver, and other file unzip tools. The article explains what TAR files are and how they're different from other archive formats, which programs can extract files from them, and how to . Jun 25, †Ј A TAR file is an archive created by tar, a Unix-based utility used to package files together for backup or distribution purposes. It contains multiple files stored in an uncompressed format along with metadata about the archive. TAR files are commonly compressed elvalladolid.com files with GNU Zip compression.
The GNU tar command included with Linux distributions has integrated compression. It can create a. Use the following command to compress an entire directory or a single file on Linux. While tar is frequently used to compress a single directory, you could also use it to compress multiple directories, multiple individual filesor both. Just provide a list of files or directories instead of a single one. In some cases, you may wish to compress an entire directory, but not include certain files and directories.
You can tae so by appending an --exclude switch for each directory or file you want to exclude. The --exclude switch is very powerful.
For example, you could archive an entire directory and exclude all. While gzip compression is most frequently used to wwhat. This allows you to create bzip2-compressed files, often named. To do so, just replace the -z for gzip in the commands here with a -j for bzip2. Gzip is faster, but it generally compresses a ie less, so you get a somewhat larger file. Bzip2 is slower, but it compresses a bit more, so you get a somewhat smaller file. Gzip is also more common, with some stripped-down Linux systems including gzip support by default, but not bzip2 support.
In general, though, gzip and bzip2 are practically the same thing and both will work similarly. Once you have an archive, you can extract it with the tar tile. The following command will extract the contents of archive. This specifies you want to e x tract an archive instead of create one. You may want to extract the contents of the archive to a specific directory.
You can aa. so by appending the -C switch to the end of the command. For example, the following command will extract the contents of the archive. This what is your favourite book the simplest possible usage of the tar command.
For more information. On Windows, you can extract and create. The Best Tech Newsletter Anywhere. Joinsubscribers and get a daily digest of news, comics, trivia, reviews, and more.
Windows Mac iPhone Android. Smarthome Office Security Linux. The Best Tech Newsletter Anywhere Joinsubscribers and get a daily digest of news, geek trivia, and our feature articles. How-To Geek is where you turn when you want experts to explain technology. Since we launched inour articles qhat been read more than 1 billion times. Want to know more?
Displaying the Contents of a tar file
Files that contain elvalladolid.com file extension are TAR archive files that have been created by the TAR file archiving utility. The TAR utility is a Unix-based utility that combines multiple files into a single archive file. The TAR file format makes the storage and distribution of a large volume of files more convenient and manageable. To Create a Tar file: tar -cv(z/j)f elvalladolid.com (or elvalladolid.com) c = create v = verbose f= file name of new tar file 2. To compress tar file: gzip elvalladolid.com (or) bzip2 elvalladolid.com (slower but more efficient compression) 3. To uncompress tar file. gunzip elvalladolid.com The tar command is useful for bundling up multiple files and/or directories. In a sense, itТs similar to the zip command. However, zip files are compressed by definition; tar files can be compressed, but donТt have to be. Creating a tar file.
Here, c Ч create an archive v Ч verbose just because f Ч filename the name of our tar file. The current directory will now contain a file called test.
To display the contents of the tar file, we could issue this command:. Here, t Ч table of contents list v Ч verbose display all info f Ч filename test.
Here, x Ч extract v Ч verbose f Ч filename test. You can also extract a specific file from the tar file instead of extracting the entire tar file. To extract only the file1 file from the archive, type the following command:. If you would also like to add compression to your tar files, you can combine the gzip utility with tar on the command line by adding the z switch to the command.
Usually when this is done, we change the suffix of our tar filename from. This will let whoever sees the file know that it is a gzipped tar file. Here, z Ч gzip compression c Ч create v Ч verbose f Ч filename test. The tar command knows about another compression algorithm called bzip2. For example,. If you would like to preserve the permissions of the files you backup, use the p option with the tar command. This will save the uid, gid as well as the specific permission attributes of the files read, write, execute etc.
While extracting the above tar file, you would have to use the p option again if you want to extract the files with the preserved file permissions. For example :. Note : Also worth mentioning is that by default tar is recursive. Meaning it will back up all files and subdirectories recursively unless you otherwise specify with the n flag non-recursive.
You May Also Like.