Tuesday, January 19, 2010

UNIX command - scp


Description
secure copy (remote file copy program).

scp copies files between hosts on a network using ssh for data transfer and authentication with the same security as ssh. Unlike rcp, scp will ask for passwords or passphrases if they are needed for authentication.
File
/usr/bin/scp
Syntax
scp [-pqrvBC46] [-F ssh_config] [-S program] [-P port]
    [-c cipher] [-i identity_file] [-o ssh_option]
    [ [user@]host1:]file1 []... [ [user@]host2:]file2

--host1, host2, ...: The name(s) of the host
--file1, file2, ...: The file(s) to be copied

Note: scp source dest
Options
-4: Forces scp to use IPv4 addresses only.

-6: Forces scp to use IPv6 addresses only.

-B: Selects batch mode (Prevents asking for passwords or
    passphrases.)

-c cipher: Selects the cipher to use for encrypting the data
           transfer. This option is directly passed to ssh.

-C: Compression enabled. Pass to ssh to enable compression.

-F ssh_config: Specifies an alternative per-user configuration
               file for ssh.

-i identity_file: Selects the file from which the identity
                  (private key) for RSA authentication is read.
                  This option is directly passed to ssh.

-o ssh_option: The given option is directly passed to ssh.

-p: Preserves modification times, access times, and modes from
    the original file.

-P port: Specifies the port to connect to on  the remote  host.

-q: Disables the progress meter.

-r: Recursively copies entire directories.

-S program: Specifies the name of the program to use for the 
            encrypted connection. The program must understand
            ssh options.

-v: Verbose mode. Causes scp and ssh to print debugging messages
about their progress. This is helpful in debugging connection,
authentication, and configuration problems.

Example
(SUN Solaris 10)
1. scp all files in the currently directory to directory /oraback/mydb/rman on another server dbserver2.com, log in to server dbserver2.com by using oracle

2. to copy a directory, use –r (recursive option)
    
$ scp -r mydir xyz@dbserver2.com:mydir
3. After setting up SSH for no password on UNIX database servers, scp will not ask for password.

Last updated: 2010-01-19 Tuesday

Monday, January 18, 2010

UNIX command - vmsat


Description
report virtual memory statistics regarding  kernel thread, virtual memory, disk, trap, and CPU activity.

Without options, vmstat displays a one-line summary  of  the virtual memory activity since the system was booted.
Syntax
vmstat [-cipqsS] [disks] [ interval [count]]

count: Specifies the number of times that the statistics are repeated. count does not apply to the -i and -s options.

disks: Specifies which disks are to be given priority in the output (only four disks fit on a line).

interval: Specifies the last number of seconds over which  vmstat  summarizes activity.
Options
-i: Report the number of interrupts per device. count and interval does not apply to the -i option.

-p: Report paging activity in details. This option will display the following, respectively:
              epi      Executable page-ins.
              epo      Executable page-outs.
              epf      Executable page-frees.
              api      Anonymous page-ins.
              apo      Anonymous page-outs.
              apf      Anonymous page-frees.
              fpi      File system page-ins.
              fpo      File system page-outs.
              fpf      File system page-frees.

-q: Suppress messages related to state changes.

-s: Display the total number of various system events since boot.  count and interval does not apply to the -s option.

-S: Report on swapping  rather  than  paging  activity. This  option  will  change  two  fields in vmstat's ``paging'' display:  rather  than  the  ``re''  and ``mf'' fields, vmstat will report ``si'' (swap-ins) and ``so'' (swap-outs).

Example
(SUN Solaris 10)
1. display a summary of what the  system is doing every five seconds.

$ vmstat 5 3
     kthr   memory          page             disk      faults        cpu
     r b w swap  free re mf pi p fr de sr s0 s1 s2 s3  in  sy  cs us sy id
     0 0 0 11456 4120 1  41 19 1  3  0  2  0  4  0  0  48 112 130  4 14 82
     0 0 1 10132 4280 0   4 44 0  0  0  0  0 23  0  0 211 230 144  3 35 62
     0 0 1 10132 4616 0   0 20 0  0  0  0  0 19  0  0 150 172 146  3 33 64

The fields of vmstat's display are:

kthr: Report the number of kernel threads in the following states:
      r - # of kernel threads in run queue
      b - # of blocked kernel threads waiting for I/O, paging, etc
      w - # of swapped out lightweight processes (LWPs) waiting for
          processing resources to finish. If w<>0, swapping is
          ccurring and your system is short of memory.

memory: Report on usage of virtual and real memory.
      Swap - available swap space (Kbytes)
      free - size of the free list (Kbytes)

page: Report information about page faults and paging activity. The information on each of the following activities is given in units per second.
      Re - page reclaims
      Mf - minor  faults
      pi - kilobytes paged in
      po - kilobytes paged out
      fr - kilobytes freed
      de - anticipated short-term memory shortfall (Kbytes)
      sr - pages scanned by clock algorithm

disk: Report the number of disk operations per second. There are slots for up to four disks, labelled with a single letter and number. 

Faults: Report the trap/interrupt rates (per second).
      in - interrupts
      sy - system calls
      cs - CPU context switches

cpu: Give a breakdown of percentage usage of CPU time. On MP systems, this is an average across all processors.
      us - user time
      sy - system time
      id - idle time

2. CPU stressed system

$ vmstat 5 5
 kthr      memory            page                     disk       faults         cpu
 r b w   swap      free  re  mf   pi  po fr de sr m1 m1 m1 m2 in   sy    cs   us sy id
 0 0 0  22636368 9168720 505 212 2535 9  9  0  0  3  2  2  0  966  11486 1936 25 4  71
 72 0 0 21789992 7491856 208 351 495  2  2  0  0  0  0  0  0  1051 24535 1434 95 5  0
 60 0 0 21782600 7483352 149 265 516  2  2  0  0  1  1  1  0  1341 25212 1612 95 5  0
 71 0 0 21790680 7489176 124 144 466  0  0  0  0  1  1  1  0  1110 24746 1388 96 4  0
 64 0 0 21791080 7501120 84  6   78   26 26 0  0  1  1  1  0  1028 25069 1256 96 4  0

3. IO stressed system

$ vmstat 5 2
 kthr      memory            page                      disk        faults          cpu
 r b w   swap     free  re   mf pi   po   fr  de sr m1 m1 m1 m2 in   sy   cs    us sy id
 0 0 0 19491928 5387584 363 128 2538 27   26  0  0  2  2  2  0  3359 5396 4758  1  1  98
 0 0 0 17307120 2090072 1    21 0    186  186 0  0  0  0  0  0  5935 4711 4807  3  1  96

Last updated: 2010-01-18 Monday