Tutorial
Intelligent auto-installation of filesets for missing commands in IBM AIX
Auto-installation of required filesets using NIM serverArchive date: 2025-09-28
This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed.Introduction
When working with any operating system, identifying the package that provides a specific command can be challenging. On Linux, the command-not-found package addresses this issue by suggesting the package to install when a command is not found.
In this tutorial, we will learn how to setup IBM AIX server to achieve similar functionality using a Network Installation Management (NIM) server's lpp_source as the installation source for recognized commands.
Steps
Perform the following steps to set up automatic installation of filesets for missing commands on AIX:
Add filesets to NIM's lpp_source.
By default, the
lpp_sourcecreated on a NIM server will not include all packages available in the AIX media. You must manually copy them over to thelpp_source.- Create an
lpp_sourcefileset using the Configuring the NIM master and creating basic installation resources from the command line documentation. Copy the packages from AIX media to the
lpp_sourceusing the following command:# cp –prh <AIX MEDIA PATH>/installp/ppc/* <lpp_source dir>/installp/ppc/ # nim -Fo check <lpp_source>Allocate
lpp_sourceto client, from the NIM client using the following command:# nimclient -o allocate -a lpp_source=<lpp_source>
- Create an
Install the bos.content_list fileset.
The
bos.content_listfileset provides an inventory of all commands and their respective packages. You must Install it on the NIM client.Install the
bos.content_listfileset using the following command:# nimclient –o cust –a filesets=bos.content_list # lslpp -l bos.content_list Fileset Level State Description ----------------------------------------------------------------- ----------- Path: /usr/lib/objrepos bos.content_list 7.3.3.0 COMMITTED AIX Release Content List #After the
bos.content_listfileset is installed, you can identify the fileset a particular command belongs to using thewhich_filesetcommand. Example:# which_fileset rpvstat /usr/sbin/rpvstat glvm.rpv.client 7.3.2.0 #
Prepare .profile file.
The default shell in AIX is
ksh. Create a.profilefile for automatic command installation. If you already have a.profilefile, append the following content to it. The same approach can be applied to other shells.# cat /.profile # Define the find_cmd function find_cmd() { COMMAND=$(fc -ln -1 | tail -1 | awk '{print $1}') rc=$? if [ $rc = 0 ]; then type $COMMAND > /dev/null 2>&1 if [ $? != 0 ]; then which_fileset $COMMAND >/dev/null 2>&1 rc=$? if [ $rc != 0 ]; then echo "ksh: $COMMAND: not found." >/dev/null 2>&1 else FILESETS=$(which_fileset $COMMAND | awk '{print $(NF-1)}' | awk '!x[$0]++') echo "$COMMAND belongs to fileset $FILESETS. It's not installed on the system. Do you want to install it? (y/Yes)" read Option if [[ "$Option" = "y" || "$Option" = "yes" || "$Option" = "Y" || "$Option" = "Yes" ]]; then LPP_SOURCE_LIST=$(nimclient -l -c resources `hostname - s` | grep lpp_source | awk -F" " '{print $1}' | awk '!x[$0]++') if [ -n "$LPP_SOURCE_LIST" ]; then for LPP_SOURCE in $LPP_SOURCE_LIST; do for FILESET in $FILESETS; do nimclient -o showres -a resource=$LPP_SOURCE | grep $FILESET >/dev/null 2>&1 if [ $? = 0 ]; then nimclient -o allocate -a lpp_source=$LPP_SOURCE nimclient -o cust -a filesets="$FILESET" if [ $? = 0 ]; then echo "$FILESET for command $COMMAND successful" else echo "$FILESET installation failed " fi nimclient -o allocate -a lpp_source=$LPP_SOURCE fi done done else echo "LPP source not allocated to client" fi fi fi fi fi COMMAND="" } trapDbg() { local c="$BASH_COMMAND" [[ "$c" != "pc" ]] && export _cmd="$c" } pc() { local r=$? trap "" DEBUG [[ -n "$_cmd" ]] && _ret="$r " && find_cmd || _ret="" export _ret export _cmd= trap 'trapDbg' DEBUG } # Shell-specific configurations case "$SHELL" in *ksh) # Use DEBUG trap for ksh trap ' [ "$ERRNO" = "2" ] && find_cmd' DEBUG #trap - HUP INT ERR QUIT KILL ;; *bash) # Use PROMPT_COMMAND for bash # PS1='$_ret$ ' export PROMPT_COMMAND=pc trap 'trapDbg' DEBUG ;; *zsh) # Use preexec function for zsh preexec() { find_cmd } ;; *) echo "Unsupported shell: $SHELL" ;; esacTest the setup.
After the .profile file is prepared and sourced in the current shell, you can run the required commands and test the automatic installation of missing commands.
Verify the
lpp_sourceallocation using the following command:# nimclient -l -c resources `hostname -s` 730_TL2_SP1_LPP lpp_source #If no
lpp_sourceis allocated, allocate thelpp_sourceusing the following command:# nimclient -o allocate -a lpp_source=<lpp_source>- After sourcing the .profile file, try running the commands you want. If a command is valid and not found on the system, you will be prompted to install the corresponding fileset.
Example:
If a command is not found to be part of any fileset, you will receive the not found error message. Example:# dpasswd ksh: dpasswd: not found. dpasswd belongs to fileset dsm.core. It's not installed on the system. Do you want to install it? (y/Yes) y +-----------------------------------------------------------------------------+ Pre-installation Verification... +-----------------------------------------------------------------------------+ Verifying selections...done Verifying requisites...done Results... SUCCESSES --------- Filesets listed in this section passed pre-installation verification and will be installed. Selected Filesets ----------------- dsm.core 7.3.0.0 # Distributed Systems Manageme... << End of Success Section >> +-----------------------------------------------------------------------------+ BUILDDATE Verification ... +-----------------------------------------------------------------------------+ Verifying build dates...done FILESET STATISTICS ------------------ 1 Selected to be installed, of which: 1 Passed pre-installation verification ---- 1 Total to be installed +-----------------------------------------------------------------------------+ Installing Software... +-----------------------------------------------------------------------------+ installp: APPLYING software for: dsm.core 7.3.0.0 . . . . . << Copyright notice for dsm >> . . . . . . . Licensed Materials - Property of IBM 5765CD300 Copyright International Business Machines Corp. 2008, 2021. All rights reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. . . . . . << End of copyright notice for dsm >>. . . . Finished processing all filesets. (Total time: 4 secs). +-----------------------------------------------------------------------------+ Summaries: +-----------------------------------------------------------------------------+ Installation Summary -------------------- Name Level Part Event Result ------------------------------------------------------------------------------- dsm.core 7.3.0.0 USR APPLY SUCCESS dsm.core 7.3.0.0 ROOT APPLY SUCCESS dsm.core for command dpasswd successful ## leap ksh: leap: not found. #
Summary
This comprehensive approach described in this tutorial ensures you to identify and install the fileset corresponding to a missing command on AIX, similar to the command-not-found functionality in Linux. This setup can be adapted for other shells like bash, sh, zsh, and so on.