 Joined: Jan 2007 Posts: 84
Freelance Graphic Designer
 
 Israel
|
Jan 09, 2008, 11:56:52 PM | #1 |
To construct a ``tarball'' that contains copies of all the files in a particular directory subtree:
1. Use the cd command to change your current working directory to the parent directory of the root directory of the subtree you want to archive. For example, if you want to build a tarball of a directory whose pathname is /u/gertrude/rain/pics/, you would use this command:
cd /u/gertrude/rain
2. Pick a name for the tarball that ends in .tgz. In the example, we might call the tarball rainpics.tgz. 3. Build the tarball with this command:
tar -cvzf name.tgz subdir
where subdir is the name of the subdirectory you want to save. To continue the example, this command would be:
tar -cvzf rainpics.tgz pics
The -c option tells tar to create an archive. The v option tells it to write out the names of the files on your screen as it saves them, so you can be sure it is including everything you want. The z option specifies that the file should be compressed, to save space. The f option instructs tar to use the next name (in the example, rainpics.tgz) for the tarball it is building.
The last argument is the name of the directory subtree to be saved. You could use an absolute path name here, but it is not recommended, because you may be moving the tarball to a system that has different directories. That's why we recommend you use a relative path name here.
Once your tarball file is completed, you can move or copy it elsewhere on the system, or to a different system altogether. |
|