How to Tar a File in UNIX
The common means with which to archive a batch of files within a UNIX system is by using the "tar" command. When you issue a tar command you can easily roll up a group of files. This eases the delivery of a group of files in per-session intensive applications such as the File Transfer Protocol and peer-to-peer applications. These steps describe how you can tar a file in UNIX using the command prompt.
Instructions
-
-
1
Open a terminal session on your UNIX PC. Otherwise, you can Telnet into the terminal from a remote machine.
-
2
Once in the terminal, type "tar -cf" and do not press "Enter." The "c" indicates that you are creating a tar file, and the "f" indicates that the tar is to be given the name you specify.
-
-
3
Press the spacebar and type in the full name (with extension) you want for the file. If you're tarballing a picture, for example, you might want to type "pictures.tar."
-
4
Press space and enter the path of the full path to the file. Remember that the path should be relative to the location you're issuing the command from. For example, if the full path of the directory is "hdd0\home\user\pictures\pic1.jpg" and you issued the command from the "user" directory, then you'd simply have to put "pictures\pic1.jpg" in the command.
-
5
Press "Enter." A new file with the name you specified should now be in that directory.
-
1
Tips & Warnings
A detailed explanation of all of the "tar" parameters can be obtained any time by typing "tar -help."
It is best to navigate yourself as close as possible to the directories where your target files are located. This way, you do not have to remember long paths. (e.g. "tar -cf usr\bin\thisfile.doc usr\bin\another.doc" versus "tar -cf thisfile.doc another.doc")
Remember that a tarball is not compressed! If you want compression, you'll have to utilize another program, such as gzip.
Running the same command with the same .tar filename, but different files, will erase the original tar. Use the "tar -uf [filename] [file]" function to update the tar file with modified or new additions.