Category AIX Commands

VIO and HMC Levels

It is important to maintain proper levels of your VIO (Virtual I/O) servers and HMC (Hardware Management Console).  IBM is constantly providing fixes and updates, and it is integral that you keep a keen eye on these levels when implementing new technology or you are experiencing issues with new applications or practices.

 

VIO:

ioslevel –> VIO version

oem_platform_level –> AIX version of VIO server

 

HMC:

lshmc -V –> list the version of your HMC

Read More

Edit /etc/inittab

vi /etc/inittab = BAD IDEA

We all know that vi (or any other text editor) can easily edit a text file such as the inittab.  We also know that nobody is perfect, and that mistakes do happen (escape characters, wrong formatting etc.)  The problem is, when editing the inittab, if you make an error in the wrong place, you can render the system unbootable.  This is because the inittab is an important part of the boot sequence for an lpar, and once the boot sequence get mucked up, bad things start to happen.

This guide will go over the correct ways to edit the inittab without the risk of breaking the lpar altogether. (The only way to recover from some inittab errors are to network boot and fix from there…)

lsitab -a -> list contents of the inittab

lsitab identifier -> find specified identi...

Read More

AWK vs CUT

Well, not really.  But I assume I’ll get lots of attention with that name alone.  When I thought about writing this it was for one very specific thing only.

Often times in a script I’ll want to strip output based on a delimiter or columns.  I found myself constantly fighting with IFS and trying to make sense of delimiters that don’t follow a common pattern.  My two ways of extracting columns from a file/variable are as follows:

echo $variable | cut -f 2 -d “:” –> (-f to select column, -d to select delimiter)

echo $variable | awk ‘{ print $2 }’

Believe it or not, for someone that started off with no formal shell training or anything, this took me awhile to figure out.  Cut has its ups and downs but I will say this, awk is without a doubt worth learning.  In its entirety.

Anyways, th...

Read More

set -o vi

If you moved to AIX from Linux, like I did, the one thing you will miss with KSH is the command recall and auto-complete that BASH offered.  Well you needn’t worry because KSH has these capabilities, you just have to spend some time familiarising yourself with the new techniques.

This tutorial will be heavily related the the Vi Tutorial.  I suggest if you need more help or explanations with this, please visit that post for further explanation.

When using KSH, you can select the default history editor type.  To do this we use the “set -o” command.

$ set -o vi -> use vi as your command history editor

$ set -o emacs -> use emacs as your command history editor

$ set -o gmacs -> use gmacs as your command history editor

This will in turn allow you to use vi to edit the line that you are c...

Read More

Quotation Marks

In shell scripting, you may run into a constant battle with quotation marks.  Seems silly, but between the three types (double quotes-”, single quotes-’, backticks-`), I have run into numerous problems that perhaps I can save you from.
First off, when copying any scripts, commands or data from the internet, if you run into any problems with code that is said to be tested, check the quotation marks.  Often times browsers, web themes or even copying and pasting can result into a mish-mash of punctuation changes.

Secondly, when nesting quotes in a script or command, be sure you a) alternate quotation styles when nesting and b) ensure your order of end-quoting matches.

A quick overview of meta characters is below.

Remember, anything in double quotes may be read by the shell interpreter and ...

Read More

Korn Shell (KSH) Command | if Test Parameters

if/Test Statement

test -e file
[ -e file ]
[[ -e file ]]

x=2
test $x -eq 1
[ $x -eq 2 ]
[[ $x -eq 3 ]]

File Test Operators

File status can be examined using several operators.

Parameter:     Meaning
-s file     size greater than zero
-r file      exists and is readable
-w file      exists and is writable
-x file      exists and is executable
-u file      exists and has the SUID bit set
-g file       exists and has the SGID bit set
-k file      exists and has the SVTX sticky bit set
-e file       exists
-f file      exists and is an ordinary file
-d file      exists and is a directory
-c file      exists as a character special file
-b file      exists and is a named pipe file
-p file      exists and is a named pipe file
-L file    ...

Read More

Common FTP Commands

Here are some common commands that we all use to move files around using FTP

? -> to request help or information about the FTP commands
ascii -> to set the mode of file transfer to ASCII (this is the default and transmits seven bits per character)
binary -> to set the mode of file transfer to binary (the binary mode transmits all eight bits per byte and thus provides less chance of a transmission error and must be used to transmit files other than ASCII files)
bye -> to exit the FTP environment (same as quit)
cd -> to change directory on the remote machine
close -> to terminate a connection with another computer
close brubeck -> closes the current FTP connection with brubeck, but still leaves you within the FTP environment.
delete -> to delete (remove) a file in the current remote...

Read More

FTP Script | AIX to Windows Share

Often times you may want to create a script to copy, move or grab files from your AIX machine to a Windows (or other) box.  In some cases, there may a shared Windows drive created office wide and you would like to dump system information or reporting here.  If ssh is not supported on the other end, you will need to use FTP.

General FTP Commands

Here is a quick script to move files from your AIX box to your Windows share.

ftpmove(){

ftp -n <<-EOF
open fully_qualified_server_name
user username password
cd path/to/file
put file_to_copy_to_windows

get file_to_copy_to_aix

EOF
}

ftpmove

Read More

AIX Command | Exporting NFS: exportfs vs mknfsexp

Every once in awhile you will find a quaint little reminder that AIX is not UNIX.  I worked in a shop where we used third party software connecting our servers to the vendor’s servers through an NFS mount.  The unfortunate thing was that when we rebooted the server, for some unknown reason some of the exports were not persistent.  This created a whirlwind of problems, resulting in making customer service support tickets and waiting for the vendor to reissue their mount.
If you have been working with AIX for more than a couple days, you know that there are multiple ways to complete any one task.  You may also know that AIX still incorporates many UNIX commands, and also has (seemingly redundant) AIX proprietary commands.  This example is a great explanation of why this is.

One of the t...

Read More

AIX Command: lssyscfg — HMC command to view system configuration

Command:

“lssyscfg” will return system configuration information stored on the HMC.  This can be used to extract information on partitions, partition profiles, managed systems, system profiles.  This is a very useful tool for developing an understanding of a large environment that is managed by an HMC.

Usage:

lssyscfg -r sys -F “name” -> List all CEC’s on HMC
lssyscfg -r lpar -m [CEC] -F “name” -> List all LPARs on CEC
lssyscfg -r lpar -m [CEC] –filter “lpar_names=[lpar]” -> List information on specific LPAR

MAN Page:

NAME

lssyscfg – list system resources

SYNOPSIS

lssyscfg -r {lpar prof sys sysprof cage frame} [-m managed-system -e managed-frame] [--filter "filter-data"] [-F [attribute-names] [--header]] [--help]

DESCRIPTION

lssyscfg lists the attri...

Read More