You may be sorry I did this, but here is someting from my notes.
PHP Code:
[b]
There are many ways you can do this, one of the most popular methods is to use the tar utility.
The name tar stands for Tape Archive, as this utility originally used to tape to archive backup files.
Tar is no longer confined to archiving to tape, and it is now used with floppy disks and files downloaded from the Internet.
There are a number of options you can use with tar.
In this example, you can see the syntax of the tar command using the "c" option, which creates a new archive.
tar c <filename>
The following funtions are available with the tar command:
c creates new archive
x extracts files from an archive
r adds files to the end of an archive
t lists the names of files in an archive
d compares the files in the archive to the files in the filesystem
u updates files that are newer than the files in the archive
The "t" option shown here, allows you to interrogate an archive.
tar t <filename>
And "x" extracts a file from as archive, using the syntax shown here.
tar x <filename>
There are other options that you can use with tar, such as "v", which prints verbose information on processed files.
tar v <filenames>
The "k" option prevents you from overwritine files contained in the tar file.
tar k <filenames>
This option identifies the name of the tar file to which files are to be stored and from which they are to be extracted.
f <filenames>
Say Brad Clemente has resigned, so you want to archive the directory /home/bradc, and back it up to tape.
You want to create a temporary archive in the location /var/tmp, and you want its tar filename to be brad.tar.
/var/tmp/brad.tar
To do this, you type:
tar cvf/var/tmp/brad.tar /home/bradc
Then press ENTER.
When you use the "v" option with the tar command, each file in the directory is listed as it is archived.
You can see what is contained in the brad.tar tar file by typing
tar tvf /var/tmp/brad.tar.
This command lists the contents of the archive.
[root@amber /root]# tar tvf /var/tmp/brad.tar
Say you receive a tape with the tar file reports.tar on it.
You want to extract this file, so first you copy the file from the tape to any directory - in this case the /oldarch directory.
By interrogating the file using the "t" function, you can see that this tarfile contains the contents of a directory called data.
tar t <options><filename>
To extract the reports.tar archive, you enter tar xvf reports.tar from the directory /oldarch, so that it is extracted to that location.
[root@amber /oldarch]# tar xvf reports.tar
Extracting the tarfile creates a subdirectory within the /oldarch directory.
The directory is data - the directory that is contained in the archive.
drwxr-xr-x 2 andread andread 1024 Sep 16 18:15 data
To access the contents of the extracted reports.tar file, you must change directories to data.
[root@amber /oldarch]# cd data
This directory is a subdiresctory of /oldarch, so the pathname for the extracted files is /oldarch/data/<filename>
If you want to extract reports.tar to a different directory, you change directory to where you want the file extracted and enter:
tar xvf/oldarch/reports.tar
This command allows you to extract specific files from an archive.
tar xvf <tarfile><files>
If you want to extract just the file march.txt from the archived tarfile brad.tar, you would enter:
tar xvf brad.tar home/bradc/march.txt
And you can then see, only the file march.txt is extracted from the archive.
The tar utility is easy to use, and very reliable.
You can read tar files from almost all Linux and UNIX systems.
Although tar is a popular archiving utility, it does have some disadvantages.
With certain versions the archive must reside on one volume, such as a single disk or tape.
This is a limitation, and in a sense it governs when you can and cannot use tar to carry out an archiving request.
And if you encounter a bad sector or block, your enter backup could be lost.
You can compress file using utilities such as "gzip".
The gzip compression utility is both fast and efficient, which makes it a very popular way to compress files.
The gzip utility takes a file, compresses it, saves the compressed version, and then removes the original file.
If gzip fails to compress the file correctly, it does not remove the original file.
Say you have a tar file, recruitment.tar, that you want to compress.
To compress this file using gzip, you enter the command:
gzip recruitment.tar
Then you can see that the compressed file recruitment.tar.gz is now only 200781 bytes, whereas it was 798720 bytes before being compressed.
The gzipped file is automatically given a .gz extension.
And the uncompressed version of the file is removed by gzip once the compression has been completed.
The gunzip utility allows you to unzip a gzipped file.
Say you want to unzip the file brad.tar.gz.
To do this, you enter:
gunzip brad.tar.gz
[/b]
* may have a few spelling errors.
