Whether you're a newly minted AIX administrator or a gray-bearded RS/6000 guru, you likely know that AIX isn't your granddad's Unix. Although standard Unix shell commands, such as ls and grep, work fine under AIX, IBM developers often took the road less traveled when developing commands for administering hardware or low-level OS functions. Thus AIX includes hundreds of commands that perform functions unique to the AIX Power platform—commands you won't find in other Unix systems, such as Linux or BSD.
Alas, these AIX commands are often unintuitive, and you can spend hours searching for them to polish off a critical administrative task before dashing home for the weekend. This article gives you the top 10 uniquely AIX commands you should have at your fingertips for the most common administrative tasks. Learn them, remember them, use them.
1. smit: System Management Interface Tool
If you don't know about smit, you're truly an AIX neophyte. No shame in that, as long as you spend a goodly number of hours exploring and learning the smit menu structure (Figure 1, at bottom), which provides guided navigation to virtually every AIX command:
Move cursor to desired item and press Enter.
Software Installation and Maintenance
Software License Management
System Storage Management (Physical & Logical Storage)
Security & Users
Communications Applications and Services
Manage the 4764 PKCS11 subsystem
Performance & Resource Scheduling
Processes & Subsystems
Cluster Systems Management
Using SMIT (information only)
F1=Help F2=Refresh F3=Cancel Esc+8=Image
Esc+9=Shell Esc+0=Exit Enter=Do
You can append a command name to smit (e.g., smit chuser), and smit walks you through each argument of the command, providing help text as well as lists of possible values. When you don't know what you're looking for or aren't even sure what you want to do, smit can help you peruse the AIX command structure until something strikes your fancy.
2. prtconf: Print Configuration
You can't properly administer a machine if you don't know what AIX version and hardware components it's running. Every Unix platform seems to have its own private command to perform this task; with AIX it's prtconf. If you run prtconf without any options, it displays the values shown in Figure 2.
System Model: IBM,9133-55A
Machine Serial Number: 65BAA7G
Processor Type: PowerPC_POWER5
Processor Implementation Mode: POWER 5
Processor Version: PV_5_2
Number Of Processors: 4
Processor Clock Speed: 1499 MHz
CPU Type: 64-bit
Kernel Type: 64-bit
LPAR Info: 1 65-BAA7G
Memory Size: 7936 MB
Good Memory Size: 7936 MB
Platform Firmware level: SF240_338
Firmware Version: IBM,SF240_338
But prtconf doesn't stop there. It also displays several more pages of useful values: network addresses, paging space utilization, volume group usage, and a detailed inventory of installed hardware components (e.g., IDE, PCI, and SCSI storage adapters; Ethernet NICs; RAID controllers). You can supply option flags to extract a specific value, such as CPU type (-c), kernel address type (-k), or system memory capacity (-m), which can be very useful in scripts. The output is in the form of a key:value pair, which is easy to parse in a script:
Other AIX-specific commands that provide similar information, but sometimes with more detail, include lsattr, lscfg, oslevel, and uname. Check out their man pages for details on their abilities.
3. lsdev: List Attached Devices and Their Characteristics
Sometimes you just want to examine system peripherals by type, to determine whether you have an available unused device for a particular mission. The lsdev command delivers what you want, concisely and quickly. For example, to get a list of network interface cards, run
and you get the output that Figure 3 shows.
en1 Defined 07-09 Standard Ethernet Network Interface
et0 Defined 07-08 IEEE 802.3 Ethernet Network Interface
et1 Defined 07-09 IEEE 802.3 Ethernet Network Interface
lo0 Available Loopback Network Interface
The -Cc option is an AIX idiom. The uppercase C indicates that you want to list a device identified in AIX's standardized Customized Devices object class; the lowercase c indicates that you will specify a single device class name, in this case "if" for network interfaces. Other common class name values include disk and tape. To list all the devices in the Customized Devices object class, just run lsdev -C. The command has loads of other options, which you can peruse in the man page. Be aware, however, that Linux has a command by the same name that operates completely differently.
4. lsuser: List User Attributes
User administration is another one of those functions that every Unix flavor seems to do differently, which makes privilege-sensitive scripts hard to write. For example, you would like to ensure that the user running a backup script is a member of the group with access to the tape drive. Usually you're forced to go mucking around in the /etc/passwd and /etc/group files for this information. AIX is better than most in this respect; its lsuser command lets you query the attributes of an individual user, and AIX by default stores more than 50 attributes, including a user's groups, home directory, shell, quotas, and last-login timestamps. For instance, you can run the command that Figure 4 shows and get output like that shown in the figure.
The -f option requests attributes in stanza form, indented under the user name, one attribute per line. Without -f, all the attributes are strung together on one line, which may be more convenient for parsing using regular expressions. Specifying ALL for the user name lists all user attributes for all users, or if you specify an attribute using the -a option, all of that attribute for all users, as Figure 5 demonstrates.
5. entstat: Display Ethernet Statistics
Many server performance problems can be traced back to bad network connectivity: defective cables, port speed/duplex mismatch, MTU failures, and so on. Other Unix flavors present this information in tabular form, which makes it difficult to query and parse easily. AIX's entstat tool delivers the stats for one interface at a time, with crystal-clear captions, making it easy to assess an interface's error conditions. The most common idiom for entstat is the one that Figure 6 depicts.
Transmit Errors: 10223 Receive Errors: 0
No Carrier Sense: 0 CRC Errors: 0
Lost CTS Errors: 0 Alignment Errors: 0
Max Collision Errors: 216 No Resource Errors: 0
Late Collision Errors: 10007 Receive Collision Errors: 0
Deferred: 281379 Packet Too Short Errors: 0
SQE Test: 0 Packet Too Long Errors: 0
Timeout Errors: 0 Packets Discarded by Adapter: 0
No mbuf Errors: 0
Every significant error counter includes the tag Error, so a simple grep for that string gives you a quick way to see if a particular network interface might be the cause of performance troubles. A related command idiom to see the port speed/duplex settings on an interface is this one:
Note that AIX native Gigabit Ethernet controllers should always be configured to run in auto-negotiation mode, which you can enforce by using the following command:
6. svmon: System Virtual Memory Monitor
Troubleshooting application performance problems typically requires first verifying that resource starvation isn't the cause, and the most common resource that applications run out of is memory. Memory comes in two varieties, virtual and real, and despite the "v" in the svmon command name, it can report on real memory usage as well as virtual. For example, to discover the top three users of real memory, check out the command and output that Figure 7 shows.
Pid Command Inuse Pin Pgsp Virtual 64-bit Mthrd 16MB
0 swapper 12058 8156 0 12058 Y N N
PageSize Inuse Pin Pgsp Virtual
s 4 KB 11962 8076 0 11962
m 64 KB 6 5 0 6
To get the same information for virtual memory, run svmon -Pgt 3.
7. iptrace: TCP/IP Packet Capture Utility
The legendary packet-sniffing program popular on other Unix flavors, tcpdump, is available in AIX but may not be the best tool for the job. AIX's built-in iptrace utility collects more information than tcpdump, and its companion ipreport tool provides better decoding. Note, however, that iptrace actually runs as a daemon process in the background, rather than as a shell command in the foreground, as with tcpdump. Although you can invoke iptrace directly from the command line, it's easier to control if you use the Start System Resource (startsrc) and Stop System Resource (stopsrc) commands, as Figure 8 shows.
# stopsrc -s iptrace
You can then print out the captured packets, decoded, by using ipreport, as you see in Figure 9.
ETH: ====( 1177 bytes transmitted on interface en0 )==== 10:35:45.432353167
ETH: [ 00:02:55:6a:a5:dc -> 00:02:55:af:20:2b ] type 800 (IP)
IP: < SRC = 18.104.22.168 > (en6host1)
IP: < DST = 22.214.171.124 > (en6host2)
IP: ip_v=4, ip_hl=20, ip_tos=8, ip_len=1163, ip_id=1983, ip_off=0
IP: ip_ttl=60, ip_sum=e6a0, ip_p = 6 (TCP)
TCP: <source port=32873, destination port=20(ftp-data) >
TCP: th_seq=623eabdc, th_ack=973dcd95
TCP: th_off=5, flags<PUSH | ACK>
TCP: th_win=17520, th_sum=0, th_urp=0
TCP: 00000000 69707472 61636520 322e3000 00008240 |iptrace 2.0....@|
TCP: 00000010 2e4c9d00 00000065 6e000065 74000053 |.L.....en..et..S|
TCP: 00000020 59535841 49584906 01000040 2e4c9d1e |YSXAIXI....@.L..|
TCP: 00000030 c0523400 0255af20 2b000255 6aa5dc08 |.R4..U. +..Uj...|
TCP: 00000040 00450000 5406f700 00ff0128 acc00106 |.E..T......(....|
TCP: 00000050 01c00106 0208005a 78468a00 00402e4c |.......ZxF...@.L|
As an added bonus, the trace.out file created by iptrace is readable by Windows-based network analyzers, such as the free Wireshark (wireshark.org).
8. topas: Top Resource Usage Monitor
Legacy Unix gave us the top command, a continuously updating list of the top CPU users on the system. AIX's topas is top on steroids. As you see in Figure 10, you get a CPU usage bar graph display (in hash marks), a list of top CPU consumers, network and disk I/O data rates, and a slew of other statistics critical for performance tuning.
Topas Monitor for host: s1 EVENTS/QUEUES FILE/TTY
Sun Jul 31 21:18:16 2011 Interval: 2 Cswitch 106 Readch 97006
Syscall 2421 Writech 2470
Kernel 7.2 |## | Reads 85 Rawin 0
User 15.6 |#### | Writes 28 Ttyout 232
Wait 0.0 |# | Forks 1 Igets 0
Idle 77.2 |###################### | Execs 0 Namei 342
Runqueue 0.0 Dirblk 0
Network KBPS I-Pack O-Pack KB-In KB-Out Waitqueue 0.0
en0 2.7 13.0 10.0 1.0 1.7
lo0 0.0 0.0 0.0 0.0 0.0 PAGING MEMORY
Faults 353 Real,MB 7936
Disk Busy% KBPS TPS KB-Read KB-Writ Steals 0 % Comp 13.3
hdisk1 0.0 0.0 0.0 0.0 0.0 PgspIn 0 % Noncomp 6.6
hdisk0 0.0 0.0 0.0 0.0 0.0 PgspOut 0 % Client 6.6
cd0 0.0 0.0 0.0 0.0 0.0 PageIn 0
PageOut 0 PAGING SPACE
Name PID CPU% PgSp Owner Sios 0 Size,MB 512
topas 319528 0.0 1.5 root % Used 0.0
sshd 278694 0.0 0.6 root NFS (calls/sec) % Free 100.0
sshd 442374 0.0 0.9 root ServerV2 0
rpc.lock 250018 0.0 1.2 root ClientV2 0 Press:
syslogd 151766 0.0 0.3 root ServerV3 0 "h" for help
sendmail 135256 0.0 1.4 root ClientV3 0 "q" to quit
pilegc 45078 0.0 1.4 root
muxatmd 274638 0.0 0.6 root
syncd 122966 0.0 0.5 root
gil 86058 0.0 0.9 root
xmgc 49176 0.0 0.4 root
snmpdv3n 241782 0.0 1.0 root
The variant topas -E displays just the Ethernet throughput statistics. Alas, AIX doesn't have the good old original top command, but if you miss its columnar output, you'll be glad to know that topas -P gives you almost the same thing.
9. mksysb: Make a Bootable System Backup
Creating a "bare metal" backup copy of an AIX installation is critical for rapidly recovering from a permanent system or hard drive failure. A "bare metal" backup is one you can restore to a completely new AIX server without the time-consuming manual task of reinstalling AIX from scratch, along with all the licensed program products and PTFs from the failed machine. The command is easy to use: Just provide the -i option and specify the device path for the backup device (in this case Removable Tape 0):
The mksysb command creates a "bare metal" backup by creating a binary image copy of the root volume group (rootvg), which is where the AIX operating system resides. You can use this copy to restore AIX to that point in time on repaired or new hardware. Even open files are backed up with mksysb.
A mksysb backup has three parts: a boot image, a complete list of files contained in the backup (image.data), and the actual binary image file. After mksysb writes these parts to the backup media, it compares what's on the list to what's on the tape in the backup as a verification step. If you create the backup on tape or UDFS-capable (DVD-ROM) media, the backup is bootable and includes the installation programs needed to install from the backup. If the tape drive to which you make the copy doesn't support bootable media, you need AIX licensed product DVDs or CDs to boot the system, and then you can restore the mksysb backup by using the restore command:
Although mksysb backs up the complete AIX operating system, it doesn't back up data in other volume groups, such as your application files. Traditional Unix uses the tar (Tape Archive) utility to do this, but AIX has a better way, the Save Volume Group (savevg) command:
Using savevg is better than using tar because savevg stores the logical volume sizes and mount names, so that they're automatically re-created when you restore the data by using the restvg command:
As with mksysb, savevg can back up even open files, although you should take care with this feature because it may result in data backup being in an inconsistent state with respect to the underlying applications.
10. IBM's AIX Error Identifier Demystifier
This last "command" is not really a command, but it needs to be in your command-line toolkit anyway: the AIX Error Identifier Lookup web query page:
AIX has an extremely fine-grained error-coding scheme, which lets you get more information about the root cause of, and remedies for, any error ID returned from any command. This tool retrieves IBM's original error code specification sheet.
AIX Is a Better IBM system administration
These commands unique to AIX can make system administrative tasks much easier than on traditional AT&T UNIX or variants such as Linux or BSD. But you have to know these commands exist before you can exploit them. Now you do, so you can.
*Editor’s Note: This article is part of a special five-article Power Pack, “Beyond POWER7: Performance for Power Pros,” available as a handy downloadable .pdf from our sister site, iPro Developer.