Skip to main content

14.5) "tar" Command


If you are going to transfer a lot of files to another person or to another of your computers then it is easiest if you use the tar command to gather together all the files and put them into one file called a tar file (the file name has to end with ‘.tar’). Then you can transfer the file and reverse the tar operation and it will reproduce all the files again in your directory.

tar –cvf name.tar file1 file2 file3

This command will gather up all three files (‘file1’, ‘file2’, and ‘file3’) and put them in a new file called ‘name.tar’ (you can change the name to whatever is a good name that you like to represent those files, but always end the name with a ‘.tar’).
Note that the tar command does not compress the files, it just gathers them up including the directory tree structure (below where you execute the command) and stores it all in a single file (e.g. name.tar as in the above command). You can then move the name.tar file anywhere you like (to a different computer if you like). When you extract the files from name.tar (you will see how in the coming pages) then the files and associated directories are extracted and appear in the directory that you run the extract command.
Note:
The -cvf indicates c for create a new tar file, v for verbose to print to the screen what is going into the tar file, and f for files.