How to Install LSOF on AIX

The LSOF command, which lists open files, shows the processes connected to a particular file. It’s a very useful command.

The name’s a little bit misleading. But remember, Unix treats everything (devices, filesystems) as files. So think of lsof as the command to “show the process that’s using a particular resource”.

Example of Using lsof

For example, I’d like to unmount /dev/cd0, which is on /mnt. But I can’t unmount, because I’m in the /mnt directory:

AIX# cd /mnt
AIX# umount /mnt
umount: 0506-349 Cannot unmount /dev/cd0: The requested resource is busy.

Suppose I didn’t realize my shell is keeping the /mnt directory busy. But the LSOF command can verify that it’s my bash session preventing the umount:

AIX# lsof /mnt
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 975102 root cwd VDIR 15,0 /mnt (/dev/cd0)

AIX# cd /
AIX# umount /mnt

Steps to Install lsof on AIX

1) Obtain the fileset. It’s in the AIX 5L V5.3 Expansion Pack which shipped with your AIX system. Supposedly, you can call IBM and they will ship you the CDs if you have support with them. Otherwise, try downloading it from their website. I had to create an IBM login to get the file I needed.

I personally installed this using the CDs, so those are the instructions I’m giving.

2) Insert CD, “AIX Expansion Pack”

3) Run SMIT

AIX# smit

4) Navigate to Install Software

Software Installation and Maintenance > Install and Update Software > Install Software

5) Specify your device as your CD (i.e. /dev/cd0)

6) Scroll to SOFTWARE to install. Press F4 or esc+4.

7) Find lsof.base and lsof.man.en_US. Select these using F7 or esc+7

8) Hit enter a few times and it should install in /usr/sbin/lsof.

9) Test the command as root:

AIX# lsof

Uh-Oh. lsof: FATAL: compiled for a kernel of 32 bit size.

You have a 64-bit machine. You’re running the 32-bit version. It’s okay. You probably have both versions installed. To check:

AIX# lsof64

If that command runs without any errors:

AIX# which lsof
/usr/sbin/lsof

AIX# cd /usr/sbin
AIX# mv lsof lsof32
AIX# ln -s lsof64 lsof
AIX# lsof

Tags: , , , ,

2 Responses to “How to Install LSOF on AIX”

  1. [...] Note: If you have LSOF installed, make sure you’re running the 64-bit version.  Check out the last part of my How to Install LSOF post. [...]

  2. [...] Install.  If you’re using a CD, follow my directions for installing lsof from here (of course, replace openssh with lsof).  Otherwise, I have some installp examples [...]

Leave a Reply