Chapter VIII of the user data archive
Translation: hfzheng
hfzheng@sohu.com
Please keep this information reproduced
Archive command overview
In order to file and directory security, they need to archive a copy to removable media such as tape. You also need to archive the tapes to recover lost, deleted, or have been destroyed documents.
System which can use the command can easily store, locate and restore or archive tape device file. Available commands are:
tar: create a file to a tape device or the archive file, a tape device or solution files in the archive
compress and uncompress: a file compression and decompression
zcat: view a compressed file
gzcat: Extract the files at the same time view the file. Under the command line unzip files, and to extract data displayed on the screen.
Zip and unzip: compress and decompress files
Gzip and gunzip: compress and decompress files
Jar: compression packing multiple files into one archive
Cpio: from the archive file or tape device in a paper copy of reconciliation
Note: When the archive, we should use relative paths
Tar archive file using the command
tar command tar file from a file called archive files, or solved. A tar file is typically a tape device, but not limited to this, can any files.
Command format
tar functions archive_name / tape_device filenames
functions
The following is tar used a detailed list of functions:
Function defined
c Create a new tar file
t list the contents of tar file
x from the tar file in the Solution of a specified file
f specify archive or tape device name, the default tape device is / dev/rmt/0
v details of the contents of tar file
Create the tape device, view, restore a directory ribbon device
User1 directory to create a tape archive, use the default tape device, perform the following command:
$ / Export / home
$ Tar cv user1
View copy to tape the contents of the directory, execute the following command:
$ Tar t
If the user1 directory is accidentally deleted or damaged, you can execute the following command from the tape archive solution out to restore the contents of the directory are the directory:
$ Cd / export / home
$ Tar xv user1
Normally, system administrators usually at night on the home directory for archiving, but in normal times, but you also archive the contents of your home directory, so that if a file is deleted accidentally, you can quickly resume.
Create the archive file, in the view from the archive and restore files
tar command can also create an archive disk, you can share the files with other users, or add the file as an e-mail message.
$ Cd
$ Tar cvf files.tar file1 file2 file3
The above example, the file file1, file2 and file3 saved to a file called files.tar. Need to view the contents of the file, execute the following command:
$ Tar tf files.tar
The following example shows how to solve for the archive file to the current directory:
$ Tar xvf files.tar
Compressed files using the compress command
compress command is used to compress files to reduce the file size. And is very useful when dealing with large files, you can save hard disk space, when transmitted through the network transmission time can be reduced.
Compression ratio can be different according to the different file types, for a text document, usually 60-80% compression. When a file is compressed, the file will be a band. Z file extension instead of, attention, file owner and modification time is not changed, although the contents of the file has been completely changed.
Command format
compress filename
Compress a file
The following example is used to compress a file named files.tar:
$ Compress-v files.tar
The newly created zip file, will be used to replace the original file files.tar.Z file. With extension naming tradition is to remind the user that the file has been compressed. In the absence of extract can view and print before.
Note: Compressed files an already compressed file will become larger.
Extract the files using the uncompress command
uncompress command is used to restore a compressed file to its original state.
Command format
uncompress-c filename
The following example is used to extract a file named files.tar.Z:
$ Uncompress files.tar.Z
View the contents of a compressed file
Use with-c parameter uncompress command can display the contents of a compressed file to the screen, rather than extract. Z files.
$ Uncompress-c files.tar.Z | more
View files using the zcat command
zcat command can also view a file created by the compress command, zcat command translation compressed data, and to compress content of the document between the display on the screen, in the run zcat command, the contents of compressed files is not changed, still compressed stored on the hard disk.
Command format
zcayt-c filename
View the contents of a compressed file
To view the contents of a compressed file, execute the following command:
$ Zcat file.tar.Z | tar xvf -
Compressed files using the jar command
jar command and the tar command is similar, but the same steps in the compressed file, the command can copy and compress multiple files into one archive file, Zip application can read the jar file.
Note: the first is for the java programmers to use, to download multiple files at once, not each separate file in the next, jar command is the standard Solaris operating environment commands, in any other installed java virtual machine system can be used.
Command format
jar format and command syntax is almost the same tar command:
jar options output_file filenames / directorys
options:
jar command options:
Options defined
M does not create list
C to create a new jar file
Jar files are listed in the contents of T
X solved from the jar file, the file specified
F specify the jar file
V show details of implementation
Other tools
A more efficient compression tool is the zip and gzip, they can create a higher compression ratio of compressed file.
Use the zip command
zip and jar commands similar to the command are used to compress the file name, the difference is that zip is a unix tool, jar is a java application tools.
When using the zip command compressed file, the file name with extension. Zip.
Note: You can type in the command line zip and unzip to list all the options for each command.
Command format:
zip filename filename
For example:
$ Zip filename1 filename2 filename3 filename4
Using the gzip command
When using the command gzip compressed file, the file name with extension. Gz.
Command format:
gzip filename filename filename
For example:
$ Gzip filename1 filename2 filename3 filename4
Restoration of a gzip file
Gzip command to restore a compressed file, use the gunzip command:
$ Gunzip filename.gz
Use the cpio command
cpio command to archive files to tape or archive, or from the tape and archive solutions of the file.
Cpio command of advantages:
1, the compressed data to tape, and effective than the tar
2, the recovery file to skip out bad tape
3, can be written in different header file format to facilitate migration between the different systems
4, you can create multi-volume tape
5, you can archive and does not change the file access time
Command format
cpio options filenames
options:
Listed below can be used in the cpio command options:
Command definitions
o Create a file for the archive, copy the path name to the list of files or tape devices
I tape from the archive file or files solved
C in ASCII mode to read header information to be used for transplantation
T lists the contents of the file
V ls-l command to use and the format is similar to print out the file name list
M message to the media when the media and the needs of the end of the work has been completed, send a message
P reads the tape device or file to get the path name
A re-set when the copied file access time
I filename from the file filename as input file to read the content
O filename send the output of the cpio command file filename
Note: The cpio command line, you must specify o, I, p one of them.
Create the file file
The following example shows the combination of find and cpio commands to the current contents of the directory to create a file and copy it to the dir.list file.
$ Find. | Cpio-o dir.list
But the combination you find and cpio commands to those in the last week, is modified to create an archive file and copy it to the modify.list file.
$ Find.-Mtime -7 | cpio-ocv modify.list
The following example shows how to create a list archive for more than just the contents of the document:
$ Cpio-ivt-I dir.list
$ Cpio-ivt-I modify.list
Copy a directory of all files to tape
The following example describes how to use the cpio command copies files and directories to tape
$ Cd / export/home/usr1
$ Ls | cpio-oc-O / dev/rmt/0
List the contents of a tape, perform the following command:
$ Cpio-civt-I / dev/rmt/0
Table lists the contents of each file tape contains information on the eight parts, the first part of the octal mode with given access to the second part of the owner of the document is given, the third part of the given file number of bytes, the fourth, fifth, sixth part of the given file was last modified month, date, time. Last part gives the name of the file.
Restore files from tape
Need to recover files from the tape, first you have to put the location into the file and then execute the following command:
$ Cpio-icv-I / dev/rmt/0
Volume Management features
In order to store and restore the files in the floppy or CDROM, Solaris operating environment provides volume management features.
Volume Management for ordinary users to handle data in the floppy and CDROM provides a standard method. Using volume management features, you can automatically access your floppy and CDROM.
Note: If the volume management system does not start, only the super user can access the floppy and CDROM.
Volume management services from a daemon called named vold. Super users can start or stop any system in the process, by default, always start volume management services, so for the average user, can automatically manage access to the floppy and CDROM.
Detection of removable media devices
When we insert the floppy disk drive, floppy disk or CD to the CDROM in place, the volume manager need to test new equipment in order to provide access to the equipment.
CDROM Volume Management automatically detected, but the floppy disk, the Volume Manager does not automatically detect the new disk into the need to insert the disk every time you notice the volume manager.
Note: Automatic detection of extra disk read operations, this will soon wear damage to the floppy disk drive.
Volume Manager informed that you have inserted a new disk using the volcheck command.
Command format
volcheck options device_pathname
For example, to notify the Volume Manager to check your floppy drive inserted in the new media, execute the following command:
$ Volcheck-v / dev / disk
volcheck order feedback of the following messages:
1, if the disk into the drive, volcheck command displays the message: / dev / disk has media
2, if there is no disk drive, volcheck command displays the message: / dev / disk has no media
Access to removable media devices
The next section describes how to access removable media devices
CDROM and volume management
When the Volume Manager automatically detects the CDROM in CD exist, automatically place the CDROM directory tree called / cdrom standard directory.
You can use the cd command to enter to the directory, you can immediately access all the files in CD-ROM.
Access to local CDROM drive in the file:
1, in the drive into the CD-ROM (labeled side up), Volume Manager automatically put it on the directory / cdrom under;
2, in a terminal window, type the command cd / cdrom/cdrom0 and press Enter;
3, type the ls command and press Enter, the display / cdrom/cdrom0 all files.
NOTE: If you are running CDE File Manager, it will pop up a new File Manager window to display the contents of CDROM, you can window mode or the command line to access the data.
Floppy disk and volume management
Volume Manager does not automatically detect whether the floppy drive into a disk, you must use volcheck command to notify the Volume Manager to test drive. If the disk exists, the volume manager will put the disk in a directory tree called / floppy standard directory. You can use the cd command to enter to the directory, you can immediately access all the files on disk.
Access disk files:
1, placed in the drive has been formatted disk (labeled side up);
2, type volcheck and press Enter, the volume manager will put the disk directory / floppy under;
3, type cd / floppy and press Enter;
4, type ls carriage return, will show the disk name;
5, type cd disk_name carriage return;
6, type ls Enter to show all files on the disk name, you can use the cp command to copy the files on the disk.
Notes:
1, if there is no disk in the drive, volcheck will display an error message.
2, from the command line you can access files on the disk, or from the File Manager window File menu, choose Open Disk to access files on the disk.
Pop-up removable media devices
Once the completed CDROM and disk operations, you can use the eject command to remove the CD-ROM and floppy disk.
Pop CDROM
Eject the disc from the drive:
1, the CDROM File Manager window, click File, and select eject (eject) option;
Or:
1, close the CDROM File Manager window;
2, type the command exit cd / cdrom directory;
3, type eject cdrom Enter a few seconds later, CD-ROM drive will pop up.
Pop-up floppy disk
To eject a floppy disk:
1, in the Disk File Manager window, click File, and select eject (eject) option;
Or:
1, close the Disk File Manager window;
2, type the cd command exit / floppy directory;
3, type eject floppy Enter a few seconds, the disk from the drive or display a pop-up window, telling you can manually eject the disk.
Device busy information:
If the CDROM or disk does not eject from the drive and display a "device busy" message, you may still work CDROM or disk directory.
When you are in CDROm or working directory when the disk can not eject CDROM and disk.
To see you is in / cdrom and / floppy directory, you can use the pwd command, if you are in the directory, use the cd command to exit the directory.
Recommended links:
On FreeBSD5.2 common OPERATIONS (setting) changesZack Rusin INTERVIEWED the beauty and magic of KDENovell and Red Hat open source Giants collisionDomain Name Will Be The First Time Chinese And Other Non-Latin Alphabet And Opening Support 11 LanguHP's new CEO denied that HP will not sell PC sector glory is overHow to troubleshoot an hp laptopCasino And Gambling ShopOGM TO MKVMJPEG to AVISource EDITORS comparisonMTS to MOVBeautiful Call, XP Mac OS Perfect CloneAuto Auto Parts Order Will Be The First Commercial Capital Of China Held In ShiyanSimple Network Monitoring