Navigation Bar

UNIX Commands

This is not meant to be an exhaustive list of UNIX commands, there's plenty of sites out there that will give you them. Rather, it's a list of some of the commands that I find useful when working with UNIX Storage. Most of these commands will work with Linux too.

The UNIX interface

First, what should be some basic ideas about how to interface with UNIX. Be aware that some Utility commands are shell dependent. These ones should work for the ksh shell. Every user has their own environment that contains variables that control your session, such as home directory, shell and paths to commands. Use the command 'env' to see what variables are set for your session.

  • To stop your session from timing out use 'TMOUT=0' - handy if you are working intermittently on a server.
  • To recall your last command use 'set -o vi', then use '<esc> k' to retrieve commands
  • To see the last 20 commands that you used, type 'history'.
  • Cut and paste depends on your emulator. Some have standard cut and paste buttons on a toolbar. Some require that you hlight the text you want to copy with the left cursor button, then click with the mousewheel to paste. This seemed very strange to me at first but it's second nature now.

To make temporary changes to your environment use the set command as above 'set -o vi' or 'set history=50' (this increases your history record from the 20 default).

To make permanent changes you need to update the .profile dataset in your home directory. You can see this file if you use the ls -al command.

The vi Editor

This leads to Unix editing. The vi editor is pretty much universal and is powerful once you learn to use it. Some less well known command mode tips are: -

  • ':set number' or ':set nu' turns line numbers on. ':set nonu' turns it off again.
  • to find a string in vi, use '/string', for example '/server' or use '?string' to search backward
  • change the case of a character using the '~' key
  • to sort a file in vi, use ':1,$!sort'
  • ':set autoindent' makes program type files more readable
  • '<<' and '>>' will indent lines a set number of spaces. '4>>' will indent the next 4 lines
  • to insert some text in front of a block of 3 lines use
    3!!awk '{print "chmod 666$",$0}'
    put your cursor in front of the first line you want to change, and in this case, chmod 666 will be inserted before the text on all 3 lines.

Networking

One of the challenges with TSM backups is network connectivity. These network commands are worth trying to track down a problem, before you go and find someone who knows what they are doing.

  • To resolve a hostname or ip address type 'host ip' or 'host hostname', for example
      /home/stmanl:(no_env):/users/cn082337 $ host 10.125.228.207                             
      s12365dev328-csm is 10.125.228.207,  Aliases:   s12365dev328-csm.test.lascon.co.uk, dev328    
      /home/stmanl:(no_env):/users/cn082337 $ host dev328                                     
      s12365dev328-csm is 10.125.228.207,  Aliases:   s12365dev328-csm.test.lascon.co.uk, dev328  
      
  • To display the current hostname type 'hostname'
  • To list all available/defined network interfaces type 'lsdev -Cc if'
  • To display the network card settings for an individual device type 'ifconfig device name'
  • To display interface statistics type 'netstat -i'
  • To display ethernet statistics type 'netstat -d adapterid eg 'netstat -d en0'
  • To display all the hops from a client to a TSM server, say type 'traceroute name or ipaddress or server

UNIX configuration

  • To list all installed devices use 'lscfg'
  • To list details of all installed devices use 'lscfg -v'
  • To list detail of a single device use 'lscfg -vl device name
  • To find out the amount of useable memory use 'lsattr -El sys0 -a realmem' for example
     
      /home/stmanl:(no_env):/users/cn082337 $ lsattr -El sys0 -a realmem    
      realmem 8388608 Amount of usable physical memory in Kbytes
      

UNIX File System commands

The lspv command with various flags will list physical volumes and various attributes, not all of which are relevant in these days of RAID arrays and virtualisation. Try man lspv for an explanation.

The lsvg command for Volume Groups is relevant for HACMP configurations where you need to know the filespaces that are assigned to to floating HACMP volume groups.

  • a simple 'lsvg' will list all volume groups
  • 'lsvg -o' lists all online volume groups
     /home/stmanl$ lsvg -o
     sh_vg133_201
     lo_vgbas_202
     rootvg
    
  • 'lsvg -l' volume group lists file systems associated with an individual volume group
    /home/stmanl$ lsvg -l sh_vg133_201
    sh_bas133vg_201:
    LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
    p2bvg133tivol       jfs2       4       8       2    open/syncd    /usr/rg_p2_vg133/tivoli
    backups_lv          jfs2       395     790     2    open/syncd    /shared/backups
    repos_lv            jfs2       80      160     2    open/syncd    /shared/repositories
    adm_lv              jfs2       40      80      2    open/syncd    /shared/team/admin
    bicclv              jfs2       40      80      2    open/syncd    /shared/team/cbt
    
    The mount point gives you the file system, and the LV or Logical Volume name lets you interrogate logical volumes. for example 'ls -l lvname' will relate a logical volume to its underlying physical volumes.
     /home/stmanl$ lslv -l backups_lv
     backups_lv:/local/backups
     PV                COPIES        IN BAND       DISTRIBUTION  
     hdisk2            395:000:000   19%           080:076:079:080:080 
     hdisk4            395:000:000   19%           080:076:079:080:080 
    
  • If you just want to list out all the file systems, use 'lsfs' or 'mount' to see the mounted file systems.

back to top


                           VENDOR Showcase

Copyright © Lascon Storage Ltd. 2000 to present date. By entering and using this site, you accept the conditions and limitations of use