Unix Commands Part 7
Compress command.
Compress command compresses a file and returns the original file with .z extension, to uncompress this filename.Z file use uncompress filename command. syntax for compress command is
compress options files
- Options
- -bn limit the number of bits in coding to n.
- -c write to standard output (do not change files).
- -f compress conditionally, do not prompt before overwriting files.
- -v Print the resulting percentage of reduction for files.
Uncompress command.
Uncompress file uncompresses a file and return it to its original form.
syntax is
uncompress filename.Z this uncompresses the compressed file to its original name.
- Options
- -c write to standard output without changing files
Cpio command.
cpio command is useful to backup the file systems. It copy file archives in from or out to tape or disk, or to another location on the local machine. Its syntax is
cpio flags [options]
- It has three flags, -i, -o, -p
- cpio -i [options] [patterns]
- cpio -i copy in files who names match selected patterns.
- If no pattern is used all files are copied in.
- It is used to write to a tape.
- cpio -o
- Copy out a list of files whose name are given on standard output.
- cpio -p
- copy files to another directory on the same system.
- Options
- -a reset access times of input files.
- -A append files to an archive (must use with -o).
- -b swap bytes and half-words. Words are 4 bytes.
- -B block input or output using 5120 bytes per record.
- -c Read or write header information as Ascii character.
- -d create directories as needed.
- -l link files instead of copying.
- -o file direct output to a file.
- -r rename files interactively.
- -R ID reassign file ownership and group information to the user's login ID.
- -V print a dot for each file read or written.
- -s swap bytes.
- -S swap half bytes.
- -v print a list of filenames.
- Examples
- find . -name "*.old" -print | cpio -ocvB > /dev/rst8 will backup all *.old files to a tape in /dev/rst8
- cpio -icdv "save"" < /dev/rst8 will restore all files whose name contain "save"
- find . -depth -print | cpio -padm /mydir will move a directory tree.
Dump command is useful to backup the file systems.
dump command copies all the files in filesystem that have been changed after a certain date. It is good for incremental backups. This information about date is derived from /var/adm/dumpdates and /etc/fstab .
syntax for HP-UX dump is
/usr/sbin/dump [option [argument ...] filesystem]
- Options
- 0-9 This number is dump level. 0 option causes entire filesystem to be dumped.
- b blocking factor taken into argument.
- d density of tape default value is 1600.
- f place the dump on next argument file instead of tape.
- This example causes the entire file system (/mnt) to be dumped on /dev/rmt/c0t0d0BEST and specifies that the density of the tape is 6250 BPI.
- /usr/sbin/dump 0df 6250 /dev/rmt/c0t0d0BEST /mnt
- for more info type man dump at command line.
Pack command.
pack command compacts each file and combine them together into a filename.z file. The original file is replaced. Pcat and unpack will restore packed files to their original form.
Syntax is
Pack options files
- Options
- - Print number of times each byte is used, relative frequency and byte code.
- -f Force the pack even when disk space isn't saved.
- To display Packed files in a file use pcat command
pcat filename.z - To unpack a packed file use unpack command as unpack filename.z .
Tar command.
tar command creates an archive of files into a single file.
Tar copies and restore files to a tape or any storage media. Synopsis of tar is
tar [options] [file]
Examples:
tar cvf /dev/rmt/0 /bin /usr/bin creates an archive of /bin and /usr/bin, and store on the tape in /dev/rmt0.
tar tvf /dev/rmt0 will list the tape's content in a /dev/rmt0 drive.
tar cvf - 'find . -print' > backup.tar will creates an archive of current directory and store it in file backup.tar.
- Functions:
- c creates a new tape.
- r append files to a tape.
- t print the names of files if they are stored on the tape.
- x extract files from tape.
- Options:
- b n use blocking factor of n.
- l print error messages about links not found.
- L follow symbolic links.
- v print function letter (x for extraction or a for archive) and name of files.
Mt command
Mt command is used for tape and other device functions like rewinding, ejecting, etc. It give commands to tape device rather than tape itself. Mt command is BSD command and is seldom found in system V unix versions.
syntax is
mt [-t tapename] command [count]
- mt for HP-UX accept following commands
- eof write count EOF marks.
- fsf Forward space count files.
- fsr Forward space count records.
- bsf Backward space count files.
- bsr Backward space count records.
- rew Rewind tape.
- offl Rewind tape and go offline.
- eod Seek to end of data (DDS and QIC drives only).
- smk Write count setmarks (DDS drives only).
- fss Forward space count setmarks (DDS drives only).
- bss Backward space count setmarks (DDS drives only).
- Examples
- mt -t /dev/rmt/0mnb rew will rewind the tape in this device.
- mt -t /dev/rmt/0mnb offl will eject the tape in this device.
Comments