dropdown menu



lspv | cut -c 6-7            lists the hdisks numbers (cuts the 6th and 7tn character (disk nubers))
dlnkmgr view -drv | grep -w 00000 | awk '{print $4}' | cut -d . -f 3


EXPR: integer arithmetic

\*                           multiplication (\ is needed to tell * is not a special character)
/                            division
%                            remainder
-                            substraction

expr \( 6 + 4 \) / 2        5


FIND: recursively searches the directory tree

find / -xdev -type f -name "cor*" -size +10000c -exec ls -l {} \;

    /                        where to find
    -xdev                    looks only in the given fs
    -type f                  what type to look for (f: file, d: direcory)
    -name "cor*"             name to look for
    -size +10000c            search for the given size (+10000c : greater than 10000 character (larger then 10kbyte))
    -size +2                 search for greater than 1kbyte (bloxk size is 512 byte, that's why +2 is given)
    -exec ls -l {} \;        what command to execute
                             ({}: it represents each findings and \; is needed at the end of line)
                             e.g. find /home -xdev -name "*.old" -exec rm {} \;
    -mtime -1                file modifocation date is less then 1 day (+1 means older than 1 day)

find . -name '*.ksh' -ok rm {} \; this will ask if the command (rm) should be executed or not (much safer if find is not perfect)
find /etc/rc.d -ls           it lists the files and dirs in the given dir
find /tmp/bb -exec awk '/func/ {print FILENAME}' {} \;   it will check in /tmp/bb if any files contains the word "func" and list those


GREP: (Global Regular Expression Parser) The grep command searches for the pattern.

grep -i                      ignore case (small letter or capital)
grep -c                      displays only a count of matching lines
grep -n                      shows line number at the beginning of the matching line
grep -v                      invert the sense of matching, to select non-matching lines
grep -w                      selects only whole words
grep -l                      lists the name of the files (once) which contain matching line  (grep -l paging00 *)

ps -ef | egrep 'ssh|aix'     select lines with ssh and aix
errpt -a|grep -A1 'NAME'     selects lines with NAME and shows 1 line after that (A: after, B: before)



head filename                displays first 10 lines of the file
head -50 filename            displays first 50 lines

tail filename                displays last 10 lines of the file
tail -50 filename            displays last 50 lines
tail +15 filename            displays the file starting from the 15th line
tail -f filename             used when we are monitoring the file (interactively shows how the file is changing)



-n                           no host name resolution
-P                           not converts port numbers to port names

lsof -i                      show all network connections
lsof -i| grep LISTEN         shows what ports are waiting for connections
lsof -i | grep ESTABLISHED   shows current active connections

lsof -i tcp                  list only TCP connections (works with udp as well)
lsof -i :<port>              shows all connections of a given port (lsof -i :22 or lsof -i :ssh)
lsof -i @<host>              shows connections to a specific host (lsof -i @
lsof -i protocol:@ip:port    this is the syntax for network findings (protocol: tcp or udp, @ip: any ip address, port: a port number)
lsof -a -u <user> -i         shows all network activity of a user (-a combines -u and -i)

lsof -u <user>               shows what is open for a user (lsof -u oracle)
lsof <file>                  shows what is using a file (lsof /var/adm/syslog.log)
lsof <directory>             shows what pids are using the filesystem (directory) (it can be good if we cannot umount)
lsof +D <directory>          shows which file is open by which process in a directory (lsof +D /usr)
                             (+D will show recurcively the open files, otherwise only device name would be shown)
lsof -N                      list all NFS files
lsof -c <command>            shows files and network connections a command is using (lsof -c ssh)

lsof -p <pid>                shows what a proccess ID has open (lsof -p 335545)



root@aix20: /root # lsof -p 319660
ovcd    319660 root   32r  VREG     10,5    12153 69705 /usr (/dev/hd2)

(it will show the filesystem and the indode number (69705))

root@aix20: /root # find /usr -inum 69705



                     GREP    SHELL
single character      .       ?
multicharacter        .*      *
character range     [x-z]    [x-z]
begins a line         ^       N/A
ends a line           $       N/A
variable             N/A      $   

HOME                         home directory
$PS1                         prompt symbol   
set                          displays the values of all shell variables



rpm -qa                       shows what rpm packages are installed
rpm -ql <package name>        shows where the files are installed (rpm -qlp .. shows the absolut paths???)
rpm -q --filesbypkg cdrecord  list all the files on installed rpm package
rpm -qf /usr/bin/lynx         query a file to find the source rpm package
rpm -qi <package name>
        list information on an installed rpm package
rpm -qR <package name>        list all dependencies on any rpm package
rpm -ivh httpd-2.2.8.aix5.1.rpm install the rpm package

rpm -ivh --force *.rpm
rpm -ivh --force --nodeps <package name>    does not check dependency (same can be done with "rpm -Uvh..." for upgrade)
rpm -e <package name> 
        removes the rpm package

rpm -Va                       shows which files are missing from the RPM database
rpm -Vv <package name>        verifies a package
rpm --rebuilddb               compress and rebuild the RPM database

/usr/sbin/updtvpkg            enables the rpm command to recognize that the libraries have been installed

In some cases you might get an error about failed dependencies when you install RPMs on AIX (for example, error: failed dependencies: libX11.a(shr4.o) is needed by tk-8.3.3-1). Most likely the error occurs because the rpm command does not recognize the shared library. If the error occurs, check to see if the X11 libraries are installed in the directory /usr/lpp/X11/lib. If they are not installed, use the AIX product media to install them. After you have installed the libraries, run the above command (updtvpkg). The command enables the rpm command to recognize that the libraries have been installed.



Much like cp, rsync copies files from a source to a destination. Unlike cp, the source and destination of an rsync operation can be local or remote. rsync can resume a transfer after interruption; it transfers only those portions of a file that differ between source and destination; and rsync can perform entire or incremental backups.

By default, rsync uses Secure Shell (SSH) as its transport mechanism; you can reuse your machine aliases and public keys with rsync

rsync -av /tmp/bb_rs30 /tmp/bb        it will copy the directory (/tmp/bb_rs30) and its contents under /tmp/bb
rsync -av /tmp/bb_rs30/ /tmp/bb       it will copy the contents of the named directory but not the directory itself (check / at the end)
                                      -v option enables verbose messages
                                      -a option (stands for archive), is a shorthand for -rlptgoD:
                                      recurse, copy symbolic links as symbolic links, preserve permissions, preserve file times,
                                      preserve group, preserve owner, and preserve devices and special files, respectively

rsync -n -av /tmp/bb_rs30/ /tmp/bb   -n: previews what will happen but does not move a single byte (it is good for testing)

rsync -av /tmp/bb_rs30/ aix2:/tmp/bb_rs20  it will copy the contents of the given dir to the other host
                                           (assuming the same login name on the remote machine)



cat /etc/passwd | sort -t: -n +2
    -t:                      gives the delimeter character (here :, deafult is the space)
    -n                       numerical order
    +2                       sort by the 3rd column
    -r                       reverse order

df -m | sort -n +3 | egrep '9.%|100%'    sorts by the 4th column (%) of the filesstems, which are 90-100% full
cat animals | sort +0.1      sort the file animals by the second character of the first word
ls -lR |sort -nk 5|tail -20  sorts the 20 largest file
lspv | sort -k1.6n           list hdisk in numerical order (lspv|sort -tk +1 -n <--it is the same (delimiter is "k")
lspv | sort -k1,1.5 -k1.6n   list hdisks then vpaths in numeric order



tar -cvf /tmp/file.tar .                       saves where we are to the given path (-c: create, -v: verbose, -f: file)
tar -cvf conf.tar conf                         creates conf.tar of the dir conf
tar -xvf /tmp/file.tar                         extracts the tar file (-x: extract)
tar -xvf -C /home/bb /tmp/file.tar             it will extract the tar file to /home/bb
tar -tvf /tmp/file.tar                         list (verify) the content of a tar file

tar -cf - * | gzip -9 > vmi.tar.gz             makes tar and zip wehere we are
tar cvf - openssh5.8p1 | gzip -c > openssh5.8p1.tgz   creates tgz in one command

tar: 0511-197 DirectorServer: Cannot write data extracted with the tar command:
A file cannot be larger than the value set by ulimit.

I changed these ulimit settings after that it was OK (dont't forget to logout and login again)
root@bb_lpar: /bb # chuser fsize=-1 fsize_hard=-1 root
root@bb_lpar: /bb # chuser data=-1 data_hard=-1 root



truss <command>     
         it will show what system calls a command makes
truss -c -p <pid>            it will trace a process (-c: counts the system calls rather than displaying them, -p: pid)
truss -d -p <pid> -o
truss -t open lsps -a        shows whatis needed for the given command (here lsps -a)



lspv|awk '{print$1}'|xargs   it will list the elements in a line separated with space
cat list | xargs -t rm       will rm all the files which are in the file list
ls | xargs -t -I {} mv {} {}.old it will rename to .old all the file in the current dir
    -t                       it echoes the constructed command (trace mode) (it is optional)
    -I {}                    insert each line of the ls to that place where the {} symbol appear

lsdev -Cc disk | xargs -n1 rmdev -dl removes all the listed disks
    -n1                      1 element will be passed each time to xargs (if n2 then the command will be created with 2 elements)



gzip-V                       shows gzip version
gzip file1                   zip
gzip -d file1.gz             unzip

gzip -9 filename             will zip (and remove the file automatically)
gunzip filename              unzipping it

gzip -c file > file.gz       it creates a zip file but leave the original file as well
> filename                   after that original file can be emptied

compress file1               the original file will be deleted and a new compressed file will be created with a .Z at the end
zcat file1.Z                 displays the compressed files (without uncompression)
uncomress file1.Z            uncompressing a file (the compressed one will be deleted)

if you receive this:
gunzip SysDir6_2.tar.gz
gunzip: SysDir6_2.tar: File too large

this is because gzip 1.2.4 (or lower gzip versions) need a patch to accept large files, workaround for this problem:
gzip -d -c SysDir6_2.tar.gz| tar xvf -



file <filename>              shows the type of a file

diff file1 file2             compares only text files
cmp file1 file2              compares all types of files
dircmp dir1 dir2             compares directories

time cp file1 /home          show the time to accomplish the command (godd for performance analysis)

ps $$                        shows which shell is in use
echo $SHELL                  shows the current shell
printenv                     view environmental variables

cat -vet file                shows tabs, enters... as viewable characters
    -v                       displays non-printing characters as visible characters
    -t                       displays tab as ^I
    -e                       displays enter as $

!!! sh -xv <command...>      for troubleshooting, if a command fails, you can see where exactly it failed in the command script!!!
                             (sh -xv exportvg rootvg)

dd if=/dev/zero of=/home/user/bb/4GB_file bs=1m count=4000  it creates a 4GB file
lmktemp <filename> <size_in_bytes>   it creates a file with given size

alias dir='ls'               creates an alias   
unalias dir                  removes an alias
set - unset

df -g | awk '{sum = sum + $3} END {print sum}' it sums up the fs in gigabyte (by the 3rd column)
for i in `ls -l | grep old | awk '{print $9}'` ;  do du -sk $i; done | awk '{sum = sum + $1} END {print sum}'

generating random passwords:
dd if=/dev/urandom bs=16 count=1 2>/dev/null | openssl base64 | sed "s/[=O/\]//g" | cut -b1-8


  1. Hi google
    Need assistance
    I am trying to install wireshark in aix. Need assistance

    As advised i have done all the steps. But still i am getting same error

    After running updtvpkg

    exec(): 0509-036 Cannot load program wireshark because of the following errors:
    0509-150 Dependent module libgtk-x11-2.0.a(libgtk-x11-2.0.so.0) could not be loaded.
    0509-022 Cannot load module libgtk-x11-2.0.a(libgtk-x11-2.0.so.0).
    0509-026 System error: A file or directory in the path name does not exist.
    wireshark binary around 1406 rpm
    server:/opt/wireshark>ls -l |wc -l

    1. Hi, I would check if the mentioned library (libgtk-x11-2.0) really exists.
      Or you can check this as well: http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=%2Fcom.ibm.java.doc.user.aix64.50%2Fuser%2Flimitations.html

  2. You have a typo in the FIND stanza. In the line beginning with "-size +10000c", change 1000 to 10000.


  3. Oops, after editing out my snarky comment in my previous comment (since I'm new here), I forgot to say "great blog and AIX resource" !!


    1. Hi Paul, thanks for you feedback, I have updated the mentioned line. Happy to hear you like this blog :)


  4. rpm -Uvh httpd-2.2.8.aix5.1.rpm install the rpm package

    rpm -Uvh --force *.rpm
    rpm -Uvh --force --nodeps does not check dependency

    rpm -Uvh ---> is for upgrade the package i hope, corrct me if i am wrong

    1. Hi, yes and no :)
      This is written in man page for "rpm -U":
      "This upgrades or installs the package currently installed to a newer version. This is the same as install, except all other version(s) of the package are removed after the new package is installed."

      I used "-U" to install new packages, but you are right in can be misleading so I changed it to "-i"

  5. Hi,
    i can see the history of cmds ran by the individuals in the home directory .sh_history.in which file can we see the history of cmds ran by the user after he switch as root by sudo su - root?

    1. Hi, commands are saved in the .sh_history of the actual user. If you change user with "su", the commands followed after the change will be saved in the sh_history of the new user.

  6. Hi sir, i new for AIX. ur blog is very useful for me. thanks alot...

  7. Excellent and educational blog. I've learned alot from this blog. Thanks

  8. HI Aix,
    Thanks for the sharing each and every inputs on each topyic....Some of them are not covered.So,plz kindly add some more filesystems cleared spaces like /,/usr(is not proper),/tmp

    Thanks in Advance.

    1. Hi, some description about filesystem clearing can be found here: http://aix4admins.blogspot.hu/2011/05/superblock-in-jfs-superblock-is-first.html. /tmp should be temporary filesystem so no permanent data should be contained there.

  9. Hi AIX,
    I am new to this blog. Just gone through some pages and found it very useful. Excellent blog. Thank you very much!!!!!!!!!!!

    - Nitin

  10. u r blog is so super compare ....compare to all ...people are said dont compare to every one ...but ur superb.................

  11. For such issues, you can use Long Path Tool, it really works good I will say.

  12. Hello

    grep -A and grep -B are not working in AIX 6100-09.
    cat file.txt|grep -A1 'Generating'
    grep: illegal option -- A
    grep: illegal option -- 1
    usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...]