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

    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.
  • If you just want to list out all the file systems, use 'lsfs' or 'mount' to see the mounted file systems. 'lsfs' does not work on Linux, but 'mount' does work.

Checking installed versions of software

The Linux command for this is not the same as Unix, to check installed tivoli software on AIX use

lsppp l- *tivoli*

and on Linux (RHEL) use

rpm -qa | grep tivoli

Using VMSTAT and IOSTAT to check for disk problems

The VMSTAT command can be used to check for disk bottlenecks by looking at the block I/O. A command with typical parameters would be

vmstat -ItW 10

The -ItW means show an IO view, add a timestamp on the end of each time and display the count of waiting threads. The '10' means run the command every 10 seconds. The commands has loads of other parameters as well as these three. Typical output looks like this.

The first 4 columns are the most interesting;
'r' is the runber of 'runnable' kernel threads, including active and waiting
'b' is the number of threads that are blocked waiting for IO on filesystems
'p' is the number of threads waiting for IO on raw logical volumes
'w' is the number of threads waiting for IO operations

You want to see Values of 0 in the 'b' 'p' and 'w' columns. If you see values greater than 0, this indicates the I/O threads that are blocked but don't worry about occasional high values, this is only an issue if the values are consistently high.

IOSTAT output can be used to check for Disk performance bottlenecks, suitable commands for AIX and Linux respectively are

iostat -DlT 10
iostat -xtk sinterval iterations

This command will return loads of data for every online disk, split into 4 sections; xfers, read, write and queue.
The qfull column in the queue section indicates how many times an i/o request was blocked because the OS queue for the disk was full. Consistently high numbers are bad and is an indication that there isn’t enough parallelism at the OS layer, or it might be an indication that queue depth is incorrectly set. Most IBM disk subsystems have a default queue depth of 32, the XIV can be set at 64, but non IBM disk subsystems have a default value of 1. For parallelism it can be better to have 10 100GB LUNS rather than 1 1TB LUN.
The tps column under xfers tells you hom many IOs per second (IOPS) are going to each disk, and typical Fibre Channel or SAS IOPS should be about 150, SATA about 90 IOPS, but SSDs should be in the thousands.
The read and write columns are service times, and TSM likes service values less than 5ms for log and DB reads or writes.