Aix
Aix
Aix
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
Introduction Hardware command Diagnosing Harware problem System information Software packaging and Maintenance Level Monitoring and system performance User administation Managing files and directories Boot an AIX fom NIM and HMC - boot problem Miscellanous command VI Transforming and converting files Tape util AIX script ftp Server X CD-ROM - DVD-ROM DHCP/FTP/LOGS/DNS/NTP/rc.tcpip daemons See unused hdisk and create new volum group lsof
1 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
Boot problem Recreating the boot logical volume Tipes Tutorials Install Java
Introduction AIX is an IBM version a Unix system V. To see more on this system clic on AIX to see wikipedia explain. In this tutorial only a few options are listed for a command, for more information about a command use "man <command>" Top
Hardware command lsdev Displays devices on the system and their characteristics lsdev -Cc adapter Display information about adapter lsdev -Cc disk Display information about disk lsdev -c | grep ent Display information about netwok adaptater lsvg Diplays information on a volume group lsvg -o Displays volume group active lsvg -l rootvg Displays the status of disks lspv Displays information about a physical volume within a volume group lspv hdisk0 mkvg Creates a volume group mkvg -y datavg hdisk1 hdisk2 lsfs Displays the filesystems and their characteristics lsattr Displays information about the attributes of a given device lsattr -El sys0 -a realmem (amount of ram)
2 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
cfgmgr command is used to onfigure devices and, optionally, install device software into the system mkdev To create a new device mkdev -vadapter vhost2 -vdev hdisk17 -dev disk17_data rmdev To delete a device rmdev -d1 scraid1 To delete scraid1 device rmdev -l pdisk8 To change the device state from Available to Defined rmdev -l pdisk8 -d To delete pdisk8 device fsck To make a file check after a disk problem fsck -y /dev/fslv00 Check disk without prompting lsmcode Displays microcode and firmware levels of the systemTo make a file check after a disk problem fuser Identifies processes using a file or a file structure fuser /etc/passwd fuser -c /home/ See all the PID using the ressource lsvgfs Display a list of file systems belonging to a volume group lsvgfs rootvg
Top
Diagnosing Harware problem errpt command to etrieve an error record from the error log (errpt -a) errclear to delete entries from the error log (errclear -0) diag command is the starting point to run a wide choice of tasks and service aids that are used to perform hardware problem determination To log system messages, AIX uses syslogd. The syslogd daemon reads a atagram socket and sends each message line to a destination described by the /etc/syslog.conf configuration file. to start it use startsrc -s syslogd to stop it use stopsrc -s syslogd to see if the service is running use ps -ef | grep syslogd snap To make an image for the system configuration for the support snap -r To supress the old snap snap -gc To create a snap for the support
3 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
Top
System information prtconf | more Print system information lstattr -EL -l sys0 To display system level attribute lsattr -El sys0 -realmem Display amout of ram lsattr -l rmt0 -E To list the current values of the attributes for the tape device, rmt0 lscfg Detailled configuration of my system lscfg | grep proc Display number of processor oslevel Returns the major level of the OS oslevel -r Returns the detailled level of the OS oslevel -s To see which service pack is currently installed uname -a Type of the machine unmae -uM Type of the machine and serial number oslevel Reports the latest installed maintenance level of the system (VIO) lspv To display the number of hard disks on your system lspv hdisk1 To find details about hdisk1 lsconf To document the machine bootinfo Reports some system information bootinfo -r How much memory does machine have bootinfo -y Display if the hardware is 32 or 64 bit http://www14.software.ibm.com/webapp/set2/flrt/home Provides minimum recommended fix level Top
Software packaging and Maintenance Level oslevel oslevel -q (List filesets of known technology) oslevel -r (Applies all flags to tehnology levels) oslevel -sq (List all know service pack) installp to install additional software or PTF (Program Temporary Fix) instfix to list, update or update an individual fix instfix -i | grep ML Show what fileset are found for maintenance release and if they are complete insfix -ik <fix> Show if a particular fix is installed on the system lslpp to view the maintenance level
4 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
lslpp -l lslpp -l <fileset> to see information about a fileset (fileset -l bos.iconv.ucs.com) lppchk -v Show fileset that are incompletly installed lscfg -vp | grep alterable Show firmware level Top
Monitoring and system performance Nagios an open source program to monitor all your systems topas to see in "real time" system stats (CPU, IO etc...) nmon a free tool to analyse AIX and Linux performance iostat Reports CPU and I/O statistics vmstat Reports virtual-memory activity and other system statistics netstat Displays the contents of network-related data structures ps Displays the status of processes lsattr Displays the attributes of devices lslv Displays information about a logical volume or the logical volume allocations of a physical volume nfsstat Displays statistics about Network File System (NFS) and Remote Procedure Call (RPC) activity nice Runs a command at higher- or lower-than-normal priority no Displays or sets network options renice Changes the priority of one or more processes reorgvg Reorganizes the physical-partition allocation within a volume group sar Collects and reports or records system-activity information schedtune Sets parameters for CPU scheduler and Virtual Memory Manager processing svmon Captures and analyzes a snapshot of virtual memory time Prints the elapsed execution time and the user and system processing time attributed to a command tprof Reports CPU usage for individual programs and the whole system trace Records and reports selected system events filemon To find out the busy filesystems and files
The following AIX performance tools provide general information and metrics related to performance.
CPU Monitoring
5 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
vmstat, topas, ps, lsps, ipcs vmstat, topas, iostat, lvmstat, lsps, lsatt/lsdev, lspv/lsvg/lslv netstat, topas, atmstat, entstat, tokstat, fddistat, nfsstat, ifconfig ps, pstat, topas
Top
User administration User administration command mkuser Creates a new user smitty mkuser passwd Creates or changes the password of a user chuser Changes user attributes (except password) lsuser Lists user attributes rmuser Removes a user and its attributes chsec Changes security related stanzas login Initiates a user session who Identifies the users currently logged in dtconfig Enables or disables the desktop autostart feature User administration files /etc/security/environ Contains the environment attributes for users /etc/security/lastlog Contains the last login attributes for users /etc/security/limits Contains process resource limits for users /etc/security/user Contains extended attributes for users /usr/lib/security/mkuser.default Contains the default attributes for new users /usr/lib/security/mkuser.sys Customizes new user accounts /etc/passwd Contains the basic attributes of users /etc/security/passwd Contains password information /etc/security/login.cfg Contains configuration information for login and user authentication /etc/utmp Contains the record of users logged into the system /var/adm/wtmp Contains connect time accounting records /etc/security/failedlogin Records all failed login attempts /etc/motd Contains the message to be displayed every time a user logs in to the system /etc/environment Specifies the basic environment for all processes
6 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
/etc/profile Specifies additional environment settings for all users $HOME/.profile Specifies environment settings for specific user needs /etc/group Contains the basic attributes of groups /etc/security/group Contains the extended attributes of groups Top
Managing files and directories cd Change directory ls Display the content of a directory ls -la Display the content of a library long format ls -latr Display the content of a library in chronogical order cat Display, create, copy, concat a file cat file.input Display file.input cat file1.input file2.input > file.outpout Concat file1 et file2 more Display each page of a file cp Copy files or directories mv Move or rename file grep Search a string in a file grep -r "text" /tmp Search the string text in the /tmp directory wc Count word, line in a file ln Make a hard or soft link of a file touch Create an empty file find Find a file find . -name "text.txt" Find the file text.txt find . -name "*.txt" | xargs -n1 ls -la Find the files *.txt if there is too many occurences find . -name "text*" | xargs rm Find all the file with the argument text* and remove it find . -type f -mtime +10 | xargs -n1 rm Find all files older than 10 days and remove it chmod Modify the permission of a file or directory chmod ugo+rwx Set the permission for user - group - other + Read - Write - execute chown Change the owner of a file or directory chown user file chgrp Change the group of a file or directory chgrp group file cut Cut certain colonn of a file head Display the head of a file sdiff Display the difference between two files
7 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
sort Sort the content of a file tail Display the last lines of a file tail -f /var/log/error.log Display in "real time" the content of a log file mkdir Make a directory rmdir Remove a directory nl Number lines in a file nl -ba file.txt Top
Boot an AIX from NIM and HMC - boot problem Define the machine on NIM smitty NIM Perform NIM Adimistration Tasks Manage Machines Define a machine NIM Machine Name (machine name) Machine Type (standalone) Hardware Platform Type (chrp) Cable Type (bnc) NIM Network (Nim network Name) Host Name (host name) Network Adapter Hardware (Network Adapter Adress) The network adress can be found booting in SMS Mode -Setup Remote IPL Perform NIM AdministrationTasks Manage Machines Perform Operations on Machines Machine name maint_boot = enable a machine to boot in maintenance mode SPOT (spot name) Boot from HMC in maintenance Mode In advanced option boot on SMS Choose open a terminal 5. Select Boot Options 1. Select Instal/Boot device 6. Network 1. Virtual Ethernet 3. Normal Mode Boot
8 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
1. Access a Root Volume Group 2) Volume Group.... 2) Access this Volume Group and start a shell before mounting filesystems Also you can make some intervention on disk fsck -y /dev/hd1 mount /dev/hd1 ... Top
Miscellanous command who Display the connected users whoami Display the current user connected man Display manual of a command man ls df Display information about total space and available space on a file system du Display the file space usage chfs Change attributes of a file system chfs -a size=+500M /usr su Change the current user connected su - user lp Sent a file to the spooler lpr Sent a file to the spooler wget Wget is a free utility for non-interactive download of files from the Web.
wget -b ftp://ftp.arcudi.org/file.tar.gz Download the file.tar.gz in backgroup
lastreboot See when the system is rebooted the last time gzip Compress a file gzip file.tar Create a compressed file file.tar.gz gzip -d Unpack a *.gz file Uncompress a file.tar.gz file tar cvf - directory/ | gzip > toto.tar.gz Create a compressed tar file in a single command zip Compress a file tar Archive a file tar -tvf file Verify the content of a tar file tar -xvf file Unpack a tar file tar -c file repertory Create a tar file tar -cvfX file.tar exclude.txt /tmp/toto/ Create a tar file exluding directories that are present in the exclude.txt file tar cvf - directory/ | gzip > toto.tar.gz Create a compressed tar file in a single command
9 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
history See the last command entered nl Number lines in a file nl -ba file.txt lssrc See the status of a subsystem lssrc -ls dhcpsd Top
Vi VI Esc To switch between insert or command mode Insert mode a Insert text after the cursor i Insert text before the cursor I Insert text of the top of the line A Insert text of the bottom of the line x Supress a character o Insert text in the next line O insert text in the previous line r Replace the current character R Edit the current line in typeover cc Change line cw Change word C Change from current position to the end of line dw Delete a word from the cursor position dd Delete the line and place to the buffer yy Copy line in the buffer p Copy the content of the buffer after the current line P Copy the content of the buffer before the current line Position command l Go right h Go left k Go up j Go down b Go a word left w Go a word right $ Go to the end of the line
10 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
O Go to the top of the line :24 Go to line 24 gg or 1G Go to the first line of the document G Go the last line of the document Global Comand / Search string :1,$s/a/b/g Replace character b from a, from the 1st line to the end of a file :r Insert a file at the position of the cursor :q! Quit without saving a fle :w Write a file :wq Write and quit a file Top
Transforming and converting files Here are listed some "utilities" with example to transform files. tr tr '\332' '012'< file.input > file.output To transform character 'DA' (hex) to '0A' (hex). The value 332 and 012 are in octal tr -d '\025' < file.input > file.output To delete the character '15' (hex). The value 025 are in octal tr 'A-Z' 'a-z' < file.input > file.output To transform upercase to lowercase
tr '' 'aceeeeiioouuACEEEEIIOOUU' < file.input > file.output
sed sed perl perl -pe 's/\332/\012/g' < file.input > file.output To transform character 'DA' (hex) to '0A' (hex). The value 332 and 012 are in octal perl -pe 's/\332/\015\012/g' < file.input > file.output To transform character 'DA' (hex) to '0D0A' (hex. Thel value 332, 015 and 012 are in octal. perl -n -e 'chop; printf "%-120s\n",$_;' < file.input > file.output To transform a file with a Carriage Return at the position 120 perl -e '1,2d' < file.input > file.output To suppress the first two line of a file perl -e 'while (read(STDIN, $l, 160)){printf "%s\n",$l;}' < file.input >file.output To add a
11 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
carriage return at the position 160 iconv To convert from one encoding to another encoding iconv -f ISO8859-1 -t IBM-850 file.input > file.output To convert file from ISO8859-1 to IBM-850 encoding awk ls -la * | tail -1 | awk '{print $9}' To display information of the colon 9 in a ls command ls -ltr | grep "Jan 24" | awk '{print $9}' | xargs -n1 -i cp {} /work/toto/ dd dd if=/tmp/file.input of=/tmp/file.output conv=ascii To convert input file from bin to ascii Sript to transform "dos file" to Unix (in particular ^M) #!/usr/bin/ksh if [ $# -ne 1 ] then echo "Usage: $0 filename" exit fi sed 's/^M$//' $1 > tmp mv tmp $1 chmod 755 $1 Tips to transform Dos file to Unix # to convert DOS file to Unix in place: perl -i -pe 's/\r//g' file # Unix to DOS: perl -pe 's/$/\r/g' < infile > outfile # Unix to DOS in place: perl -i -pe 's/\n/\r\n/' file # to check for <CR> : perl -ne 'print if /\r/' < infile Top
Tape Util tapeutil To run the menu version /dev/rmt0 = Tape drive
12 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
/dev/smc0 = Tape library lsdev -Cc tape List the devices tapeutil -f /dev/rmt0 mount 2 To mount tape from slot 2 tapeutil -f /dev/rmt0 unmount 2 To unmount tape from slot 2 restore -Tvqf /dev/rmt0 > file To list information on a tape saved with backup or savevg tar tvf /dev/rmt0 > file To list information on a tape saved with tar tcl -f /dev/rmt0.1 fsf 3; restore -Tvqf /dev/rmt0 > file To list information on a tape saved with mksysb lsattr -l rmt0 -E To list the current values of the attributes for the tape device, rmt0 Top
aix script (examples) Script to compare condition with "or" "and" condition condition1= $(ls -la | /tmp/file2.txt | wc -l) condition2 = $(ls -la | /tmp/file2.txt | wc -l) if [ "$condition1" = "1" ] || [ "$condition2" = "2" ] then echo "ok 1 or 2 is accepted" else echo "error only 1 or 2 is accepted" if [ "$condition1" = "1" ] && [ "$conditions2" = "2" ] then echo "ok 1 and 2 is accepted" else echo "error only 1 and 2 is accepted" Top
Server X Start a server x ps -ef | dtlogin (identifiy all the process dtlogin) kill <PID> (kill the process from the result of the ps command) cd /etc sh rc.dt (Start the server X) Top
CD-ROM - DVD-ROM
13 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
CD-ROM utility cdromd Automatically mounts a CD-ROM or DVD-ROM when it is inserted (man cdromd for more details) cdeject Eject a media from a CD drive managed by the cdromd daemon cdumount Unmounts a previously mounted file system on a device managed by cdromd cdmount Make a file system available for user on a device managed by cdromd mount -V cdrfs -o ro /dev/cd0 /cdrom Mount a cd-rom Top
DHCP/FTP/LOGS/DNS/NTP/rc.tcpip daemons DHCP config file /etc/dhcpsd.cnf start/stop/refresh startsrc -s dhcpsd stopsrc -s dhcpsd refresh -s dhcpsd FTP start/stop startsrc -s ftp stopsrc -s ftp LOGS config file /etc/syslog.conf start/stop/refresh startsrc -s syslogd stopsrc -s syslogd refresh -s syslogd DNS library where config files are stored (we have two files to configure) /var/named start/stop/refresh startsrc -s named stopsrc -s named refresh -s named NTP /etc/ntp.conf
14 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
start/stop startsrc -s xntpd stopsrc -s xntpd rc.tcpip daemons (Many network daemons are started from /etc/rc.tcpip) config file /etc/rc.tcpip Top
See unused hdisk and create new volum group This "procedure" is used to see the content of an unused disk on AIX and create a new volum group from this unused disk lspv (To display information about a physical volume within a volume group) importvg <disk> (Imports a new volume group definition from a set of physical volumes) importvg hdisk0 lsvg -l <logical volume> (Displays information about volume groups) lsvg -l vg00 varyoffvg <volume group> varyoffvg vg00 exportvg <volume group> ( Exports the definition of a volume group from a set of physical volumes) exportvg vg00 mkvg -f -y <volum group> <disk> (Create a volume group forcing the volume group to be created on the specified physical volume) mkvg -f -y datavg hdisk0 Top
lsof lsof is a useful command to list open files When lsof is called without parameters, it will show all the files opened by any processes.
lsof
15 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
Show what files are opened by processes whose names starts by "s" (smb...).
Show what files are opened by processes whose names starts by "smb", but exclude those whose owner is the user "toto":
lsof -u toto
lsof +p 86397
Search for all opened instances of directory /tmp and all the files and directories it contains:
lsof +D /tmp
16 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
List all opened internet sockets and sockets related to port 80:
lsof -i -U
Show what process(es) has an connection opened to or from the host www.arcudi.org :
Top
Boot problem Here some useful commands in case of boot problem. See also the procedure to boot the machine in maintenance mode (boot an AIX from NIM and HMC - boot problem) and the procedure recreating the boot logical volume Display information about volume groups
17 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
ipl_varyon -i Display and alters the list of boot devices available to the system
bosboot -ad /dev/hdisk0 Create boot image, the boot record, and the service record
chpv -c hdisk0 Synchronizes or rebuilds the logical volume control block synclvodm rootvg hd5 See detailled information about a volume lqueryvg -Avtp hdisk0 Display attribute characteristics and possible values of attributes for devices lsaltr -El hdisk90 Top
18 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
After booting from CD, tape or NIM an Installation and Maintenance Menu is shown and you can startup the maintenance mode. After accessing the rootvg, you can repair the boot logical volume with the bosboot command. You need to specify the corresponding disk device, for example hdisk0: bosboot -ad /dev/hdisk0 It is important that you do a proper shutdown. All changes need to be written from memory to disk. The bosboot command requires that the boot logical volume (hd5) exists. If you ever need to re-create the BLV from scratch, maybe it had been deleted by mistake or the LVCB of hd5 has been damaged, the following steps should be followed: 1. Boot your machine in maintenance mode (from CD or tape (F5 or 5) or use (F1 or 1) to access the Systems Management Services (SMS) to select boot device). 2. Remove the old hd5 logical volume. # rmlv hd5 3. Clear the boot record at the beginning of the disk. # chpv -c hdisk0 4. Create a new hd5 logical volume: one physical partition in size, must be in rootvg and outer edge as intrapolicy. Specify boot as logical volume type. # mklv -y hd5 -t boot -a e rootvg 1 5. Run the bosboot command as described on the visual. # bosboot -ad /dev/hdisk0 6. Check the actual boot list. # bootlist -m normal -o 7. Write data immediately to disk. # sync # sync
Top
Tipes
Find big files on a system
If you want to see big files on a system you can use this following procedure (do not use it in / as it will find all the big files on a system) : ls -asR |sort -nr |nawk '/total / {size=($2*1024) /1024000;print ""; printf "Total %6.3fMB ",size;print ""; exit}; {size=($1*1024)/1024000;printf "%4.3fmg %s",size,$2;print ""}' |pg
19 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
If you want to check directories permissions : find /work/toto -prune -type d -perm -777 -exec ls -ld {} \;
How to sort by file size using ls and sort du -g | sort -nr | more Top
Tutorials Here you can find some very good tutorials on virtualization, hardware, vio and similar things:
ftp://ftp.software.ibm.com/systems/power/community/aix/AIX_Movies/ Top
Install Java This install is for the version 1.6 http://www-128.ibm.com/developerworks/java/jdk/aix/service.html Choose the packet Java6.sdk.tar (for installp) gunzip -d Java6.sdk.tar.gz tar -xvf Java6.sdk.tar inutoc . smitty installp . To preview Preview yes
20 of 21
http://www.arcudi.org/joomla_25/index.php/aix-personal-...
no yes yes
Accept new licence agreement To Install Preview Commit Save replace no no yes
yes
Top
21 of 21