
Rather than extracting all contents of the tar file which is the default, we can specify a particular file to extract. Rather than first cd to the destination directory, we can use the -C option which will change to the directory specified when performing the extraction for us. Extract Tar File To Specific Directoryīy default tar will extract to the current working directory which may not always be what we want.

tar file, it will remain in place after extracting files from it. In this example, we show the contents of the original test2.txt file, wipe it clean, then extract the contents of archive.tar confirming that the contents of test2.txt have been returned from the copy in the archive. We can extract all contents of a tar file with the -x option. Note that we also need the -f option to specify the tar file to run against. We can list the contents within a tar file with the -t option. tar extension, however we use it here to allow us to easily see what the file is. The original files still exist after being added to the archive, they are not removed by default. 1 root root 10240 Sep 2 12:26 archive.tar ~]# tar -cf archive.tar test1.txt test2.txt The -c option is used to create a new archive file, while the -f option is used to specify the archive file to use (in this case, create). In its most simplest form, the tar command can be used to copy multiple files into a.
UNIX TAR COMPRESS HOW TO
The practical examples in this guide will show you how to use the tar command in all sorts of different situations. This makes it easy to perform backups and restores of files and directories in Unix/Linux based operating systems.

The GNU tape archive command, known as ‘tar’, is used to store many different files together into a single archive file.
