Skip to main content

Unix Commands Part 7

Storage commands
compress uncompress, cpio,dump,pack, tar, mt.

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

Popular posts from this blog

INSTALL CISCO VPN CLIENT ON WINDOWS 10 (32 & 64 BIT). FIX REASON 442

This article shows how correctly install Cisco VPN Client (32 & 64 bit) on Windows 10 (32 & 64 bit) using simple steps, overcome the ‘ This app can’t run on this PC ’ installation error , plus fix the Reason 442: Failed to enable Virtual Adapter error message . The article applies to New Windows 10 installations or Upgrades from earlier Windows versions and all versions before or after Windows 10 build 1511 .  To simplify the article, we’ve broken it into the following two sections: How to Install Cisco VPN client on Windows 10 (clean installation or upgrade from previous Windows), including Windows 10 build prior or after build 1511 . How to Fix Reason 442: Failed to enable Virtual Adapter on Windows 10 Figure 1. The Cisco VPN Client Reason 442: Failed to enable Virtual Adapter error on Windows 10 HOW TO INSTALL CISCO VPN CLIENT ON WINDOWS 10 (NEW INSTALLATIONS OR O/S UPGRADES) The instructions below are for new or clean Windows 10 inst...

Linux File and Directory Permissions

file & directory protection is a essential of any OS and Linux OS is no exception for it! These authorizations allow you to choose exactly who can access your files & directory, providing an overall improved system security. There was one of the major flaws in the older Windows operating-system where, by standard, all users can see each other people's information (Windows 95, 98, Me). For overcoming it, editions of the Windows based computer system such as NT, 2000, XP and 2003 lot more security features added. They fully support file & directory permissions, just as Linux system has since the beginning. Together, we'll now assess a directory listing from our Lab Linux system hosting server, to help us understand the information provided. a simple 'ls' command will give you the file and directory listing within a given directory, including the option  '-l' will display number of new areas that we are going to discuss here:

How to create a Hirens Boot CD 15.2 USB Disk

Hiren’s BootCD (HBCD) is a bootable CD that contains a set of tools that can help users to fix their computer if their system fails to boot. More specifically, HBCD contains hardware diagnostic programs, partition tools, data recovery utilities, antivirus tools and many other tools to fix your computer problems.  I write this article because I use Hiren’s BootCD frequently to troubleshoot computer problems, specially when a computer doesn’t boot anymore due to a virus attack or due to a corrupted file system. In this article you will find instructions on how to put Hiren’s BootCD on a USB flash drive (stick) in order to troubleshoot computer problems in the future.