These pages are deprecated (latest changes date from end 2001). More recent information may be found at http://www.coresequence.com/training.php. I leave the old pages here as they are because lots of people are still visiting them (eventhough they aren't spell-checked), and because the basics are still useful.
Although Unix is one of the safest operating systems in existence and even if it is designed to keep on going, data can always get lost. Mostly because of users not paying attention, and occasionally because the systems faults, e.g. in case of an electricity breakdown. So it's always a good idea to keep an extra copy of sensitive and/or important data.
In some cases, you will want to compress your data so that they don't take up more space than usual. In Unix, this is commonly done with the tar command. tar was originally designed to archive tapes, but it can also make a "tarball", a file containing other compressed files.
tar has many options, we cite the most important ones below:
t: test, shows content of a tarball
x: extract archive
c: create archive
-f archivedevice: use archivedevice as source/destination for the tarball, the device defaults to the first tape device (usually /dev/rmt/0 or something similar)
Refer to the tar manpage for more information.
Note: The archives made with a proprietary tar version on one system, may be incompatible with tar on another proprietary system. This may cause much headaches, e.g. when the archive needs to be recovered on a system that doesn't exist anymore. Use the GNU tar version on all systems to prevent your system admin from bursting into tears. Enter tar --help to find out which version you are using. Contact your system admin if you don't see the word GNU somewhere.
In the example below, an archive is created and unpacked.
tille:~>ls images/ me+tux.jpg nimf.jpg tille:~>tar cvf images-in-a-dir.tar images/ images/ images/nimf.jpg images/me+tux.jpg tille:~>cd images tille:~/images>tar cvf images-without-a-dir.tar *.jpg me+tux.jpg nimf.jpg tille:~/images>cd tille:~>ls */*.tar images/images-without-a-dir.tar tille:~>ls *.tar images-in-a-dir.tar tille:~>tar xvf images-in-a-dir.tar images/ images/nimf.jpg images/me+tux.jpg tille:~>tar tvf images/images-without-dir.tar -rw-r--r-- tille/tille 42888 1999-06-30 20:52:25 me+tux.jpg -rw-r--r-- tille/tille 7578 2000-01-26 12:58:46 nimf.jpg tille:~>tar xvf images/images-without-a-dir.tar me+tux.jpg nimf.jpg tille:~>ls *.jpg me+tux.jpg nimf.jpg
When a tape drive is connected to your machine and configured by your system administrator, the filenames ending in .tar are replaced with the tape device name, e.g.
tar cvf /dev/tape mail/
The directory mail and all the files it contains are compressed into a file that is written on the tape immediately. A content listing is displayed because we used the verbose option.
Data, including tarballs, can be compressed using zip tools. The gzip will add the suffix .gz to the filename and remove the original file.
tille:~>ls -la | grep tar -rw-rw-r-- 1 tille tille 61440 Jun 6 14:08 images-without-dir.tar tille:~>gzip images-without-dir.tar tille:~>ls -la images-without-dir.tar.gz -rw-rw-r-- 1 tille tille 50562 Jun 6 14:08 images-without-dir.tar.gz
Uncompress gzipped files with the -d option.
bzip works in a similar way, but uses an improved compression algorithm, thus creating smaller files.
Unix software packages are often distributed in a gzipped tarball. The sensible thing to do after unpacking that kind of archives is find the README and read it.
On some systems, the tar command is aware of gzipped files. Use the
tar zxvf file.tar.gz
for unzipping and untarring .tar.gz files.
Note that neither gzip nor bzip2 may be available on your system (if you are working on an older or not so well maintained system). Use compress and uncompress in that case. These commands work rather straight forward, see the manpages when in doubt.
Saving copies of your data on another host is an accurate way of making backups. See next chapter 11: Communications.