![]() ![]() Type in the following to find the contents of your bzipped tarball: $ tar tvf name_of_2 Find the size of the tar file, gzipped tarball and bzipped tarball Just type in the following command: $ tar tvf name_of_ Listing the contents of a bzipped tarball You should have figured it out by now, but we’re going to show you how to do it anyway. Listing the contents of a gzipped tarball The “t” instructs Linux to display the files contained in the package file in a list form. Extracting a tar file is generally a slow process, depending on the size of a file, so you can use the following command a lot in Linux: $ tar tvf name_of_archive.tar Sometimes you may want to know what a tar file contains without extracting it. Just type in the following to separate a bzipped tarball into its component files: $ tar xvf name_of_2 -c dirname/ Listing the contents of a tar file Seperating a bzipped tarball into component files You can extract the files to a different directory or to the directory you currently are in. You can separate a gzipped tarball into its component files through the following syntax: $ tar xvf name_of_ -c dirname/Īgain, the –c dirname option is optional. Separating a gzipped tarball into component files The new “x” we’ve added instructs Linux to extract the tar file. The following command will extract the tar file to the directory you’ve currently navigated to: $ tar xvf package.tar You can specify the directory name if you want to extract the tar file to directory other than the current one. You don’t need to specify the directory name while separating a tar file into its component files. The syntax for this would be as follows: $ tar xvf name_of_archive.tar -c dirname/ You can separate tar files into its component files by using the “x” command. The syntax to create a bzipped file is: $ tar cvzf name_of_2 dirname/ Separating a tar file into component files gz file? The former is smaller, but it takes more system resources to create and is consequently slower to process. You can create a bzipped file instead of a gzipped file by changing your command just a little. To create a gzipped package.tgz file in your “home/john” directory, just type in the following command: $ tar cvzf home/john Creating a smaller tarball (bzipped) file The syntax to create a tarball is: $ tar cvzf name_of_ dirname/ You can create a compressed tar file just by including the letter “z” in “cvf”. What does the “cvf” we typed mean? The “c” tells Linux to create a new archive, “v” to verbosely display files that have been processed and “f” stands for the file name. The package.tar file will, in turn, be placed in the john directory. This will place all the files inside the home/john inside a new tar file called package.tar. For this, you would use the following command: $ tar cvf package.tar home/john Let’s say you wanted to create a tar file named package.tar for all the files inside your “home/john” directory. You create a tar file, use the following command: $ tar cvf name_of_archive.tar dirname/ You can create a tar file from files you have placed inside a directory location. ![]() Please note that this is not an exhaustive list, but a collection of the most basic tar commands you’ll need while working with tar files. Let’s take a look at some of the tar commands you can use in Linux. ![]() ![]() A compressed tar file is known as a tarball (.tgz file), which is a type of file you can create with the tar command. A tar file is often confused for a compressed file, but in reality it’s just a collection of uncompressed files. You can create tar files, store, separate, compress and decompress them. There are several variations of the tar command on Linux. The tar command stands for “tape archiving”, which means the storing of one or more files onto a magnetic tape. The Tar command in Linux (and UNIX) systems can be used for several purposes, the most common of which is to combine several files into a single file. If you’re new to Linux, we recommend you first try out this crash course. We assume a basic level of familiarity with Linux. In this tutorial we will walk you through the tar command usage. While this does give a much finer level of control to the Linux user, it can take a while to master the Linux command line. This means you have to explicitly type the commands out at a prompt, unlike the Windows drag and drop. Linux, unlike Windows, is mostly a command line based operating system. ![]()
0 Comments
Leave a Reply. |