Putting a Red Hat on AIX: Easing the Transition Between Linux and AIX

There is a growing need for system administrators, programmers, and engineers to be equally comfortable in multiple operating system environments.  At my current place of employment, I am expected to function equally well in the following environments:

  • AIX 6.1
  • AIX 7.1
  • Red Hat Enterprise Linux 6
  • Windows Server 2008 R2
  • Windows Server 2012 R2

AIX, fully adhering to the Single UNIX Specification, obviously shares much in common with Red Hat Enterprise Linux and other Linux distributions.  The most stressful gap to cross is between Windows and UNIX/Linux.  Microsoft is making the crossover easier and easier with their fantastic PowerShell (if you have to deal with Microsoft, and you will, you’d better learn PowerShell; it is, IMHO, the best thing Microsoft has ever done) which comes with a variety of built-in aliases to help *nix administrators deal with their reflexive shell typing (“man,” for example, is an alias of the “Get-Help” cmdlet, meaning PowerShell generally does what you want when you instinctively type “man <command>” in an attempt to get some information).

In this article, I thought I might offer some advice on how to configure your AIX environment to be more like a standard Red Hat Enterprise Linux environment.  There are a few reasons I consider it to be more reasonable to make AIX more like RHEL rather than the other way around:

  1. Most people are going to have their initial *nix experience with free and open source software such as Fedora or Ubuntu (though the former is recommended due to its similarities with the more-likely-to-be-seen-in-an-enterprise-environment RHEL and SUSE, being upstream to RHEL and sharing the rpm infrastructure with SUSE)
  2. While it wasn’t always this way, bash is now the ubiquitous standard shell.  The standard AIX ksh used to hold this position, but not anymore.
  3. Bash supports tab completion, whereas ksh does not.  This alone leads me to prefer bash over ksh.  To be fair, you could install zsh, which is an upgraded version of ksh that includes tab completion, but see (2) above.
  4. The GNU core utilities are vastly superior to the AIX core utilities.
  5. vim is superior to vi.

That’s my rationale.  A lot of this stuff is simple preference, so there’s no need to be dogmatic about it, but this appears to me the most prudent way forward.  What we want is a very RHEL-like AIX environment.  You’ll still have to learn about the critical differences between the systems (such as the unique-to-AIX facilities and subsystems like the Object Data Manager database and the System Resource Controller) but it’s much easier to handle those differences if the environment in which you will be writing scripts and interacting with the system is largely equivalent.

So the way forward is as follows:

  1. Install the necessary components on the AIX system.
  2. Change one’s login shell to bash.
  3. Configure one’s user profile to leverage the installed components and emulate a RHEL environment (to one’s liking).

The good news for those of you who are familiar with Fedora or Red Hat Enterprise Linux (or some rpm-based distribution) is that AIX actually supports rpm packages.  In fact, IBM has a website where they offer rpm packages holding all the content we’ll need to proceed (albeit very out-of-date in some cases).  For the sake of security, my instructions will describe the installation of the IBM-provided rpm packages, but I’ll provide a link to the website of a very nice gentleman who packages up the latest versions of open source utilities for AIX on a regular basis.  He’s probably trustworthy (that’s a call you and your team can make), but I will be endeavoring to learn to create rpm packages myself so that I can acquire the content from the publishers (the GNU core utilities, for example) and package it up myself, assuring the integrity of the package for my organization.

Note:  All versions of AIX succeeding AIX 5.1 should allow for the following instructions to function properly.

Installing bash on AIX

  1. Acquire the latest bash package from IBM’s website:  http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/date.html.  While bash 4.3 is the latest version, at the time of writing, the latest package offered by IBM is bash-4.2.  No big deal.
  2. Install the package with the command:
    rpm -ivh bash-4.2-1.aix6.1.ppc.rpm

Configuring bash for use on AIX

  1. Enable bash for use on the AIX system by modifying /etc/shells.  Simply add a line to /etc/shells as follows:
    /opt/freeware/bin/bash
  2. Change your login shell to bash by logging into the account which you intend to modify and executing:
    chsh /opt/freeware/bin/bash
  3. Log out and log back in.  Notice the -bash-4.2$ prompt!

Installing the GNU Core Utilities on AIX

  1. Acquire the latest GNU Core Utilities package from IBM’s website:  http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/date.html.   The latest version is called “coreutils-5.2.1.”  As you can see, it is quite old (the latest version of the GNU Core Utilities is 8.22) but it is functional.  This is the package I am most interested in acquiring and packaging for AIX, myself (see the note about Perzl later for a possible shortcut).
  2. Install the package with the command:
    rpm -ivh coreutils-5.2.1-2.aix5.1.ppc.rpm

Configuring the GNU Core Utilities for use on AIX

  1. Edit your .profile file in your home directory so that you PATH variable includes at its beginning the following locations:  /opt/freeware/bin:/opt/freeware/sbin.  The overall variable may look something like:  /opt/freeware/bin:/opt/freeware/sbin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/lpp/X11/bin:/sbin:/usr/dt/bin
  2. Optional:  Edit your .profile file so that aliases common to RHEL work as expected in AIX.  I primarily use
    alias ls="ls --color=auto"

    and

    alias ll="ls -l --color=auto"
  3. Reload your .profile in your current shell session by either logging out and back in or simply executing:
    . .profile

Installing vim on AIX

  1. Acquire the latest packages from IBM’s website:  http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/date.html.   You’ll need both vim-common-6.3 and vim-enhanced-6.3.  Again, these packages are quite old (the latest version of vim is 7.4 – again, see the Perzl information at the bottom for a potential shortcut to acquiring an AIX rpm package for the latest version).
  2. Install the common package:
    rpm -ivh vim-common-6.3-1.aix5.1.ppc.rpm
  3. Install the enhanced package:
    rpm -ivh vim-enhanced-6.3-1.aix5.1.ppc.rpm
  4. If you haven’t already followed the step above in adjusting your PATH variable for the GNU Core Utilities, open your .profile file in your home directory and add the directory /opt/freeware/bin to the PATH variable.

Configuring vim for use on AIX

To make the arrow keys functional for vim in AIX, you’ll need to create a file in your home directory called “.vimrc”.  The mere presence of this file implies the “nocompatible” option which allows the arrow keys to function properly in vim, but I explicitly set the option in the .vimrc file so that I remember why it’s there in the future should I inspect it (empty files are sometimes deleted during aggressive cleanup operations).  Just create the file and write in the first line:  “set nocompatible”.

Conclusion

And there you have it!  You now have a fully functional bash environment which is very similar to RHEL.  Ah, the colorful display of the GNU coreutils ls command, how I missed thee.  The human-readable (-h) option for the ls, df, du, etc… so nice, so nice.  The GNU Core Utilities blow the IBM versions out of the water, if you ask me.

Obtaining Better RPM Packages for AIX

Later on, I’ll probably try to write up some instructions for packaging these things yourselves so that you can use them even in a highly secure environment, but for now, you can probably trust Michael Perzl and his awesome website:  http://www.perzl.org/aix/.  You can find up-to-date versions of all the nice utilities you want in handy AIX-ready rpm packages (so everything consistently gets dropped into /opt/freeware, among other things).

But again, out of an abundance of caution for very secure environments, I would encourage you to package up these utilities yourself or use the AIX-provided stuff (despite the bugs and whatnot).  I’m sure any reasonable manager would pitch a fit if he knew you found some guy slingin’ rpms on the web and you went ahead and installed them in your production environments…

Advertisements
This entry was posted in Information Technology and tagged , , . Bookmark the permalink.

4 Responses to Putting a Red Hat on AIX: Easing the Transition Between Linux and AIX

  1. earth2baz says:

    If all you want is tab completion on AIX, then just use /usr/bin/ksh93 which is included in the default install.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s