Stanford University School of Earth Science
 
Home
News
New Users
Policies
Network File Server
Web Server
Get Help
Net Connections
Your Macintosh
Your Windows PC
Your Unix/Linux System
Other School Resources
Using Unix
   Overview
   Documentation
   Accounts
   Using the Shell
   Using X-Windows
   File Manipulation
   Net Commands
   Editing Text
   Formatting Text
   Printing
   Filters & Utilities
   Programming

Use of relative or absolute directory pathnames in writing and reading

Last revision July 20, 2004

Additional topics:

 

If you write a tape with tar and use a relative pathname, then all filenames on the tape are relative to that pathname and can be restored to a different directory. Example:

cd ~username
tar cf /dev/rmt1h .

This example creates an archive of the entire "current" directory tree, which is username's home directory, to the tape device rmt1h. The tar program treats the current directory as the "root directory" and only saves the portion of the pathnames beyond that root in the archive. For example, if there is a file named ~username/example, it is saved on the tape archive file with the simple filename ./example. This means that you can restore the contents of this archive to a different disk directory.

If you use an absolute pathname (starting at root) in the tar command, then the entire absolute pathname of each matching file is written into the archive and you can only restore the files to the same directory from which they came. Example:

tar cf /dev/rmt1h /home/sysop/username

In this case, entire pathnames like /home/sysop/username/example are stored in the archive file on tape. When you try to restore this file, the entire directory path /home/sysop/username must already exist, with permission for you to write in it, or you must have permission to create all the directories needed for the path, starting at the root level. Generally, only the "root" account has such permissions. If you tried to restore from this archive with absolute pathnames onto a different computer system, it would probably fail unless you was using the root account.

 


Comments?

Stanford University    |