USEFUL TIPS IN AIX ls -l /home | sort -rn This displays files and directoris inside /home as per their size, larger file on top. ls -l /home/* sort -rn This displays files and also the subdirectories in the /home/ directories as per their size, larger one on top. Note: If /home dir. contains more than one dir. then it first shows all the directiory name and then the files inside the directories as per the directory order. The order is symlink, Directory name, file name. du /home | sort -rn This also displays the subdirectories inside /home as per their size but not files. du -m /home/test/smit.log This shows the size of the smit.log in MB. -g=GB, -k=KB, without flag=shows in Block size. ls -lrt | grep 'Jan 10' | awk '{print$9}' > namefile This is used to get only the file names dated Jan 2010 in a namefile rm `cat namefile` To delete filenames mentioned in the namefile created by the above command. To execute a command in a loop, i.e. in a certain intervals, put the small script in the shell while i= do
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
USEFUL TIPS IN AIX
ls -l /home | sort -rn This displays files and directoris inside /home as per their size, larger file on top.
ls -l /home/* sort -rn This displays files and also the subdirectories in the /home/ directories as per their size, larger one on top.
Note: If /home dir. contains more than one dir. then it first shows all the directiory name and then the files inside the directories as per the directory order. The order is symlink, Directory name, file name.
du /home | sort -rn This also displays the subdirectories inside /home as per their size but not files.
du -m /home/test/smit.log This shows the size of the smit.log in MB. -g=GB, -k=KB, without flag=shows in Block size.
ls -lrt | grep 'Jan 10' | awk '{print$9}' > namefile This is used to get only the file names dated Jan 2010 in a namefile
rm `cat namefile` To delete filenames mentioned in the namefile created by the above command.
To execute a command in a loop, i.e. in a certain intervals, put the small script in the shell
while i=dodf -g /backupsleep 3done
in the above example this will show the size of /backup filesystem in each 3 seconds interval.
stty erase ^? To use backspace button to clear previous letters.
set -o vi To see previous executed commands using vi style
i.e. esc+ j=up, h=down, l=go right, g=go left, /string= search the command from history,
NIM related Commands in AIX
lsnim To list the nim resources
lsnim -l dcmds To list the detailed info about the object dcmds
lsnim -O dcmds To list the operation dcmds object can support
lsnim -c resources dcmds To list the resources allocated to the machine dcmds
nimclient The client version of nim command (User can obtain same results of nim in server )
nimconfig -a pif_name=en0 -a netname=net1 To initialise the NIM master with network name net1
nimconfig -r To rebuild /etc/niminfo file which contains the variables for NIM
nim -o define -t lpp_source -a source=/dev/cd0 -a server=master -a location=/export/lpp_source/lpp_source1 lpp_source1 To define lpp_source1 image in /export/lpp_source/lpp_source directory from source cd0
nim -o define -t mksysb -a server=master -a location=/resources/mksysb.image mksysb1 To define mksysb resource mksysb1, from source /resources/mksysb.image on master
nim -o remove inst_resource To remove the resource inst_resource
nim -o check lpp_source1 To check the status of lpp_source lpp_source1
nim -o allocate -a spot=spot1 -a lpp_source=lpp_source1 node1 To allocate the resources spot1 and lpp_source1 to the client node1
nim -o bos_inst node1 To initialise NIM for the BOS installation on node1
nim -o dkls_init dcmds To initialize the machine dcmds as diskless operation
nim -o dtls_init dcmds To initialize the machine dcmds for dataless operation
nim -o cust dcmds To initialize the machine dcmds for customize operation
nim -o diag dcmds To initialize the machine dcmds for diag operation
nim -o maint dcmds To initialize the machine dcmds for maintenance operation
nim -o define -t standalone -a platform=rspc -a if1="net1 dcmds xxxxx" -a cable_type1=bnc dcmds To define the machine dcmds as standalone with platform as rspc and network as net1 with cable type bnc and mac address xxxxx
nim -o unconfig master To unconfigure nim master
nim -o allocate -a spot=spot1 dcmds To allocate the resource spot1 from machine dcmds
nim -o deallocate -a spot=spot1 dcmds To de allocate the resource spot1 from machine dcmds
nim -o remove dcmds To remove machine dcmds after removing all resources associated to it
nim -o reboot dcmds To reboot ther client dcmds
nim -o define -t lpp_source -a location=/software/lpp1 -a server=master -a source=/dev/cd0 lpp1 To define lppsource lpp1 on master at /software/lpp1 directory from source device /dev/cd0
clstop -f -N To force shutdown cluster immediately without releasing resources
clstop -g -N To do graceful shutdown immediately with no takeover
clstop -gr -N To do graceful shutdown immediately with takeover
cldare -t To sync the cluster toplogy
cldare -t -f To do the mock sync of topology
cldare -r To sync the cluster resources
cldare -r -f To do the mock sync of resources clverify cluster verification utility
cllscf To list clustur topology information
cllsclstr To list the name and security level of the cluster
cllsnode To list the info about the cluster nodes
cllsnode -i node1 To list info about node1
cllsdisk -g shrg To list the PVID of the shared hard disk for resource group shrg
cllsnw To list all cluster networks cllsnw -n ether1 To list the details of network ether1
cllsif To list the details by network adapter
cllsif -n node1_service To list the details of network adapter node1_service
cllsvg To list the shared vgs which can be accessed by all nodes
cllsvg -g sh1 To list the shared vgs in resource group sh1
cllslv To list the shared lvs
cllslv -g sh1 To list the shared lvs in the resource group sh1
cllsdisk -g sh1 To list the PVID of disks in the resource group sh1
cllsfs To list the shared file systems
cllsfs -g sh1 To list the shared file systems in the resource group sh1
cllsnim Show info about all network modules
cllsnim -n ether Show info about ether network module
cllsparam -n node1 To list the runtime parameters for the node node1
cllsserv To list all the application servers
claddclstr -i 3 -n dcm To add a cluster definition with name dcm and id 3
claddnode To add an adapter
claddnim To add network interface module
claddgrp -g sh1 -r cascading -n n1 n2 To create resource group sh1 with nodes n1,n2 in cascade
claddserv -s ser1 -b /usr/start -e /usr/stop Creates an application server ser1 with startscript as /usr/start and stop script as /usr/stop
clchclstr -i 2 -n dcmds To change cluster definitions name to dcmds and id to 2
clchclstr -s enhanced To change the clustur security to enhanced
clchnode To change the adapter parameters
clchgrp To change the resource group name or node relationship
clchparam To change the run time parameters (like verbose logging)
clchserv To change the name of app. server or change the
start/end scripts
clrmclstr To remove the cluster definition
clrmgrp -g sh1 To delete the resource group sh1 and related resources
clrmnim ether To remove the network interface module ether
clrmnode -n node1 To remove the node node1
clrmnode -a node1_svc To remove the adapter named node1_svc
clrmres -g sh1 To remove all resources from resource group sh1
clrmserv app1 To remove the application server app1
clrmserv ALL To remove all applicaion servers
clgetactivenodes -n node1 To list the nodes with active cluster manager processes from cluster manager on node node1
clgetaddr node1 returns a pingable address from node node1
clgetgrp -g sh1 To list the info about resource group sh1
clgetgrp -g sh1 -f nodes To list the participating nodes in the resource group sh1
clgetif To list interface name/interface device name/netmask associated with a specified ip label / ip address of a specific node
clgetip sh1 To get the ip label associated to the resource groupclgetnet 193.9.200.2 255.255.255.0 To list the network for ip 193.9.200.2, netmask 255.255.255.0
clgetvg -l nodelv To list the VG of LV nodelv
cllistlogs To list the logs
clnodename -a node5 To add node5 to the cluster
clnodename -o node5 -n node3 To change the cluster node name node5 to node3
clshowres Lists resources defined for all resource group
clfindres To find the resource group within a cluster
xclconfig X utility for cluster configuration
xhacmpm X utility for hacmp management
xclstat X utility for cluster status
HACMP LOGS
=========
/tmp/hacmp.out Detailed event script output logged in 7 day rolling history
/var/adm/cluster.log High level view of cluster events (No clean up on this file)
/usr/sbin/cluster/history/cluster.mmdd Day by day view of cluster events. (one file / day of month)
/tmp/cm.log Clstrmgr messages
/tmp/cspoc.log Output from C-SPOC commands (similar to smit.log)
/tmp/emuhacmp.out Output from event emulation
rdist -b -f /etc/disfile1 To distribute the files in disfile1 to all nodes in disfile1 in binary mode
AIX differentiates between hardware adapters, their interfaces and protocols standards associated.
To recognize interface card AIX uses three notations:ent, en and et.All are different and are described below and the sake of completeness I am using 0 at the end:ent0:The notation ent0 is used to specify the hardware adapter. It has nothing to do with the TCP/IP address. The parameters associated with ent0 can be seen as below:# lsattr –El ent0It will show parameters related to card. It shows adapter_names, alt_addr, auto_recovery, backup_adapter, hash_mode, mode, netaddr, noloss_failover, num_retries, retry_time, use_alt_addr, use_jumbo_frame.en0:en0 represents the interface associated with hardware adapter ent0. The notation en0 is used for Standard Ethernet(inet). The TCP/IP address is associated with this interface. The parameters associated with en0 can be seen as below:#lsattr –El en0 It'll shows all the parameters related with the interface en0 of the adapter ent0.It shows alias4, alias6, arp, authority, broadcast=1500, mtu, netaddr, netaddr6, netmask, prefixlen, remmtu, rfc1323, security, state, tcp_mssdflt, tcp_nodelay, tcp_recvspace, tcp_sendspace.Rest everything is same except mtu(Maximum Transfer Unit) value. Which is 1500 as per the standard ethernet protocol.et0:et0 represents the interface associated with hardware adapter ent0. The notation et0 is used for IEEE 802.3 Ethernet(inet). If you are using standard ethernet protocol then it will not have TCP/IP address. The parameters associated with et0 can be seen as below:#lsattr –El et0 It'll shows all the parameters related with the interface et0 of the adapter ent0. It shows alias4, alias6, arp, authority, broadcast, mtu=1492, netaddr, netaddr6, netmask, prefixlen, remmtu, rfc1323, security, state, tcp_mssdflt, tcp_nodelay, tcp_recvspace, tcp_sendspace.Note here as well that the MTU shown will be 1492 as per IEEE 802.3 standard. Rest all parameters will be same. Also, netaddr, netmask fields will be empty fr et0.
Are these terms interchangable or is there a difference between them? I always get confused with these terms. What does en0 and ent0 mean and the difference between these?
AIX differentiates between a network adapter and network interface:
Network adapter Represents the layer-2 device, for example, the Ethernet adapter ent0 has a MAC address, such as 06:56:C0:00:20:03
Network interface Represents the layer-3 device, for example the Ethernet interface en0 has an IP address, such as 9.3.5.195
Typically, a network interface is attached to a network adapter, for example, an Ethernet interface en0 is attached to an Ethernet adapter ent0.
There are also some network interfaces in AIX that are not attached to a network adapter, for example, the loopback interface lo0 or a Virtual IP Address (VIPA) interface, such as vi0, if defined.
Clear the ADMCHG flag of the user account with "pwdadm -c <user>".
Example:
# pwdadm –c username
How can I directly read out the VGDA of a PV (hdisk)?
Information about VGx, LVx, filesystems, etc. are stored in the ODM. But these information are also written to the VGDA of the disks itself. You can read the information directly from the disk's VGDA with a command like this: # lqueryvg -Atp hdisk100
You can use # redefinevg -d hdisk100 myvg
to synchronize the ODM with the information of the VGDA. You can also synchronize the VGDA with the information stored in the ODM: # synclvodm myvg
How to set a static routes in AIX
You can use the route command to set a static route. But this way you don't get it back after reboot. To make a route persistent you need to change inet0. First check which routes are already set: # lsattr -El inet0 -a route route net,-hopcount,0,,0,192.168.1.1 Route True route net,-hopcount,255.255.255.128,,,,,192.168.3.155,192.168.2.1 Route True
These routes would be set with: # chdev -l inet0 -a route=net,-hopcount,0,,0,192.168.1.1 # chdev -l inet0 -a route=net,-hopcount,255.255.255.128,,,,,192.168.3.155,192.168.2.1
To remove these specific static routes: # chdev -l inet0 -a delroute=net,-hopcount,0,,0,192.168.1.1 # chdev -l inet0 -a delroute=net,-hopcount,255.255.255.128,,,,,192.168.3.128,192.168.2.1
In this route string 255.255.255.128 is the netmask, 192.168.3.128 the destination net, and 192.168.2.1 the gateway. For hostroutes the keyword net has to be replaced with host.
Scenario:1. There is a Single path VIO which is having a VG with 3 hdisks(hdisk1, hdisk2,hsisk3) of same size.2. An lv (lpar1_rootlv) has been createdon hdisk1 and mapped to client lpar1.3. An lv (lpar2_rootlv) has been created on hdisk2 and mapped to client lpar24. Hdisk3 is free5. Hdisk2 is about to fail and showingerror in errpt in client partition lpar2, which is rootvg of lpar26. Present Lpar2 is up and running7. Now hdisk2 has to be replaced with hdisk3 with all the data.
or you can mirror the lpar2_rootlv only on vio via command mklvcopy
# oem_setup_env# mklvcopy lpar2_rootlv hdisk3# After this command LV state must be “open/syncd”. If not use syncvg -l lpar2_rootlv command.# rmlvcopy lpar2_rootlv 1 hdisk2
Approach 2: migrate the data from bad disk to another one on vio server:
on VIO# oem_setup_env# migratepv hdisk2 hdisk3
And, That’s it.The rest is the same on both cases:on VIO:
chuser -a rlogin=true username Enable user to login remotely to server
mkuser praveen Creates user si with default values in /usr/lib/security/mkuser.default
passwd To change password of current user
passwd username To change password of a user
pwdadm username To change password of a user by security (admin) member
mkuser su=false username Create user without su facility
rmuser username To remove a user
rmuser -p praveen To remove user praveen and his all attributes
who List users with tty nos and ip numbers
who /var/adm/wtmp Lists history of login logout system startup and shutdown
last root All previous login and logoff time of root user
who -r To list the current run level ( cat /etc/.init.state )
whoami show current user
who am i To list the exact user (who -m) ( ie. difference between su and su - After su shows previous username bcoz environment not set for current user and su - shows current username bcoz environment has been set)
mkgroup dcm To create the group dcm
chgroup users=user1,user2,user3 dcm To add users user1,user2 and user3 to dcm group
rmgroup dcm To delete the group dcm
chauthent To change the authentication methods
chuser unsuccessful_login_count=0 username To change the unsuccessful login count
pwdck -t ALL / Username To verify user passwords ( Report error and ask to fix it)
usrck -t ALL / Username To verify user definition.
grpck -t ALL / groupname To verify a group
Print commands in AIX
switch.prt -d to Display current print subsytem (AIX, System V, BSD)
switch.prt -s AIX to change current print subsytem to AIX
switch.prt -d systemV to change current print subsytem to systemV
qprt -P qname filename To submit print jobs (AIX Printing)
qprt -P:lp1 filename To submit a print job if multiple queue / printer is there
qprt -N No. of print copy required
qchk -q To display the default q
qchk -P lp0 To display the status of the printer lp0
qchk -# 123 To display the status of job number 123
qchk -A To display the status of all queues (AIX Printing)
qcan -x 123 To cancel the print job 123 (AIX Printing)
qcan -X -P lp0 To cancel all jobs submitted to lp0 (AIX Printing)
cpio -icvdumB < /dev/rmt0 Restores cpio archive from rmt0
cpio -ivt < /dev/rmt0 List the contents of cpio archive from rmt0
cpio -icvd < /dev/rmt0 /home Restores /home directory from rmt0
tar -cvf /dev/rmt0 /home Archives /home to rmt0 device
tar -tvf /dev/rmt0 List the archives in rmt0
tar -xvf /dev/rmt0 /home Extract /home from rmt0
dd if=file1 of=file2 conv=ebcdic Convert and copy ascii file to ebcdic file2
dd count=1 bs=4k skip 31 seek=1 if=/dev/hd4 of=/dev/hd4 copy 31st block and paste to 1st block in the hd4 ( ie.to fix currupted superblock by restoring it's backup copy to original location)
dd if=/dev/rmt0 ibs=512 obs=1024 of=/dev/rmt1 To copy blocks from rmt0 with 512 blocks to rmt1 with 1024 blocks
tctl -f /dev/rmt0 rewind To rewind the tape
tctl -f /dev/rmt0 offline To eject the tape
tctl -f /dev/rmt0 status To show the status of tape
tcopy /dev/rmt0.0 /dev/rmt1.0 to copy contents of 1st tape(tape0) to
2nd tape(tape1). It is useful when the size of the tapes are different.
tcopy /dev/rmt0 to show no. of files and block size in the tape
chdev -l rmt0 -a block_size=512 To change the block size of the tape to 51201
******************
Posted by Praveen K at 12/02/2009 05:15:00 AM 0 comments Email This BlogThis! Share to Twitter Share to Facebook Share to Google Buzz Labels: AIX, Commands
Tuesday, December 1, 2009
How to's in AIX
1) How to disable telnet in AIX
#vi /etc/inetd.conf
comment out telnet from this file (#telnet ... ... .. )
save it and
#refresh -s inetd
Then telnet session will be disabled in that server from now.
oslevel -s : display the currently installed service pack level in AIX
find /apps -print | backup -i -v -f /dev/rmt0 : copy the contents of /apps to tape in AIX
who : display currently logged users
ln -sf /usr/lib/boot/unix_64 /unixln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unixbosboot -ad /dev/ipldeviceshutdown -Fr : reconfigure an AIX system from a 32-bit kernel to a 64-bit kernal.
oslevel -rl 5300-06 : show which filesets still need to get new technology level 5300-06 after AIX upgradation
chnfs -n 100 -B : increase the number of system threads allowed to access NFS mounts to 100
./myscript > /tmp/myoutput 2>1 : run myscript and redirect stdout and stderr to /tmp/myoutput
installp -C : to cleanup improperly applied filesets ( interrupted)
lppchk -c : to verify all the filesets installed completely
lppchk -v : verify that the operating system(AIX) is in a consistent state after installing AIX technology level ( to verify all filesets are installed completely)
refresh -s inetd : to restart TCP/IP
chvg -Qn testvg : disable quorum in testvg
smit update_all : to apply system to latest technologic level from CD.
migratepv -l /dev/testlv hdisk1 hdisk2 : move (migrate) testlv from hdisk1 to hdisk2
migratepv hdisk1 hdisk2 : move all data from hdisk1 to hdisk2
lsfs -q /testfs : to check the size of /testfs and the LV mounted on it. i.e how much space required by the FS to reach as that to LV in it.
last To list all the records in the /var/adm/wtmp file (all successful logins)
last shutdown To show the time of previous shutdown of server.
last reboot To show the time of previous reboot of server.
uptime To show how long the system has been up ( w -u )
oslevel To list the operating system level
lslicense To see the number of license
chlicense -u30 To change the fixed user license to 30
chlicense -f on To enable floating user license
lsmcode To check system firmware version (sys0)
invscout To get firmware of all peripheral devices. It will generate the output in /var/adm/invscout/invs.mrp containing the firmwares of all peripheral devices.