#aix #linux #unix #ksh #kornshell #who #pwd #uptime #ps #process #pid #netstat #wc #lsattr #uname #bootinfo #lsmcode #lscfg #od #bc #usysdefault #oslevel #lsmcode #find #grep #last #enq #find #shellscript #mount #bffcreate #lpstat #printer #printqueue #printers #installp #install #installatie #### **Getting the State of Devices** To list all connected devices: `lsdev –C` (See also: [[Hardware information in AIX]]) Example output: `sys0 Available 00-00 System Object sysplanar0 Available 00-00 System Planar pci0 Available 00-fe0f0020 PCI Bus pci1 Available 00-fe0f0090 PCI Bus ... hdisk0 Available 10-10-00-0,0 Bull 9.1 GB 16 Bit SCSI Disk Drive cd0 Available 10-18-00-6,0 Bull Multimedia CD-ROM Drive` #### **Check Tape Drives** To list all tape drives and their status: `lsdev -Cc tape` Example output: `rmt0 Available 10-18-00-5,0 Bull 12/24 GB 4mm Tape Drive rmt1 Available 15-10-00-2,0 Other SCSI Tape Drive` #### **Check SCSI Adapters** To list all SCSI controllers: `lsdev -C | grep scsi` Example output: `scsi0 Available 10-10 Wide/Ultra-2 SCSI I/O Controller scsi1 Available 10-18 Wide/Fast-20 SCSI I/O Controller` #### **Check ARTIC960 PCI Adapter** `lsdev -C | grep ric` Example output: `riciop0 Available 2C-08 IBM ARTIC960 PCI Adapter` --- ### **Reporting Filesystem Space** To check filesystem space usage: `df` Example output: `Filesystem 512-blocks Free %Used Mounted on /dev/hd4 1015808 916320 10% / /dev/hd2 5013504 3104352 39% /usr /dev/hd9var 1409024 1354872 4% /var` For a **kilobyte-based** output: `df -k` KopiërenBewerken `Filesystem 1024-blocks Free %Used Mounted on /dev/hd4 507904 458144 10% / /dev/hd2 2506752 1552176 39% /usr` --- ### **Viewing the AIX Error Log** The error log file is located in: `cd /var/adm/ras ls -lra` Example of error log file: `-rw-r--r-- 1 root system 179131 Sep 28 15:02 errlog` To display detailed system errors: `errpt -a` Example output: `LABEL: SCSI_ERR10 IDENTIFIER: 0BA49C99 Date/Time: Mon Jul 17 11:32:05 Resource Name: scsi3 Description: SCSI BUS ERROR Recommended Actions: CHECK CABLE AND ITS CONNECTIONS` --- ### **Generating a System Snapshot** To collect AIX system information (for troubleshooting): `snap -a` This generates logs in the `/tmp` directory (approx. **20MB** in size). --- ### **Managing NetBIOS in AIX** If NetBIOS/X daemons fail to start properly, use **smit**: `smitty` Then navigate to: `Communications Applications and Services NetBIOS/X NetBIOS/X Management Start NetBIOS/X Stop NetBIOS/X` - If NetBIOS/X is already running, you will see: **"NetBIOS/X has already been started"** - If it was stopped, starting it will either succeed or show a **clear error message**. --- ### **Fixing Fibre Channel (FC) Issues** If you encounter **hdisk-1** or **hdisk-2** instead of expected disk names, it may indicate: - Missing or incorrect `iospcds.rhd` configuration. - Incorrect GCOS disk detection. - Connection issues with the **FC adapter** and disk subsystem. #### **Reconfiguring AIX Fibre Channel** 1. Remove Fibre Channel devices: `rmdev -Rdl fchan0 rmdev -Rdl fchan1 rmdev -Rdl fchan2 rmdev -Rdl fchan3` (This may take a few minutes as all connected disks will be removed.) 2. Rebuild AIX configuration: `cfgmgr` - If **FCP (Fibre Channel Protocol) is not created**, there may be a **driver or firmware issue**. Quick Logout: CTRL + D Check Who Is Logged In: who -u who am i Check If a Specific User Is Logged In: ps -ef See All Processes of a User: ps -u <username> Check When the System Was Last Started: who -b Use uptime to see how long the machine has been running. Check Who Was Logged In, When, and for How Long: who -a /usr/adm/wtmp Count the Number of Directories: ls -al | grep "^d" | wc -l (^d matches everything that starts with d.) List Files: ls Execute Two Commands on One Line: who am i; date (Separate with ;, similar to && in DOS.) Go to Your Home Directory: cd See Which Directory You Are In: pwd Get Information About Yourself: w Search for Commands/Files: whereis <command/file> Example: whereis motd Network Information: netstat -v Redirect Output to a File: ls > filelist To redirect errors to a different file: ls > filelist 2> errorlist Terminate a Program: A program can be stopped by typing ^C. If this key is mapped to another function, find out using: stty -a Look for intr =, which shows the assigned key, e.g., ^C. Merge the Contents of Multiple Files into One: cat file1 file2 > file3 View Binary Files: Use the od (octal dump) command: od -bc <filename> Example: $ od -bc example 0000000 166 157 157 162 142 145 145 154 144 012 v o o r b e e l d \n (\n represents a newline.) Count the Number of Words in a Text File: wc -w <textfile> Other options: wc -l → Count lines wc -c → Count characters Count the Number of Files in a Directory: ls | wc -l Links: Create a Hard Link: ln <file1> <file2> Copy Multiple Files to a Directory: cp file1 file2 file3 ... <directory> Copy an Entire Directory: cp -r <source_dir> <target_dir> ⚠️ Be Careful with rm * Using rm * can be dangerous. If you mistakenly type a space (e.g., rm * .o), you could delete many files. To prevent accidental deletions: Create a file named -i in important directories. If rm * is executed, it expands to rm -i a b c ..., prompting for confirmation. To delete the -i file: rm ./-i Working with Variables: Assign a value to a variable: var=<value> Read the value: echo $var Example with spaces: myvar='*Hello World*' echo $myvar Output: *Hello World* (Use ' ' for values containing spaces.) Pipelines & Command Chaining: Commands can be linked using: ; → Execute one after another. & → Run the left command in the background, then continue. && → Execute the right command only if the left command succeeds. || → Execute the right command only if the left command fails. Script Programming Structures: If-Else Statement: if [ condition ] then command1 else command2 fi With elif: if [ condition1 ] then command1 elif [ condition2 ] then command2 else command3 fi While Loop: while [ condition ] do command done For Loop: for name in apple banana cherry do echo "*** $name ***" done Output: *** apple *** *** banana *** *** cherry *** Case Statement: case variable in pattern1) command ;; pattern2) command ;; *) default command ;; esac View Memory in AIX: lsattr -El sys0 | grep realmem or bootinfo -r Check AIX Architecture: bootinfo -p If it returns chrp, it's PowerPC. Check Processor Type: uname -p Check AIX Version: oslevel -r Check If Hardware is 32-bit or 64-bit: bootinfo -y Check the Machine Model: uname -M (e.g., IBM 7044-170) Check If a File Is in Use: fuser -c <filename> Example for checking if a CD-ROM is in use: fuser -c /dev/cd0 View Microcode (Firmware) Version: lsmcode Create a System Backup: mksysb mksysb /dev/rmt0 Check PCI Slots and Installed Devices: lsslot -c pci View System Information: lscfg Check an AIX Machine’s Serial Number: uname -m Turn Off Indicator Lights After a System Crash: usysdefault -s normal Mount a CD-ROM: mount -V cdrfs -o ro /dev/cd0 /cdrom Unmount: umount /cdrom Check mounted filesystems: mount Install a Fix (Patch): instfix -k IY73748 -d /dev/cd0 Check if a fix is installed: instfix -ik IY24043 List Installed Network Cards: lsdev -Cc if Activate/Deactivate a Network Card: ifconfig en0 up ifconfig en0 down View Active TCP/IP Connections: netstat -an | grep 192.168.113 Check logged-in users: who See what a user is doing: ps -ef | grep pts/6 Find All Queues That Are Down in AIX: enq -As | grep DOWN Check the Last 5 Logins of a User: last root -5 (This information is retrieved from the file /usr/adm/wtmp.) Show the Last 25 Executed Commands: history -25 Disable set -o vi: set +o vi iptrace - Debug Trace Utility for IP Packets Example What it does iptrace -a -s 193.0.0.1 -i en0 network.log Logs all TCP/IP packets originating from 193.0.0.1 via Ethernet interface en0 into network.log. ipreport - Generate a Packet Trace Report from iptrace Example What it does ipreport network.log Displays trapped packets from an iptrace session in ASCII format. The iptrace process must be terminated before running this command. Check Print Queues and Their Status: lpstat -t Check if the Spooler is Running: lssrc -g spooler Example output: Subsystem Group PID Status qdaemon spooler 49512 active writesrv spooler 98708 active lpd spooler inoperative (This also shows the PIDs.) Generate a List of Users: lsuser -c -a id home ALL | sed '/^#.*/d' | tr ':' '\011' | sort -k1 > list View a Log File Continuously: tail -f <logfile> Check Who Logged In and When: last To check a specific user’s login history: last <username> Backups Create a System Backup Before Updates Before making any system updates, always create a smit mksysb backup to ensure the system can be restored if something goes wrong. Command: mksysb When applying an update, bring the system down to maintenance mode with: shutdown -Fm This ensures no one else can interfere during the update process. Ensure the following file systems are mounted before updating: / /tmp /usr If the system was preloaded with installable images under /usr/sys/preload, do the following: Backup these images to tape for later reference (optional). Remove the /usr/sys/preload directory and its contents. Check Running Services: lssrc -a To list only active services: lssrc -a | grep active To stop a running service before updating: stopsrc -g <SubSystem Group> stopsrc -s <SubSystem Name> Some services (e.g., DOS SERVER) may require manual termination using: kill <PID> If not stopped, the LPP (Licensed Program Product) update may fail. bffcreate - Extract Installation Images Example What it does bffcreate -qv -d/dev/rmt1.1 -X pci sna snamEn_US Extracts pci, sna, and snamEn_US backup images from tape /dev/rmt1.1 into /usr/sys/inst.images (default installation directory). bffcreate -qv -d/dev/rmt0.1 -X all Extracts all images from tape to /usr/sys/inst.images. instupdt - Install, Reject, or Update Licensed Program Products (LPPs) Example What it does instupdt -r Rejects applied but uncommitted updates. Use this if an LPP update failed. lslpp -l Checks if an LPP is installed or in another state. instupdt -qI -d/dev/rmt0.1 -v -X -F bosadt.xde.obj bosadt.xde.obj Installs bosadt.xde.obj from tape. The -F flag forces downgrade installation if needed. instupdt -qI -d/dev/rmt0.1 -v -X bosnet.tcpip.obj Installs bosnet.tcpip.obj for the first time. installp - Install and Manage LPPs Example What it does installp -C Cleans up after a failed LPP installation. installp -c -g -X all Commits all applied LPPs or PTFs. installp -s Lists LPPs that are applied but not yet committed or rejected. lppchk - Verify LPP Integrity Example What it does lppchk -c bosext2.dosutil.obj Verifies checksum and length of dosutil.obj. lppchk -v Checks for missing PTFs or incorrect states. lppchk -f bos.obj Ensures all files in the specified LPP exist and are correctly sized. PowerChute UPS Configuration for RS/6000 The RS/6000 system has two serial ports (tty0 or tty1) for connecting an APC UPS. You need to disable the tty port: pdisable tty0 Configure using SMIT: smit tty Select Change/Show characteristics Choose the correct port (tty0 or tty1) Set the baud rate to 2400 Find Command Examples Command What it does find / -name jan92.rpt -print Search all file systems for jan92.rpt. find / -size +1000k -exec ls -l {} \; -print List all files larger than 1MB. find / -size 0 -print Find all zero-byte files. find / -user roger -print Find all files owned by user roger. `find . -perm 600 -print xargs chmod 666` find / -mtime +100 -print Find files not modified in the last 100 days. grep Command Examples Command What it does grep -i WhereIs * Search for "WhereIs" in all files (case-insensitive). `lsdev -C grep lp` grep [0-9][A-Z] *.doc Find .doc files containing a number followed by a capital letter. grep "^IBM" *.doc Display lines that start with "IBM". grep "IBMquot; *.doc Display lines that end with "IBM". grep -v "^ *quot; testfile > goodfile Remove all blank lines from testfile and save output to goodfile. head Displays the first 10 lines (default) of a file. Example: head -25 /tmp/phase2.out (Displays the first 25 lines of the file /tmp/phase2.out.) id Displays the system identity of the user. Example What it does id Displays the UID and GID of the current user. Example output: uid=0(root) gid=0(system). id -ru Displays only the UID of the current login process (0 for root). last Displays information about previous logins stored in the /usr/adm/wtmp accounting file. Example What it does `last reboot head -5` last roger Shows when user roger logged in and out. last tty0 Displays login and logout times for port tty0. login Initiates a new user session. Example: login -h rs6000 root (Logs into the root account on a machine with the hostname rs6000.) logout Terminates all processes on the current session and logs out the user. Example: logout (Logs you out of the system and returns to the login prompt.) (Note: exit performs the same action as logout.) lsitab Lists the contents of the /etc/inittab file. Example: lsitab -a lslicense Lists the maximum number of users that can log in concurrently. Example: lslicense Output example: Maximum number of concurrent users: >32 kill Sends a signal to stop or suspend a running process. Example: kill -l (Displays a list of valid signals to use with the kill command.) nl Adds line numbers to the beginning of each line in a file. Example: nl /etc/passwd > /tmp/user.list (Creates a numbered output file /tmp/user.list from /etc/passwd.) nice Runs a command at a lower priority. Higher numbers = lower priority. Only the super-user (root) can set a higher priority using negative numbers. Example What it does nice -n 15 make Runs the make command at low priority (15). nice -10 /usr/bin/mview Runs the mview application at high priority (-10). nvdmetoa Converts EBCDIC files to ASCII. Example What it does nvdmetoa <AS400.dat >AIXver3.dat Converts an EBCDIC file from an AS400 system to an ASCII file for AIX. nvdmetoa 132 <AS400.txt >AIXver3.txt Converts an EBCDIC file with 132 characters per line into an ASCII file with 132 bytes per line + 1 byte for linefeed. od Dumps file contents in ASCII, octal, hex, or extended character set. Example: od -c /tmp/rc.net.out (Displays bytes as ASCII characters.) To check function key control codes: od -cd <Press FUNCTION KEY> <Press SHIFT + FUNCTION KEY> <Press ALT + FUNCTION KEY> rmitab Removes an entry from /etc/inittab. Example: rmitab ice (Removes the ice entry from /etc/inittab.) sed Performs stream editing on text files. Example What it does sed -e "s/reports/report/" < /tmp/mytest > /tmp/mytest1 Replaces "reports" with "report" in /tmp/mytest. sed -e 's/ *$//' < SOURCE_FILE > DESTINATION_FILE Removes trailing spaces (not internal spaces) from each line in a file. sed '/total/d' /tmp/report > /tmp/report1 Deletes all lines containing the word "total". sed '/^$/d' /tmp/report > /tmp/report1 Deletes all blank lines from a file. sed 's/[ ]//g' /ibm/report > /tmp/report Removes all tabs from a file. shutdown Shuts down the system. Example What it does shutdown +0 Shuts down the system immediately. shutdown -Fr Shuts down and reboots the system. shutdown -Fm Shuts down into maintenance mode. (Only available from the console.) split Splits a large file into smaller files. Each file will have up to a specified number of lines. New filenames follow this pattern: Kopiëren Bewerken original_filename_xaa, original_filename_xab, original_filename_xac, etc. stopsrc Gracefully stops all System Resource Controller (SRC) subsystems. Example: stopsrc -a strip Removes the symbol table and debugging information from an executable file, reducing its size. Example: strip /usr/bin/uniplex su Runs a sub-shell as another user. Example What it does su roger Switches to user roger, but does not execute their .profile. su - root Fully switches to root, loading /etc/environment, /etc/security/user, and .profile. sum Displays a checksum for a file. Used to verify file integrity after transfers. Example: sum /unix tail Displays the last 10 lines of a file (default). Example: tail /tmp/phase2.out tee Captures output within a pipeline to a file for later review. Example: find . -cpio /dev/fd0 -print | tee /tmp/BACKUP.LOG (A list of backed-up files is stored in /tmp/BACKUP.LOG.) telinit Modifies the system run-level. Example What it does telinit q Forces init to re-read /etc/inittab. telinit 1 Switches to single-user (maintenance) mode (same as init 1). who Displays information about logged-in users. Example What it does who -b Shows the last reboot timestamp. who -r Displays the current run-level. who -u Shows logged-in users with activity timestamps. who -a /usr/adm/wtmp Shows login history. Files that keep growing Periodically, the following files need to be reduced in size. You can use the cat /dev/null command. Example: cat /dev/null >/var/adm/sulog Files: /var/adm/sulog /var/adm/cron/log /var/adm/wtmp /etc/security/failedlogin /var/adm/ras/errlog (use errclear with parameters) System Information ls -b (list garbage file names in octal) lscfg (lists installed devices, -v for versions, or -c) lsgroup (lists user groups) lsuser (lists users) lscons (displays the current console tty value) lsswconfig -a (lists the software catalog) lsdev -C -c <class> -H (lists devices) lsattr -l <class> -a <item> -E (for current attributes) Class values: tty, printer, tape, disk, adapter, dlc, bus, diskette, if, memory, logical_volume, mouse, port Setting 132 Columns for HP Laser Printers If you have trouble setting the column width to 132 columns for text reports, use this fix: If the default column width does not allow a value greater than 77, you need to edit the file containing the parameter limit. Edit the file: /var/spool/lpd/pio/@local/queuename (Replace queuename with the actual queue name.) Search for 77 in the file; there will likely be two entries containing {77}. Change 77 to 132. Volume Commands Definitions: PHYSICAL PARTITION (PP): Smallest unit a PV is divided into (e.g., 4 MB partition size). LOGICAL PARTITION (LP): One or more PPs. Represents a mirrored copy of a PP. Up to two copies of a PP can be mirrored, resulting in an LP count of three (two mirrors plus original). LOGICAL VOLUME (LV): One or more PPs. A file system resides on top of an LV. Only one LV is mapped to a file system. An LV cannot span across a VG. Up to 255 LVs in a VG. VOLUME GROUP (VG): One or more PVs. A collection of PVs that users view as a single oversized PV. A VG can contain any mixture of physical disk types. PHYSICAL VOLUME (PV): One or more LVs. Represents a hard disk (e.g., hdisk0). VGDA (Volume Group Descriptor Area): Stores information about all LVs and PVs in a VG. VGSA (Volume Group Status Area): Stores information about which PPs are stale and which PVs are missing within a VG. Steps to Re-Import VGs After a System Reinstall If the system halts with the message performing Auto varyon of Volume Groups on the console: Press CTRL-C to continue. Log in as root. Export all non-root volume groups: exportvg <VGName> Shut down and reboot the system: shutdown -Fr Re-import non-root volume groups: importvg -y <VGName> <PVName> Steps to Replace a Failing PV in a Non-Root VG Backup all filesystems found on the failing PV: lspv -l <PV> Identify how LVs are allocated on the PV: lslv -m <LV> Unmount all filesystems on that PV: umount <FILESYSTEM_NAME> Remove all LVs found on that PV: rmlv <LV> Remove the failing PV from the system: reducevg <VG> <PV> Remove the PV entry from the ODM database: rmdev -l <PV_NAME> -d Shut down the system: shutdown -F Physically replace the failed PV and install a new PV. Add the new PV to the VG: extendvg <VG> <PV> Recreate the removed LVs using a map file: mklv -y<LV> -m<MAP_FILE> <VG> <PP_NUM> <PV> Resize the filesystems on the new PV: mkfs /dev/<LV> Perform a filesystem check before mounting: fsck -f /dev/<LV> Mount all filesystems on that PV: mount <FILESYSTEM_NAME> Restore the data from your backup. Mirroring a Boot Logical Volume Each hard drive is a potential boot device. The bosboot command creates a bootable image in the BLV (boot logical volume), which is used to boot AIX. Commands: Set normal boot device: bootlist -m normal hdisk0 Set service mode boot devices: bootlist -m service fd0 rmt0 hdisk0 Create a bootable image in BLV: bosboot -u -d /dev/hdisk0 To mirror the BLV: Ensure all copies occupy the same physical partitions on each device. Use lmigratepp to move partitions and keep them synchronized. If mirroring, disable quorum checking: chvg -Qn rootvg If the system crashes, manually synchronize with: syncvg -v <VG> **Files that keep growing** Periodically, the following files need to be reduced in size. You can use the `cat /dev/null` command. **Example:** ``` cat /dev/null >/var/adm/sulog ``` Files: - `/var/adm/sulog` - `/var/adm/cron/log` - `/var/adm/wtmp` - `/etc/security/failedlogin` - `/var/adm/ras/errlog` (use `errclear` with parameters) --- **System Information** - `ls -b` (list garbage file names in octal) - `lscfg` (lists installed devices, `-v` for versions, or `-c`) - `lsgroup` (lists user groups) - `lsuser` (lists users) - `lscons` (displays the current console tty value) - `lsswconfig -a` (lists the software catalog) - `lsdev -C -c <class> -H` (lists devices) - `lsattr -l <class> -a <item> -E` (for current attributes) **Class values:** - tty, printer, tape, disk, adapter, dlc, bus, diskette, if, memory, logical_volume, mouse, port --- **Setting 132 Columns for HP Laser Printers** If you have trouble setting the column width to 132 columns for text reports, use this fix: 1. If the default column width does not allow a value greater than 77, you need to edit the file containing the parameter limit. 2. Edit the file: ``` /var/spool/lpd/pio/@local/queuename ``` _(Replace_ `_queuename_` _with the actual queue name.)_ 3. Search for `77` in the file; there will likely be two entries containing `{77}`. 4. Change `77` to `132`. --- **Volume Commands** **Definitions:** - **PHYSICAL PARTITION (PP):** Smallest unit a PV is divided into (e.g., 4 MB partition size). - **LOGICAL PARTITION (LP):** One or more PPs. Represents a mirrored copy of a PP. Up to two copies of a PP can be mirrored, resulting in an LP count of three (two mirrors plus original). - **LOGICAL VOLUME (LV):** One or more PPs. A file system resides on top of an LV. Only one LV is mapped to a file system. An LV cannot span across a VG. Up to 255 LVs in a VG. - **VOLUME GROUP (VG):** One or more PVs. A collection of PVs that users view as a single oversized PV. A VG can contain any mixture of physical disk types. - **PHYSICAL VOLUME (PV):** One or more LVs. Represents a hard disk (e.g., `hdisk0`). - **VGDA (Volume Group Descriptor Area):** Stores information about all LVs and PVs in a VG. - **VGSA (Volume Group Status Area):** Stores information about which PPs are stale and which PVs are missing within a VG. --- **Steps to Re-Import VGs After a System Reinstall** 1. If the system halts with the message `performing Auto varyon of Volume Groups` on the console: - Press `CTRL-C` to continue. - Log in as `root`. 2. Export all non-root volume groups: ``` exportvg <VGName> ``` 3. Shut down and reboot the system: ``` shutdown -Fr ``` 4. Re-import non-root volume groups: ``` importvg -y <VGName> <PVName> ``` --- **Steps to Replace a Failing PV in a Non-Root VG** 1. Backup all filesystems found on the failing PV: ``` lspv -l <PV> ``` 2. Identify how LVs are allocated on the PV: ``` lslv -m <LV> ``` 3. Unmount all filesystems on that PV: ``` umount <FILESYSTEM_NAME> ``` 4. Remove all LVs found on that PV: ``` rmlv <LV> ``` 5. Remove the failing PV from the system: ``` reducevg <VG> <PV> ``` 6. Remove the PV entry from the ODM database: ``` rmdev -l <PV_NAME> -d ``` 7. Shut down the system: ``` shutdown -F ``` 8. Physically replace the failed PV and install a new PV. 9. Add the new PV to the VG: ``` extendvg <VG> <PV> ``` 10. Recreate the removed LVs using a map file: ``` mklv -y<LV> -m<MAP_FILE> <VG> <PP_NUM> <PV> ``` 11. Resize the filesystems on the new PV: ``` mkfs /dev/<LV> ``` 12. Perform a filesystem check before mounting: ``` fsck -f /dev/<LV> ``` 13. Mount all filesystems on that PV: ``` mount <FILESYSTEM_NAME> ``` 14. Restore the data from your backup. --- **Mirroring a Boot Logical Volume** Each hard drive is a potential boot device. The `bosboot` command creates a bootable image in the BLV (boot logical volume), which is used to boot AIX. **Commands:** - Set normal boot device: ``` bootlist -m normal hdisk0 ``` - Set service mode boot devices: ``` bootlist -m service fd0 rmt0 hdisk0 ``` - Create a bootable image in BLV: ``` bosboot -u -d /dev/hdisk0 ``` To mirror the BLV: 1. Ensure all copies occupy the same physical partitions on each device. 2. Use `lmigratepp` to move partitions and keep them synchronized. 3. If mirroring, disable quorum checking: ``` chvg -Qn rootvg ``` 4. If the system crashes, manually synchronize with: ``` syncvg -v <VG> ``` --- **sysdumpdev** Operations performed on the system dump device: - Turn off the dump device: ``` sysdumpdev -p sysdumpnull ``` - Reactivate the dump device: ``` sysdumpdev -p hd7 ``` - Resynchronize the VG information in the ODM: ``` updatevg rootvg ``` lpstat Displays printer queue status information. First printer listed by lpstat is your default queue. In other words, if no queue name is given when the LP command is executed, then the print job will be submitted to the default printer. If the lpstat command hangs at a client machine, theres a good chance that the lpd daemon is not running on your print server. Execute the startsrc -s qdaemon command to start the lpd daemon. If this daemon fails to start, the lock file /etc/locks/lpd may be preventing this process from successfully starting. Delete this file and rerun startsrc -s qdaemon again. Example What it does lpstat Displays print queue status lpstat -t Displays Print queue status with more detail lpstat -plaser Displays print queue status for the queue laser only lptest Generates the line printer ripple test pattern Example What it does lptest 80 100 | pr -n Prints 100 lines of 80 column test pattern to the default print queue - where each line is prefixed with a line number lsquedev Lists the name of the printer queue attributes stored in the /etc/qconfig file Example What it does lsquedev -q ibm -d dlp0 List the attributes for the queue ibm associated with the device lp0 lsvirprt Displays the attributes for a virtual printer or printer queue Examples What it does lsvirprt -qlaser -dlp0 Lists printer queue attributes and their values. The 'q' (queue) and 'd' (device) flags are required. lsvirprt -qlaser -dlp0 -a _K Lists the condensed print attribute (_K) for the printer queue laser lssrc List the status of a subsystem Examples What it does lssrc -g spooler Display status of all the spooling daemons lssrc -a List status of all subsystems mkquedev Create another print queue to the same output device (multiple queues to one print device) When you submit jobs to these queues remember the qdaemon redirects stdin,stdout, and stderr to the NULL device (/dev/null). If you wish to see any output from your job, you will need to redirect stdout and stderr of that job to a specific file or CRT. Example What it does mkquedev -d ksh1 -q bsh -a backend=/bin/ksh Creates an additional printer queue to the 'bshdev' device named 'ksh1'. pr Paginate a file before printing it via the lp command. Separates files into pages with headers, footer margins and page numbers. It can also produce multicolumn output. Output of this command will default to the screen but is normally redirected to a file or line printer. Example What it does pr -l64 UserGuide.doc | lp Paginates the UserGuide.doc to 64 lines per page and pipes the output to the system default printer. qpri Set the priority of a print job. This command will only work with local print queues. If the job is ranked first in the queue, this command will only work once. If the first ranked job is changed a second time, the priority won't change. Default priority is 15. Use the lpstat -t command to see print queue priority. Examples What it does qpri -#169 -a 4 Lowers the priority of print job 169 to 4 from 15. If there are jobs with higher priority in the same print queue where job 169 resides, they will move ahead. qpri -#169 -a 20 Raises the priority of print job 169 from 15 to 20. If there are jobs with higher priority in the same print queue where job 169 resides, they will move behind job 169. startsrc -s qdaemon This command is used to start the spool daemon named qdaemon. By default, this daemon is started everytime the system reboots. stopsrc -s qdaemon This command Will stop the spool qdaemon. If the qdaemon is not running, all jobs submitted to the spooler will be queued. The job number for these print jobs will be marked 'new'. Once the qdaemon is restarted those queued jobs will be given a job number. Lock Files Occasion you may get a message lpd: lock file or duplicate daemon. This can be caused if there is a problem with the lpd daemon. When this happens Remove the file /etc/locks/lpd. This file should contain the Process ID (PID) for the currently running lpd daemon. Stop and start the print spooler. Backup/Restore Commands Relative vs Absolute Paths When restoring files backed up with the backup, cpio, or tar commands, find out FIRST whether RELATIVE or ABSOLUTE pathnames were used BEFORE the restore is initiated. We recommend using RELATIVE. Relative pathnames will have a ./ pre-fixed to their path. These files will be restored relative to the current directory. Absolute pathnames won't have the ., just the /. These are restored with the full pathname to the exact directory as specified on the archive device. backup Command typically used to backup files on an AIX platform. Distribution tapes for AIX are in this format. This command will span across multiple tapes. Backup by INODE is not recommended because it eliminates the capability to selectively restore files by filename. If you have more data to backup than can fit on one tape, you will probably want to perform INCREMENTAL backups for files that have been modified within the last 24 hours for each day of the work week, followed by making a complete backup of the system on the weekend. The error message Volume on /dev/rfd0 is not in backup format is generated when an attempt is made to extract a file NOT created by the backup command: If your backup was successful, the last item logged by 'backup' is the time the backup finished and the number of 512 byte block that were archived. Example message of a successful backup: Backup finished on Sat Aug 1 15:22:34 CDT 1992; there are 8700 blocks on 1 volumes. Options What it does -i Read standard input -v List names of files being backed up -f Name of output device (typically de/v/rmt0 for tape drive) -e Won't attempt to compress or pack files that are greater than 24 MB. -q Won't prompt user to insert tape -p Pack data. Backup images by default are NOT packed. If you wish to pack your data, use this option. The restore command has enough intelligence to determine if a backup image is packed or not and take appropriate action Examples What it does find /u -print | backup -ivf/dev/rmt0 Backup the file system /u to tape device using ABSOLUTE pathnames. find . -print | backup -iepqvf/dev/rmt0 | tee /tmp/BACKUP.LOG Backup files and directories under current directory (.) using RELATIVE pathnames. The tee (|) will take as input the output of the backup command (filenames being copied) and write them to the log file 'BACKUP.LOG' for later review. find /faxdata -mtime -1 -type f -print | backup -ivf/dev/rmt0.1 Find any REGULAR files (-type f) that have been modified within the past 24 hours (-mtime -1) and write them to the tape device but don't rewind (/dev/rmt*.1) the tape after backup has finished. backup -ivqf/dev/fd0 Backup files interactively. Select the file(s) to backup by typing in the file's name. When done, press ^D to finish. find / -print|backup -icvqf/dev/rmt0-1 If there is more than one tape drive attached to the system, then you can specify a range of devices to the -f flag of the backup command. (/dev/rmt0-1) compress, uncompress, pack, unpack, zcat Utilities to compress or expand data. The compress command reduces the size of the named file(s) and renames it with a .Z extension. Compressed files can be restored to their original form using the uncompress command. This utility appears to have a more EFFICENT packing scheme than the PACK/UNPACK commands. Examples What it does compress -v /tmp/junk File /tmp/junk is compressed and gets renamed to /tmp/junk.Z. -v displays the percentage of file shrinkage uncompress /tmp/junk.Z Restores file to original file type and file size and changes the name to /tmp/junk. 1)find . -print | backup -ivqpf /tmp/roger.bck 1) compress /tmp/roger.bck 2) find /tmp/roger.bck.Z -print | backup -ivqf/dev/fd0 The 3 commands will backup the current directory and compress that backup image to a floppy diskette. 3) restore -xvf/dev/fd0 4) uncompress < /tmp/roger.Z | restore -xvf- Restore the files archived from a floppy diskette. (In this example assume restored file=roger.Z) Uncompress the compressed image and restore this file back to the file system zcat /tmp/junk.Z > /tmp/junk1 Uncompresses /tmp/junk.Z into /tmp/junk1 find /u/COMPANY -print | xargs pack -f Packs all the files under the specified directory (/u/COMPANY) find /u/COMPANY -print | xargs unpack Unpacks all the files under the specified directory (u/COMPANY) cpio Copies files to/from an archive storage device. This command is often used to copy files from UNIX to AIX systems. This command will span across multiple tapes. cpio stands for CoPy Input to Output. Options What it does -c Writes header information in ascii format for portability across UNIX systems. The message Out of phase--get help is generated when an attempt is made to extract a file not in cpio format OR if the archive tape was written with the -c option. The cpio command doesn't have this option specified when attemping to extract files from the media (eg., cpio -icdumpv < /dev/rmt0) -r When restoring will prompt for new path/file to restore to -v List the file name as it's being copied -i Read from standard input, i.e. keyboard -u Copies unconditionally. Older file replaces a newer one. Files with older modification times will replace files with newer modification times. -d Creates directories, if applicable -t For table of contents -C1 Performs block I/O in 512 byte blocks, if the block size of the device that wrote the data on the tape was set to 512 bytes. Make sure you read with the same block size. If the block size that the data was written to and about to be read from are two different sizes, this message will be displayed: Cannot read from the specified device Examples What it does 5) cd /u/roger 6) find . -print | cpio -ocv > /dev/fd0 Reads file names using the find command and copies to the floppy drive (/dev/fd0). find . -cpio /dev/fd0 -print Saves files in current directory and writes this info to floppy. Same command as above except much faster. 7) cd /u/roger 8) cpio -icuvd < /dev/fd0 Restore files and directories saved on the floppy device. These files are restored under the current directory (/u/roger) Only if relative pathnames (./<filename>) were used. cpio -itvcC1 < /dev/rmt0 List the table of contents from a tape device. 9) cd /u/roger 10) find . -print | cpio -dumpv /u/jerry Copies all files FROM one directory TO another WITHOUT changing the permissions, owner/group or modification date of the file. Use the following command to verify that all files were copied: find /u/roger -print | wcfind /u/jerry -print | wc If the number of files encountered is the same for both directories its safe to assume that the directories are identical. NOTE: that the number of blocks allocated to the SOURCE directory (/u/roger) may be larger than the DESTINATION directory (/u/jerry), since compaction of the directory structure will have occurred at the destination end. cpio -imv /home/roger/.profile < /dev/fd0 Selectively restore the /home/roger/.profile file from floppy cpio -i "*.f" "*.c" </dev/fd0 Selectively restore only the *.f and *.c files from floppy dd Converts/copies files to/from an output device. DD stands for Data Dump. This command will NOT span across multiple tapes. Common utility found on most versions of UNIX. Examples What it does dd if=/dev/rmt0 bs=512k | cpio -icdmv Reads the files off the tape device faster because of the blocking factor (bs=blocksize of 512K or cache upto 1/2 MB at a time) dd if=rs6000.data of=/dev/rmt0.4 bs=1024 conv=ebcdic Copies the data from the input file (if=rs6000.dat) to the output tape device (/dev/rmt0). The rmt*.4 device extension means output is written in 1600 bpi format. This creates an EBCDIC low density tape, resulting in a 1024 byte blocked non-labeled file. To extract this file on the AS/400, create a physical file with a record length of 1024 bytes. Use the CPYFRMTAP command to copy the file. NOTE: When copying data from an EBCDIC machine, make sure your BLOCK SIZE is set to 0 on the tape device dd if=unixfile.txt of=DOSFILE.TXT conv=ucase Copies the data from the input file (if=unixfile.txt) to output name (of=DOSFILE.TXT) and converts the source data to UPPERCASE characters. tar -cvf- /u/roger | dd of=/dev/rmt0 bs=1024k Copies the ABSOLUTE path /u/roger using the tar utility. To speed this process up, these files are piped to the dd utility using a cache buffer size of 1 MB. dd if=/dev/rhdisk0 of=/dev/rhdisk1 bs=5120b Copies the raw physical volume named hdisk0 to the raw physical volume named hdisk1. This represents a copy disk utility. dd if=/dev/rmt0 of=/tmp/ascii_file conv=swab Copies the data from the tape device (if=/dev/rmt0) and creates an output file (/tmp/ascii_file) - which is BYTE swapped (conv=swab) as it is being written out. This needs to be done if your copying ascii files from a System V Unix machine (unisys to the RS/6000) dd if=/dev/rmt0.1 of=/tmp/data1 cbs=242 ibs=3240 conv=sync,unblock Useful when reading an ASCII file that is NOT delimited by a NL character. dd if=/dev/rmt0.1 of=/tmp/data1 cbs=147 ibs=2940 conv=ascii Will read a record size of 147 bytes, a block size of 2940 bytes, and convert the output to an ASCII file. mksysb High-level shell command for backing up mounted file systems in the rootvg volume group. mkszfile -f must be called prior to mksysb in order to create the /.fs.size file that mksysb uses to determine which files will be backed up. 8MM TAPE DEVICE An 8mm tape drive is the preferred method of backing up your system because that tape can be used to recreate the rootvg image if one or more physical volumes fail. Each of the file systems MUST have at least 500 blocks free when the mksysb backup is made. The system will need some work space in each file system when it is installing from a mksysb backup. To utilize the full 2.3 gb tape capacity... Set the blocksize to 1024 Edit the /usr/lpp/bosinst/diskette/startup2 file Change the following line from 512 to 1024. /etc/methods/chggen -a rmt0 -a block_size=1024 Create a new install/maint diskette MKSYSB can create a BOOTABLE tape. Further, the data is archived in TAR format. In order to look at the names of files backed up by this command, perform the following: tctl -f/dev/rmt1.1 fsf 3 tar -tvf/devrmt1.1 Example: mkszfile -f && mksysb /dev/rmt0 -f forces extending the /usr or /tmp file system if not enough working space (8 MB) exists. This command should ALWAYS succeed unless a tape has not been inserted into the archive device (eg., rmt0), or the tape is either write-protected or has defective media. restore Retrieve information from archive device created with the backup command. Default device is /dev/fd0. This command will read a backup image spread across multiple tapes. Examples What it does restore -Tvf/dev/rmt0 -T=table of contents, -v=list the file name being copied, -f=name of output device. Will list the tape's table of contents. If you forget to label the tape with the date that the tape was made, use this command to report back the date this archive was created. restore -xvf/dev/rmt0 ./usr/tmp/My* Restores all files that start with "My" from the /usr/tmp directory restore -xdvf/dev/rmt0 ./usr/tmp Restores the directory named /usr/tmp from tape device restore -xvf/dev/rmt0 Restores all the files located on the tape device that were backed up using the backup command. restore -xvf/dev/rmt0 ./tmp/TestFile -x=extract data from output device. Restores only the file named ./tmp/TestFile from the tape device. If the subdirectory /tmp doesn't exist in the current directory, then that subdirectory will be made prior to restoring 'TestFile'. 11) tctl -f/dev/rmt0 rewind 12) restore -s1 -Tvf/dev/rmt0.1 13) restore -s1 -Tvf/dev/rmt0.1 14. Rewind to the beginning of tape. 2. Review files on FIRST backup image. 3. Review files on SECOND backup image) Displays the table of contents for multiple backup images. s1=specifies that multiple backups are on the tape and that the restore command skips to the backup specified by the number associated with the 's' option. The 0.1 for the output device (-f flag) means that once the tape has been read, it will not rewind. If only the second backup image was needed, could have just typed in: restore -s2 -Tvf/dev/rmt0.1 15) tctl -f/dev/rmt0.1 fsf 3 16) restore -xvqf/dev/rmt0.1 ./unix If by chance the ./unix file was deleted, go back to your install tape and extract the file that needs to be restored. The first three images on the tape are BOSBOOT, INSTALL/MAINT, followed by the TOC (table of contents) image. restbyname -xvqf/dev/fd0 -Z /tmp/DISK.LIST Selectively restore ONLY those files listed in file /tmp/DISK.LIS tapechk Performs consistency checks on a tape device. Primarily used to check tapes written in backup format. Example: tapechk 2 ( Checks the first 2 files found on the tape device.) tar Probably the easiest command to use when transferring files from one UNIX system to another. This command will NOT span across multiple tapes. Tar stands for Tape ARchiver. When using this command while performing a SELECTIVE restore from a tape device (eg;., tar -xvf/dev/rmt0 ./etc/motd), the tar command will continue to run until the end of tape is encountered, even after the file has been found. The error message tar: directory checksum error (0 != 12345) Tar is an older utility than cpio or backup/restore is generated when an attempt is made to extract a file that is NOT in tar format. Options What it does -c Writes (creates) files (appends to archive device) -x Extract (read) files from archive device -v Verbose mode (displays names) -f Device name to use Examples What it does tar -cvf- * | dd of=/dev/rmt0 bs=128k Copies all the files and subdirectories from the current directory and pipes the output to the dd command for faster archiving. dd if=/dev/rmt0 bs=128k | tar -xvf- Use the dd command to read the tape device for faster archiving and pipe the output to the tar command to restore the archived files. tar -tvf/dev/rmt0 List the table of contents of the tape device. tar -cvf/dev/rmt0 /u/jones Copies the jones account to the archive device named /dev/rmt0. tar -xvf/dev/rmt0 tmp/newdata /tmp/olddata Selectively copies ONLY the newdata and olddata directories from the tape to the current directory. tar -cvf- * | xargs compress -v > /tmp/tar.Z Copies all the files from the current directory and compresses them into the file named tar.Z. tcopy Copies from one magnetic tape device to another. This command will work for copying multiple backup images from one media type to another. It will continue to copy until two end-of-tape marks are encountered. Examples What it does tcopy /dev/rmt0 Displays ALL the backup images and their size for the tape your currently viewing. tcopy /dev/rmt0 /dev/rmt1 Copies all the data from one media type to another until two end of tape marks are encountered. In the example above, rmt0 could be a 8mm device and rmt1 may be a 1/4" tape device. If the error message: tcopy: Cannot open /dev/rmt?' is displayed, make sure the destination device is not write-protected. tctl Command used to fast forward a tape device (Tape ConTroL). Examples What it does tctl -f/dev/rmt0 rewind Rewind the tape device. tctl -f/dev/rmt0.1 fsf Move tape forward to the second tape mark. The .1 on the rmt0 device instructs the device NOT to rewind after performing the command. Use this command to skip past unwanted tape images - assumming there are multiple archive images on the tape to skip past. tctl -f/dev/rmt0 retension Moves the tape to the beginning, end, and back to the beginning again. Used to retension the tape when encountering multiple read errors on restore operations. Backup files from a remote computer The local host MUST be included in remote's hosts /etc/hosts.equiv file. The local host and user name MUST be included in the $HOME/.rhosts file at the user account at the remote machine. Examples What it does rsh lanai -l roger "dd if=/dev/rmt0" | tar -xvf- Restores files FROM a remote tape drive on a host named 'lanai' tar -cvf- * | rsh lanai -l roger "dd of=/dev/rmt0 bs=64k conv=block" The tar command will write it's output to the rsh command which pipes the data to the remote host (lanai) and the tape drive (/dev/rmt0). Specify -l <UserName> if the local user is different from the remote user. tar -cvf- * | rexec lanai " dd of=/dev/fd0 bs=4096" Uses the floppy drive device on node lanai to store files in tar format. Commando’s Unix man = manual (opvragen handleiding bij een commando) df –sk = opvragen van de vrije ruimte van de hd realdir = het absolute pad du –sk = opvragen grote van een specifieke dir die je opgeeft mkdir = aanmaken directory rmdir = verwijderen directory rm –r [directorynaam] = verwijderden directory tar –tvf /dev/rmt0 –N 800 = geeft uitvoer van bestanden op tape tar –cvf /dev/rmt0 –N 800 [bestandsnaam] = bestanden op tape zette tar –xvpf /dev/rmt0 –N 800 [bestandsnaam] = bestanden terug laden van tape mt –f /dev/rmt0 rewind = terugspoelen van de tape mt –f /devrmt0.1 fsf 1 = het zetten van de juiste file system van de tape lscfg –vl rmt0 = gegevens van de tape unit opvragen lpstat –a [queuenaam] = status van de queue lsallq / lsallq |grep [queuenaam] = opvragen van alle queue op het systeem enable [queuenaam] = queue vrijgeven disable [queuenaam] = queue down brengen cancel [queuenaam] = verwijderen van de taken in de queue cancel [taaknummer] [queuenaam] = verwijderen van 1 of meerdere specifieke taken su – [username] = simulate user find (find . –name [bestandsnaam] –print) = zoeken van bestanden errpt = error report van server errpt –a = gespecificeerde error report crontab –l = lijst crontab –e = vi mode Acs herstarten op de p omgeving: psef acs | awk '{print$2}' | grep -v PID | xargs kill -9;/p/cqcs/acs p/prog/system/acs.cfg;psef acs Alle filesystem aktiviteiten monitoren door te tracen met output naar /tmp/filemon.log: filemon -o /tmp/filemon.log -O all: Aantal in *Project ingelogte gebruikers: ps -ef|grep -v "0:00"|grep -v tved|grep –v PID|grep csrun|wc -l Aantal processoren: lscfg -vp |grep proc |wc -l Actieve csruns op AIX: ps -ef|grep -v "0:00"| grep –v PID|grep csrun|sort -k 7|pg’ Actieve csruns op AIX maar dan de 10 drukste: ps -ef|grep -v "0:00"| grep –v PID|grep csrun|sort -k 7|pg’ | tail -10 AIXDump tape uitlezen: restore -s4 -qTvf /dev/rmt0.1 Alle extenties van files in een map weghalen bijv. .txt: ls |grep txt | sed 's/\(.*\).txt$/mv "&" "\1"/'|sh Alle processen van 1 gebruiker killen: ps -u [user-id] -o pid | grep -v PID | xargs kill -9 Alle processen van alle gebruikers killen behalve de taakverwerkers: psef csrun | grep -v root | grep -v PID | grep -v tved | awk '{print$2}' | xargs kill -9 Asynchrone i/o setting voor AIX: /usr/sbin/lsattr -El aio0 Attributes weergeven van een virtuele printer: lsvirpt -qqueue -ddevice -s__HTP Bestanden zoeken zonder owner of group: find / -fstype jfs \( -nouser -o -nogroup \) -ls Check of NFS aktief is: lssrc -a | egrep nfs Check welke Spoolers aktief zijn: lssrc -g spooler Cpu snelheid op AIX 5.2: prtconf –s Crontab Job om de 15 minuten van 7 tot 18u zonder output: 0,15,30,45 7,8,9,10,11,12,13,14,15,16,17,18 * * 1,2,3,4,5 shit hier 1>/dev/null 2>/dev/null Data van een dir inpakken: tar -cvf- * | xargs compress -v > naam.Z Datum laatste tapeclean: /usr/lpp/diagnostics/bin/utape Defuncts vinden en automatisch killen: ps -aekl | grep defunct | awk '{print $5}' | xargs kill -9 Disks boven 80% gebruik: df -k | perl -lne 'print if (split)[3] > 80' | awk '{print $4,"\t",$7}’ Extenties wijzigen van .txt naar .doc bij meerdere bestanden tegelijk: ls -1 | grep '\.txt | sed -e 's/\(.*\).txt/mv & \1.doc/' | sh Error led uitzetten op rs/6000: /usr/lpp/diagnostics/bin/usysfault -s normal FastT info: fget_config -Av Failed logins: /usr/sbin/acct/fwtmp < /etc/security/failedlogin | grep user Grote files ‘legen’ : cp /dev/null > file Harddisk type, firmware en ROS level: lsmcode -A | grep hdisk Init status: cat /etc/.init.state Korte termijn cpu processen: ps -aekl Kproc en tijden: ps aux | grep -v kproc | head -10 Kproc processen weergeven: ps auxw | sort -r +2 | head -10 | grep kproc Maximum processen per user: lsattr -E -l sys0 -a maxuproc NMON alle data gedurende een uur: nmon -f -s 30 -c 120 Netwerk stats: entstat -d ent0 OS 64bit kernel install check: lslpp -l bos.64bit Password laten wijzigen door user bij volgende inlog: pwdadm -f ADMCHG PCI sloten weergeven: lsslot -c pci Pid verplaatsen van cpu: bindprocessor [pid] [processornummer]: SSA Batterij check: ssa_fw_status -a ssaX ( waar x is het nummer van de ssa bijv. ssa0 etc.. ) SSA batterij formatteren na vervanging: ssa_format -l ssa0 –b Sendmail starten: startsrc -s sendmail -a "-bd -q30m" Server Paging space: lsps -a Server geheugen in KB: lsattr -El sys0 -a realmem Server geheugen per module weergeven: lscfg -vp | grep -e "Memory DIMM" -e "Size" Server geheugen in aantal modules weergeven: lscfg -vp | grep -e "Memory DIMM" -e "Size" | wc -l Server serienummer: lsattr -El sys0 -a systemid Servermodel: uname -M Tape listing weergeven mbv restore evt. redirecten > filenaam: restore -q -T -b 3832 -f /dev/rmt0.1 Temperatuur/fanspeed/voltages fans: /usr/lpp/diagnostics/bin/uesensor -l Test files maken (ACTO): mediatst -wr=<getal>M <file-naam> Top 10 processen monitoren: netpmon -o logfile Top 10 processen: svmon -P -v -t 10 |pg Top 10 processen realtime: ps gxu | sort -k 3.0,5r | grep -v PID | head -n 10 Virtueel geheugen in gebruik: ps -eo vsz | awk '{ i+=$1; } END {print i / 1024;}' Weergeven geinstalleerde software: lslpp -L all Weergeven geinstalleerde printersoftware: lslpp –L all | grep printers Welke filesets geinstalleerd: instfix -i | grep ML Welke kernel is geinstalleerd: lslpp -l 'bos.[um]p*' Zoek coredump files en verwijder deze: find / -name core -exec file {} \; -exec rm -i {} \; Zombie processen: ps -aekl | grep defunct ^M verwijderen achter text ge-edit met windows: tr -d '^M' < [inputfile] > [outputfile] (^M=ctrl+v+m) -- terugladen van alle dp* files op unix: mt -f /dev/rmt0 rewind mt -f /dev/rmt0.1 fsf 2 restore -q -x -b 3832 -f /dev/rmt0.1 alle dp* files worden nu teruggeladen. Deze kun je weer zien met bijv. men200 dp+ zoals we dat bij de dump doen. Command Description • apropos word Show commands pertinent to word. See also threadsafe   which command Show full path name of command   time command See how long a command takes • time cat Start stopwatch. Ctrl-d to stop. See also sw • nice info Run a low priority command (info in this case) • renice 19 -p $ Make shell (script) low priority. Use for non interactive tasks • look reference Quickly search (sorted) dictionary for prefix • grep --color reference /usr/share/dict/words Highlight occurances of regular expression in dictionary   gpg -c file Encrypt file   gpg file.gpg Decrypt file • alias hd='od -Ax -tx1z -v' Handy hexdump. (usage e.g.: • hd /proc/self/cmdline | less) • alias realpath='readlink -f' Canonicalize path. (usage e.g.: • realpath ~/../$USER) • set | grep $USER Search current environment • ls /usr/bin | pr -T9 -W$COLUMNS Print in 9 columns to width of terminal   touch -c -t 0304050607 file Set file timestamp (YYMMDDhhmm) dir navigation • cd - Go to previous directory • cd Go to home directory   (cd dir && command) Go to dir, execute command and return to current dir • pushd . Put current dir on stack so you can popd back to it CDs   gzip < /dev/cdrom > cdrom.iso.gz Save copy of data cdrom   mkisofs -V NAME -r dir | gzip > cdrom.iso.gz Create cdrom image from contents of dir   mount -o loop cdrom.iso /mnt/dir Mount the cdrom image at /mnt/dir (read only)   cdrecord -v dev=/dev/cdrom blank=fast Clear a CDRW   gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom - Burn cdrom image (use dev=ATAPI -scanbus to confirm dev)   cdparanoia -B Rip audio tracks from CD to wav files in current dir   cdrecord -v dev=/dev/cdrom -audio *.wav Make audio CD from all wavs in current dir (see also cdrdao)   oggenc --tracknum='track' track.cdda.wav -o 'track.ogg' Make ogg file from wav file archives   tar c dir/ | bzip2 > dir.tar.bz2 Make archive of dir/   bzip2 -dc dir.tar.bz2 | tar x Extract archive (use gzip instead of bzip2 for tar.gz files)   tar c dir/ | gzip | gpg -c | ssh user@remote 'dd of=dir.tar.gz.gpg' Make encrypted archive of dir/ on remote machine   find dir/ -name '*.txt' | tar c --files-from=- | bzip2 > dir_txt.tar.bz2 Make archive of subset of dir/ and below   find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents Make copy of subset of dir/ and below   ( tar c /dir/to/copy ) | ( cd /where/to/ && tar x -p ) Copy (with permissions) copy/ dir to /where/to/ dir   ( cd /dir/to/copy && tar c . ) | ( cd /where/to/ && tar x -p ) Copy (with permissions) contents of copy/ dir to /where/to/   ( tar c /dir/to/copy ) | ssh -C user@remote 'cd /where/to/ && tar x -p' Copy (with permissions) copy/ dir to remote:/where/to/ dir   dd bs=1M if=/dev/hda | gzip | ssh user@remote 'dd of=hda.gz' Backup harddisk to remote machine rsync (Use the --dry-run option for testing)   rsync -P rsync://rsync.server.com/path/to/file file Only get diffs. Do multiple times for troublesome downloads   rsync --bwlimit=1000 fromfile tofile Locally copy with rate limit. It's like nice for I/O   rsync -az -e ssh --delete ~/public_html/ remote.com:'~/public_html' Mirror web site (using compression and encryption)   rsync -auz -e ssh remote:/dir/ . && rsync -auz -e ssh . remote:/dir/ Synchronize current directory with remote one file searching • alias l='ls -l --color=auto' quick dir listing • ls -lrt List files by date. See also newest   find -name '*.[ch]' | xargs grep -E 'expr' Search 'expr' in this dir and below. See also findrepo   find -type f -print0 | xargs -r0 grep -F 'example' Search all regular files for 'example' in this dir and below   find -maxdepth 1 -type f | xargs grep -F 'example' Search all regular files for 'example' in this dir   find -maxdepth 1 -type d | while read dir; do echo $dir; echo cmd2; done Process each item with multiple commands (in while loop) • find -type f ! -perm -444 Find files not readable by all (useful for web site) • find -type d ! -perm -111 Find dirs not accessible by all (useful for web site) • locate -r 'file[^/]*\.txt' Search cached index for names. This re is like glob *file*.txt networking (Note ifconfig, route, mii-tool, nslookup commands are obsolete) • ip link show List interfaces   ethtool interface List interface status   ip link set dev eth0 name wan Rename eth0 to wan   ip addr add 1.2.3.4/24 brd + dev eth0 Add ip and mask(255.255.255.0)   ip link set dev interface up Bring interface up (or down)   ip route add default via 1.2.3.254 Set default gateway to 1.2.3.254 • tc qdisc add dev lo root handle 1:0 netem delay 20msec Add 20ms latency to loopback device (for testing) • tc qdisc del dev lo root Remove latency added above • host pixelbeat.org Lookup ip address for name or vice versa • hostname -i Lookup local ip address (equivalent to host `hostname`) • netstat -tupl List internet services on a system • netstat -tup List active connections to/from system wget (multi purpose download tool) • (cd cmdline && wget -nd -pHEKk http://www.pixelbeat.org/cmdline.html) Store local browsable version of a page to the current dir   wget -c http://www.example.com/large.file Continue downloading a partially downloaded file   wget -r -nd -np -l1 -A '*.jpg' http://www.example.com/ Download a set of files to the current directory   wget ftp://remote/file[1-9].iso/ FTP supports globbing directly • wget -q -O- http://www.pixelbeat.org/timeline.html | grep 'a href' | head Process output directly   echo 'wget url' | at 01:00 Download url at 1AM to current dir   wget --limit-rate=20k url Do a low priority download (limit to 20KB/s in this case)   wget -nv --spider --force-html -i bookmarks.html Check links in a file   wget --mirror http://www.example.com/ Efficiently update a local copy of a site (handy from cron) windows (note samba is the package that provides all this windows specific networking support) • smbtree Find windows machines. See also findsmb   nmblookup -A 1.2.3.4 Find the windows (netbios) name associated with ip address   smbclient -L windows_box List shares on windows machine or samba server   mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share Mount a windows share   echo 'message' | smbclient -M windows_box Send popup to windows machine (off by default in XP sp2) math • echo '(1 + sqrt(5))/2' | bc -l Quick math (Calculate f). See also bc • echo 'obase=16; ibase=10; 64206' | bc Base conversion (decimal to hexadecimal) • echo $((0x2dec)) Base conversion (hex to dec) ((shell arithmetic expansion)) • echo 'pad=20; min=64; (100*10^6)/((pad+min)*8)' | bc More complex (int) e.g. This shows max FastE packet rate • echo 'pad=20; min=64; print (100E6)/((pad+min)*8)' | python Python handles scientific notation • echo 'pad=20; plot [64:1518] (100*10**6)/((pad+x)*8)' | gnuplot -persist Plot FastE packet rate vs packet size • seq 100 | (tr '\n' +; echo 0) | bc Add a column of numbers. See also add and funcpy text manipulation (note sed uses stdin and stdout, so if you want to edit files, append <oldfile >newfile)   sed 's/string1/string2/g' Replace string1 with string2   sed 's/\(.*\)1/\12/g' Modify anystring1 to anystring2   sed '/ *#/d; /^ *$/d' Remove comments and blank lines   sed ':a; /\\$/N; s/\\\n//; ta' Concatenate lines with trailing \   sed 's/[ \t]*$//' Remove trailing spaces from lines   sed 's/\([\\`\\"$\\\\]\)/\\\1/g' Escape shell metacharacters active within double quotes   sed -n '1000p;1000q' Print 1000th line   sed -n '10,20p;20q' Print lines 10 to 20   sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q' Extract title from HTML web page   sort -t. -k1,1n -k2,2n -k3,3n -k4,4n Sort IPV4 ip addresses • echo 'Test' | tr '[:lower:]' '[:upper:]' Case conversion • tr -dc '[:print:]' < /dev/urandom Filter non printable characters • grep 'processor' /proc/cpuinfo | wc -l Count lines set operations (Note LANG=C is for speed) (Note also these assume no duplicate lines within a file)   LANG=C sort file1 file2 | uniq Union of unsorted files   LANG=C sort file1 file2 | uniq -d Intersection of unsorted files   LANG=C sort file1 file1 file2 | uniq -u Difference of unsorted files   LANG=C sort file1 file2 | uniq -u Symmetric Difference of unsorted files   LANG=C comm file1 file2 | sed 's/^\t*//' Union of sorted files   LANG=C comm -12 file1 file2 Intersection of sorted files   LANG=C comm -13 file1 file2 Difference of sorted files   LANG=C comm -3 file1 file2 | sed 's/^\t*//' Symmetric Difference of sorted files calendar • cal -3 Display a calendar • cal 9 1752 Display a calendar for a particular month year • date -d fri What date is it this friday. See also day • date --date='25 Dec' +%A What day does xmas fall on, this year • date --date '1970-01-01 UTC 1234567890 seconds' Convert number of seconds since the epoch to a date • TZ=':America/Los_Angeles' date What time is it on West coast of US (use tzselect to find TZ)   echo "mail -s 'get the train' [email protected] < /dev/null" | at 17:45 Email reminder • echo "DISPLAY=$DISPLAY xmessage cooker" | at "NOW + 30 minutes" Popup reminder locales • printf "%'d\n" 1234 Print number with thousands grouping appropriate to locale • BLOCK_SIZE=\'1 ls -l get ls to do thousands grouping appropriate to locale • echo "I live in `locale territory`" Extract info from locale database • locale | cut -d= -f1 | xargs locale -kc | less List fields in locale database • LANG=en_IE.utf8 locale int_prefix Lookup locale info for specific country. See also ccodes disk space (See also FSlint) • ls -lSr Show files, biggest last • du -s * | sort -k1,1rn | head Show top disk users in current dir. See also dutop • df -h Show free disk space • df -i Show free inodes • fdisk -l Show disks partitions sizes and types (run as root) • rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n List all packages by installed size (Bytes) on rpm distros • dpkg-query -W -f='${Installed-Size;10}\t${Package}\n' | sort -k1,1n List all packages by installed size (KBytes) on deb distros • dd bs=1 seek=2TB if=/dev/null of=ext3.test Create a large test file (taking no space). See also truncate monitoring/debugging • strace -c ls >/dev/null Summarise/profile system calls made by command • strace -f -e open ls >/dev/null List system calls made by command • ltrace -f -e getenv ls >/dev/null List library calls made by command • lsof -p $ List paths that process id has open • lsof ~ List processes that have specified path open • tcpdump not port 22 Show network traffic except ssh. See also tcpdump_not_me • ps -e -o pid,args --forest List processes in a hierarchy • ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d' List processes by % cpu usage • ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS List processes by mem usage. See also ps_mem.py • ps -C firefox-bin -L -o pid,tid,pcpu,state List all threads for a particular process • ps -p 1,2 List info for particular process IDs • last reboot Show system reboot history • free -m Show amount of (remaining) RAM (-m displays in MB) • watch -n1 'cat /proc/interrupts' Watch changeable data continuously System information (see also sysinfo)   hdparm -i /dev/hda Show info about disk hda   hdparm -tT /dev/hda Do a read speed test on disk hda   badblocks -s /dev/hda Test for unreadable blocks on disk hda • mount | column -t Show mounted filesystems on the system (and align output) • cat /proc/partitions Show all partitions registered on the system • grep MemTotal /proc/meminfo Show RAM total seen by the system • grep "model name" /proc/cpuinfo Show CPU(s) info • lspci -tv Show PCI info • lsusb -tv Show USB info recode (Obsoletes iconv, dos2unix, unix2dos) • recode -l | less Show available conversions (aliases on each line)   recode windows-1252.. file_to_change.txt Windows "ansi" to local charset (auto does CRLF conversion)   recode utf-8/CRLF.. file_to_change.txt Windows utf8 to local charset   recode iso-8859-15..utf8 file_to_change.txt Latin9 (western europe) to utf8   recode ../b64 < file.txt > file.b64 Base64 encode   recode /qp.. < file.txt > file.qp Quoted printable decode   recode ..HTML < file.txt > file.html Text to HTML • recode -lf windows-1252 | grep euro Lookup table of characters • echo -n 0x80 | recode latin-9/x1..dump Show what a code represents in latin-9 charmap • echo -n 0x20AC | recode ucs-2/x2..latin-9/x Show latin-9 encoding • echo -n 0x20AC | recode ucs-2/x2..utf-8/x Show utf-8 encoding interactive • mc Powerful file manager that can browse rpm, tar, ftp, ssh, ... • screen Virtual terminals with detach capability, ... • links Web browser • gnuplot Interactive/scriptable graphing • octave Matlab like environment AIX Commands: AIX Workload Manager - Quick Reference wlmcntrl [[-a | -p] [-c] [-g] [-d ConfigDir]] [-o | -q] wlmcntrl -u [-S Superclass | -d ConfigDir] wlmcntrl -T [class | proc] -T Disables total limits (AIX5.2). -c Active for CPU, passive for Memory and Disk I/O. -a Start. -p Passive. -g Disables enforcement of resource set bindings. -d ConfigDir Use config withouth /etc/wlm/current link. -o Stop. -u Update (-S AIX5.1). -q Query state (Returncode: 0 for active, 1 for stopped, 2 for passive) Network Analyse with iptrace (detailed traces) Options: -a exclude arp -s source host -d destination host -p protocol Commands: $startsrc -s iptrace -a "-i en1 /tmp/log1.out" $stopsrc -s iptrace $ipreport -ns /tmp/log1.out > /tmp/log1.formated with tcpdump (quickly writing filters) -n No resolving (numeric) of internet adresses. Use this, unless you have written a good filter with limmited output! -i Interface, name as shown in ifconfig. -I don't wait until buffer fill-up, imediate output. -p don't use promiscuous mode, use it if not needed. -q quiet, less output. filter keywords: and not ; ip ; not arp ; host 127.0.0.1 ; net 10.66.192 Undocumented features What is the current AIX Level? $ oslevel 5.2.0.0 $ oslevel -r 5200-07 $ oslevel -s 5200-07-00 Note: after AIX53 ML3 Maintenance Levels are no longer the correct naming - read aix service strategy (link dead?). Technoligy Levels, Service Packs, etc... are now the correct terminology. In what LPAR is this OS running? $ uname -L # "AIX -1 NULL" Means there are no LPAR's (1 OS on 1 box). What is the systems adress space (32 of 64 bit)? $bootinfo -y # Hardware platform capability $bootinfo -K # Current Kernel adress space Tip: Je krijgt deze opties NIET te zien via de man pages maar sms wel als je een ongeldige optie of optie --help megeeft aan het commando!!! Set up ksh for emacs mode command line editing: Tip from: [email protected] (L. Scott Emmons) The ksh has an undocumented way of binding the arrowkeys to the emacs line editing commands. In your .kshrc, add: alias __A=^P alias __B=^N alias __C=^F alias __D=^B alias __H=^A Note that "^P" (et al) must be the actual control sequence. Type "set -o emacs" or put this line in your .profile. Also, you MUST have PTF U406855 for this to work in AIX 3.2. The APAR # for the problem is IX25982, which may have been superseded. Restore from mksysb Manipulations for restoring a single file: cd / tctl -f /dev/rmt0 rewind tctl -f /dev/rmt0.1 fsf 3 chdev -l rmt0 -a block_size=0 restore -xqf /dev/rmt0.1 -s 1 ./usr/bin/vi or for a file table: restore -Tqvf /dev/rmt0.1 Manipulations for restoring without Preserving Mirrors Create an mksysb withouth mirror definitions: mkszfile (for generating image.data) edit COPIES, LPs and PP entries in image.data mksysb (zonder -i flag) Unmirror an existing mksysb with mirror definitions: $ mkdir /tmp/newdata ; cd /tmp/newdata $ chdev -l rmt0 -a block_size=512 ; tctl -f /dev/rmt0 rewind $ restore -s2 -xqvf /dev/rmt0.1 ./image.data # edit COPIES, LPs and PP entries in image.data $ echo data > signature $ find . -print | backup -iqvf /dev/rfd0 # or fda0 instead of rfd0 $ restore -Tqvf /dev/rfd0 # to check the backup NOTE: Now use the normal restore procedure but with floppy in drive AIX packaging lslpp -f "package" # results in filelist lslpp -w "/path/file" # results in package name that contains the file lslpp -L "package" # results in package version lppchk # verify files of installed software instfix -ik IY5400 # check for APAR complience instfix -ic | grep :-: # check for downlevel packages Power Management Power Management is iets voor thuis - een feature die je opzet omdat je vrouw van haar oren maakt dat die "bak" een hele dag voor niets staat te draaien. Op het werk moet z'n ding werken (of op z'n minst klaar staan om te presteren) - zet dit dus af!! # Voor het scherm alleen: $x() {pmctrl -d lft0 -t $1 $2 $3}; x '0' '0' '0' # Dit willen we dus niet en we zetten het spel volledig af! $vi /etc/inittab # and comment with ":" :pmd:2:wait:/usr/bin/pmd > /dev/console 2>&1 # Start PM daemon $reboot -Fr # The display still goes blank, # even when i don't start a Desktop and only launch X! $xset s off # from an xterm!!! Get your Systems Microcode $ lscfg -vp | grep alterable ROM Level.(alterable.ct020822 = Service Processor FirmWare level (or SvP FW) ROM Level.(alterable.CLT02219 = System FirmWare Level (or Sys FW) # or use this command and be astonished $ lsmcode -A change errpt template Create a list with Software Errors you want to ignore in /tmp/errchange.lst: =2A09B64B: Report=False =34A4A471: Report=False =44D6AA1B: Report=False EOF. $errupdate /tmp/errchange.lst Alternate Disk Install $ alt_disk_install -C -O <hdisk> # dont copy ODM (network config) $ alt_disk_install -W <hdisk> # wake-up $ alt_disk_install -S # sleep $ alt_disk_install -X [VG] # clean-up NB: never use import / export on altinst images! System Resource Controller Generic Control: lssrc -a ; stopsrc -s <service> ; startsrc -s <service> Example to add a service: mkssys -p /tmp/nisguard-wrap.sh -u 0 -s nisguard -S -n 15 -f 9 Related Information: The auditpr command, chssys command, lssrc command, refresh command, rmssys command, startsrc command, stopsrc command, traceson command, tracesoff command. Library Usage on AIX genkld : list of shared objects currently loaded onto the system (AIX) slibclean : removes any currently unused modules in kernel and library memory (AIX) ldd : display link dependencies (3th party tool from Bull package tools_from_aix.tools-1.5.4.0) cd dir; fuser -dcxV libcryptoki.so; cd dir; fuser -Vcux libC.a # can also help ODM changes Standard method to make changes in ODM see this example: Remove duplicate ODM entry's: odmget -q "attribute=modelname" PdAt > /tmp/odm1.out odmget -q "uniquetype=sys/node/chrp" PdAt > /tmp/odm2.out vi /tmp/odm1.out # verwijder alle dubbels vi /tmp/odm2.out # verwijder alle dubbels odmdelete -o PdAt -q "attribute=modelname" odmdelete -o PdAt -q "uniquetype=sys/node/chrp" odmadd /tmp/odm1.out odmadd /tmp/odm2.out mysql query output export PATH=$PATH:/opt/freeware/mysql/bin export PATH=$PATH:/opt/mysql/product/current/bin mysql -u test -p DBname pa$=test now start selecting... select ... from ... where ... like "...%" and is not ... and not like "" structure hint: show databases; show tables; describe Hardware; To submit your query and store results, use these sollutions: echo 'select ...' | mysql -u test -p DBname in mysql shell type @tee /path/filename @@ output options for mysql: option -t ASCII tables option -X XML output option -H HTML output Playing [or fighting] with mountpoints Know this one? ./..: Permission denied What it means? No rights on the mountpoint! Want proof? Here is a testcase: $su - root $chown root.root /dir/mountpoint; $chmod 700 /dir/mountpoint $mount /dev/sommefs /dir/mountpoint $su - normal_user # these all work fine $ls /dir $ls /dir/mountpoint $ls /dir/mountpoint/sommefs_dir $cd /dir/mountpoint $ls /dir/mountpoint # now, this one WILL FAIL $ls -ld ../mountpoint ./..: Permission denied # even better, watch this, and see NOTHING! $ls -la | grep "\.\." Correcting it withouth unmounting ;-) $su - root $mkdir /dummydir $mount / /dummydir $chmod 755 /dummydir/dir/mountpoint $umount /dummydir $su - normal_user $cd /dir/mountpoint # all results okay now.. $ls -ld ../mountpoint drwxr-xr-x 17 root root 4096 May 21 2001 ../mountpoint/ $ls -la | grep "\.\." drwxr-xr-x 17 root root 4096 Jul 14 09:14 ../ HACMP status Een eenvoudige manier om te weten wat op welk systeem actief is (HACMP ES) /usr/es/sbin/cluster/utilities/clfindres Voorbeeld: > root@sbaka: > /usr/es/sbin/cluster/utilities/clfindres > GroupName Type State Location Sticky Loc > ----------- ---------- ------ -------- ---------- > CBAIFSMQB_D cascading UP sbaka > CBAIFSMQB_R cascading UP sbaka Controle op Cluster configfouten: smitty clverify Creating CD's for AIX You want to create a CD with those long filenames like: cluster.es.server.rte.4.5.0.9.bff? Transfer all files to a "temp" AIX directory.. inutoc . # in the "temp" dir. cd .. mkisofs -o myimage.iso -R temp ..et voil , an image you can write with your favorite CD writer - which can be on a PC if you tranfer the ISO back. Why this workaround? AIX is using the standard ISO CD format and adheres to the 'Rock-Ridge' extensions to support long filenames, etc. This is what all Unix machines do. Unfortunately Microsoft decided that it needs its own CD format and invented 'Joliet'. Most PC software only supports 'Joliet' and not Rock-Ridge, Nero is no exception. However, there is an excellent workaround: The 'mkisofs' utility takes your files and creates a CD-image (.iso) including the Rock-Ridge table of contents. You can then write the iso file to your CD. Just search for mkisofs and start fiddling with its commandline-switches. Environment Status $ /usr/lpp/diagnostics/bin/uesensor -l For p650 and p670 this seems to be a problem, see pmr84186 (see also [1] [2]) - IBM tells us that the SP will handle this all by itself! One thing is shure, if you want to try this on a partitioned system you need resource group_128! Temperature: the best range is between 15-32 C (=60-90 F), acceptable rage is 10-40 C (=50-104 F). Get HMC Version and Release on the command line IBM says "it can't be done", i say it can: rpm -qi IBMhsc.coreserver Lately you can also use the following command: lshmc -V Network Time Protocol Time server = ntp-server Master server = ntp-server-master Check progress and internal counters on time server $ntpq ntpq> peers remote refid ... offset disp ================================================= LOCAL(0) LOCAL(0) ... 0.000 10.01 *ntp-server-mast .hopf. ... 4.252 0.84 check client systems withouth time server deamon ntptrace ntp-server ntp-server: stratum 2, offset 3.198518, synch distance 0.01930 ntp-server-master: stratum 1, offset 3.201811, synch distance 0.00974, refid 'hopf' The scripts for starting ntp: rc.01.ntp # uses ntpdate, scheduled daily rc.01.ntpd # uses xntpd for constand syncing Writing files >2GB? To get your user limits, type: `ulimit -a`. To get filesystem limits, type: `lsfs -q /some/filesystem`, on the last line you will see something like "bf: true/false", true = big file filesystem, false = normal filesystem. Note: This cannot be changed on existing JFS filesystems. doing NFS on the AIX CLI # set host in /etc/hosts # add line to /etc/exports # example: /tmp/writeme -root=host1:host2:,access=host1:host2: # example: /cdrom -ro $ exportfs /cdrom $ exportfs -v $ showmount -e $ startsrc -g nfs $ mount -v nfs -o ro serv:/cdrom /mnt $ exportfs -u /cdrom ; AND remove /cdrom line from /etc/exports Converting between: dec, hex and binary with bc Example (dec.12=hex.C): $ bc obase=16 12 C Example (dec.3=bin.11): $ echo 'obase=2;3' | bc 11 Example (hex.12=bin.10010) $ bc ibase=16 obase=2 12 10010 Hunting down the process that keeps my shared memory in use verify 'svmon' is installed on your system $lslpp -l perfagent.tools Use 'ipcs -ma' command to obtain Shared Memory ID. Note this number is in decimal and needs to be converted into hex. Use kdb (kernel debugger) to locate segment ID. Extra care should be taken when using kdb on a live system. $kdb >ipc IPC info Select the display: 17) Message Queues 18) Shared Memory 19) Semaphores Enter your choice: 2 20) all shmid_ds 21) select shmid_ds Enter your choice: 2 Shared Memory id (in hex): **input Shared Memory ID** while still in kdb, locate 'shm_handle' value. Write it down. This is the Segment ID. quit kdb with 'q' subcommand. locate process(s) attached to segment with the svmon command (drop all leading and 3 trailing zeros): $svmon -S <SegmentID> -l IBM wants a "snap" delete the old snap => snap -r software calls => snap -ac hardware call => snap -gbc hacmp calls => snap -ec snap file => /tmp/ibmsuppt/snap.pax.Z Notes: use -d option for alternate locations then /tmp/ibmsuppt. ftp upload to emea server ( ftp.emea.ibm.com ). snap -a also includes the latest system dump, see sysdumpdev -L. What is the precentage downtime in real live units 95% = 438 uur/jaar = 37 uur/maand 98% = 175 uur/jaar = 15 uur/maand 99% = 88 uur/jaar = 7 uur/maand 99.9% = 9 uur/jaar = 44 min/maand 99.99% = 52 min/jaar = 5 min/maand 99.999% = 5 min/jaar = 26 sec/maand 99.9999% = 31 sec/jaar = 3 sec/maand Major/Minor number after crash or JFS corruption In the errpt you can [sometimes] find a major/minor number. These are in hex and have to be converted to decimal. Use the decimal notation to find the device (lv) and identify on which filesystem the corruption is located. ls -lR /dev | grep [major_in_decimal] | grep [minor_in_decimal] lslv (or another appropiate command to investigate the device) ... Example: errpt... LABEL: JFS_META_CORRUPTION ... MAJOR/MINOR DEVICE NUMBER 0032 0004 32hex = 50dec 5hex = 4dec $ ls -lR /dev | grep 50 | grep 4 crw-rw-rw- 1 root system 50, 4 Apr 14 11:12 vol018 $ lslv vol018 mount point: /sbepaakb/oracle/thadbexp/db/dbf Check file permissions with find (TCB related) $ ls -l ssh_conf* -r--r--r-- 1 root system 1739 Apr 5 2004 ssh_config -r--r--r-- 1 root system 1739 Apr 5 2004 ssh_config.bak # Ah 2 files with the same permissions... $ find . -perm 444 -ls 16769 4 -r--r--r-- 1 root system 1739 Apr 5 2004 ./ssh_config.bak # only 1 file? I expected 2 files? $ ls -el ssh_conf* -r--r--r--+ 1 root system 1739 Apr 5 2004 ssh_config -r--r--r--- 1 root system 1739 Apr 5 2004 ssh_config.bak # Aha the "-e" option reaveales a "+" sign => extended ACL! $ aclget ssh_config attributes: base permissions owner(root): r-- group(system): r-- others: r-- extended permissions disabled # no! TCB maybe? $ chtcb query ssh_config ssh_config is in the TCB # Ah yes... $ find . -perm 100000444 -ls 16758 4 -r--r--r-- 1 root system 1739 Apr 5 2004 ./ssh_config # permission value = 100.000.000 for TCB files! Calculate the maximum JFS size for existing filesystems Number of bytes per inode: NBPI * 2 ^ 24 Example: ((65536*(2^24))/1024^3) GB = 1TB Fragment Size (in bytes): frag.size * 2 ^ 28 Example: ((4096*(2^28))/1024^3) GB = 1TB NBPI ranges depend on the Allocation group size: ag=8 512, 1024, 2048, 4096, 8192, 16384 ag=16 1024, 2048, 4096, 8192, 16384, 32768 ag=32 2048, 4096, 8192, 16384, 32768, 65536 ag=64 4096, 8192, 16384, 32768, 65536, 131072 Note: For JFS2 other (more flexible) rules apply. Recommended parameters Max 68 GiB: frag size: 4096, nbpi: 4096, compress: no, bf: true, ag size: 8 Max 1 TiB: frag size: 4096, nbpi: 65536, compress: no, bf: true, ag size: 32 Activate an LPAR from the HMC command prompt $ chsysstate -r lpar -o on -m <system_name> -f <profile> -n <lpar_name> e.g. $ chsysstate -r lpar -o on -m "p650-09_sbe-aam" -f "normal" -n "p650-09AD_sbedaamd" Change a partition profile's boot mode to normal from the HMC command prompt $ chsyscfg -r prof -m <system_name> -p <partition> -n <profile_name> -i attribute=value e.g. $ chsyscfg -r prof -m p650-09_sbe-aam -p p650-09AD_sbedaamd -n normal -i "boot_mode=norm" remote mksysb transfers Here we create an mksysb with the aide of sudo. In combination with the sudo command we use "su -", that way we have our "ulimits" and complete "root environment" available. Then we try to transfer it "secure" to a remote server where we do not have remote root login previleges but we do have sudo access. The result: my personal users file-limit is 2GB on both servers and with this method i can create AND transfer larger mksysb files in a secure environment! sudo su - root -c "mksysb -pe /var/local/backup/mksysb/hostx.mksysb" && \ dd if=/var/local/backup/mksysb/ hostx.mksysb bs=8k | \ gzip -1 | \ ssh -x wva0331@nimmaster sudo su - root -c "dd of=/nim/images/hostx.mksysb.gz bs=8k" && \ sudo rm /var/local/backup/mksysb/hostx.mksysb Note: more ssh file transfer methods can be found on our "other" wikipage, WikiLinuxCOM2. Stream an mksysb through a FIFO buffer mkfifo /tmp/pipe.$ mksysb -ievx /tmp/pipe.$ & dd if=/tmp/pipe.$ | ssh server dd of=.... Mirror a terminal Yes, you can do this on AIX by default. An equivalent for this is ttysnoop - but i never tested that one. Here is an example, but for the details see the man page. # ask remote host for his/her pts by typing: tty # ask remote host to open a subshell: ksh $ portmir -t pts/8 -m pts/4 portmir: Remote user connected, mirroring active. ... $ portmir -o # Closes mirror (attention - remote shell will be closed!). File, directory and link rights If you change the groupid of a group you also have to change the files. But for links people often re-create them. If you just use the -h option there is no need for that! # change file and directory rights .. $ sudo find / -group 235 -exec chgrp opc {} \; # change link rights .. $ sudo find / -group 235 -type l -exec chgrp -h group5 {} \; Config limits IBM stanza files like /etc/qconfig and /etc/security/user have line lenght limit of 255char. For qconfig this means that you are limited in the number of devices per queue. The number of queues however seems to be unlimited. The vi version included has a limit of 2048char. Use vim for editing longer lines. The maximum number of users in /etc/group is limited to 2000. The line lenght is defined in /usr/include/grp.h. Here is the calculation 8+((8+1)*2000)+14=18022. A NIS record has a maximum size of 1024bytes. This limit applies to all NIS maps including maps for /etc/group, /etc/netgroup, etc... While creating the dbm (make or makedbm), it uses the line along with the domainname and some other fields, a safe config line lenght is 1000char. qconfig device names (in /etc/qconfig) are cut to 20char and get a prepending "@"-sign . If you have the hostname "config-server-aix-01" it gets cut and becomes "@config-server-aix-0"! Logical volume Name of the logical volume. Logical volume names must be unique systemwide and can range from 1 to 15 characters. Volume group Name of the volume group. Volume group names must be unique systemwide and can range from 1 to 15 characters. Patch-files on AIX $ diff -c oldfile newfile > patchfile $ patch -ci patchfile copy-of-oldfile $ sum newfile oldfile copy-of-oldfile 40340 1 newfile 15765 1 oldfile 40340 1 copy-of-oldfile List files with full path $ echo $PWD/* $ find $PWD/* -prune Using ramdisks on AIX http://users.ca.astound.net/baspence/AIXtip/mkramdisk.htm http://www.faqs.org/faqs/aix-faq/part3/section-51.html What is SYSPROC? The resource that handles/controlls processes & dumps (eg. capture process errors), starts the init process (PID 0), etc... Start CDE desktop on AIX from text mode $ xinit /usr/dt/bin/dtsession NIS user rejected If you are using NIS an the gecos contains the word "root" (eg: Bart de Groot) the user will not be mapped unless you change the /var/yp/Makefile and replace `grep -v root` to `grep -wv root` or something Set window title # bash $ PROMPT_COMMAND='echo -ne "\033]0;xxxxxx\007"' # ksh $ print -n '\033]2;xxxxxxx\007' $ print -n '^[]2;xxxxxxx^G' (tested with putty en xterm settings) Java on AIX 4-step guide and other resources. Implementing and troubleshooting Java on AIX: Quick reference Redbook: Java Stored Procedure performance (applies to DB2 MQ Functions) NB: AIX5.3 contains -by default- a 64bit java version. Memory leaks These are dirty but they work: Attach:moni.memorydelta.sh.zip Attach:post_vg.sh.zip (IBM Reference: "AIX 5L Memory Leak Detection Script") Modify an RISC System/6000 executable to support "large memory model" Attach:lmm-set.sh.zip (The script modifies the program header to request that AIX allow multiple segment memory allocations.) Attach:lmm-check.sh.zip Sample usage: $ cp $(which who) ./who-copy $ sh lmm-set.sh who-copy Program to be zapped: who-copy previous value: 0000100 \0 005 \0 003 1 L \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 0000120 1+0 records in 1+0 records out new value: 0000100 \0 005 \0 003 1 L \0 \0 \0 \0 \0 \0 200 \0 \0 \0 0000120 $ sh lmm-check.sh "/usr/sbin/*" LMM enabled for file: /usr/sbin/fuser LMM enabled for file: /usr/sbin/rmsock NOTE: Use at your own risk, no guarantee! Extra: It is possible that the following will also work instead of the zap script, but i never verrified it... /usr/ccs/bin/ldedit -bmaxdata:0x80000000/dsa a.out Replace hdisk $ unmirrorvg rootvg hdisk0 $ chpv -c hdisk0 $ reducevg rootvg hdisk0 $ rmdev -dl hdisk0 $ ln /dev/rhdisk1 /dev/ipldevice $ bosboot -ad /dev/ipldevice $ bootlist -m normal hdisk1 Dump CHRP firmware (device table) /usr/lib/boot/bin/dmpdt_chrp Download IBM Performance Tools Performance Tools (perfpmr, etc.) nmon performance nmon analyse nmon consolidator Link between rpm and lpp The command enables the rpm command to recognize that the libraries have been installed using installp. /usr/sbin/updtvpkg AIX build-in firewall filter see FireWall Write big file dd if=/dev/zero of=bigf bs=1048576 count=1 Writes 1MiB file. VIO links Mapping Virtual Disks to Physical Disks SMT (POWER5 multithreading) Q. How would I know if my system is capable of using Simultaneous Multi-threading (SMT)? A. Your system is capable of SMT if it's a POWER5-based system running AIX 5L Version 5.3. * smtctl * lparstat [-i] * lsattr -El $(lsdev -Cc processor | grep Available | head -n 1 | cut -d' ' -f1) * lsdev -Cc processor -S A (returns the actual number of physical processors) LVM lowlevel commands to move 1 single PP In case of mirroring allocation problems or the need to free-up 1PP/disk to convert a VG to a BIG-VG you might need to move a single Physical Partition. There are 2 commands (AIX53) that can help you with this: migratelp and lmigratepp. SYNTAX: (no leading zeros, copynumbers are 1 to 3) migratelp LVname/LPartnumber[/Copynumber] DestPV[/PPartNumber] EXAMPLE: $ migratelp movemelv/1/2 hdisk12/134 SYNTAX: lmigratepp -g VGid \ -p SourcePVid -n SourcePPnumber \ -P DestinationPVid -N DestinationPPnumber EXAMPLE: $ lmigratepp -g 00582b6a00004c000000010e514b6f61 \ -p 00584d2a5e4d8e41 -n 0134 \ -P 00584d2a14dfdc7e -N 0001 Note: to choose your destination PPnumber you can use the output of `lspv -M hdiskpower14`. Undocumented low-level LVM commands Redbook: SG24-5433-00 AIX Logical Volume Manager from A to Z: Troubleshooting and Commands March 2000 Finding hotspots Hot spot management in logical volumes (eg. lvmstat) Logical volume and disk I/O performance (eg. filemon) jfs2 tuning Relevance of High Wait I/O In the past, a high wait I/O was a good predictor of a bottleneck. However, today it's a bit more complicated. High wait I/O may not imply an I/O bottleneck. You'll have to consider other factors, which is listed below. The reason high wait I/O may not be a good predictor is because CPU performance has significantly outpaced disk performance. Here's a situation that illustrates the point while replacing an older server with a new pSeries server. The new server has 6x the CPU performance (SAN storage stays the same). After the upgrade, wait I/O increases from 33% to 70% during batch jobs - the following table shows what happens. Variable Old Server New Server ==================================== Rel CPU Perf 1 6 Wait I/O 33% 75% Batch Times: CPU Time 40 min 7 min I/O Time 20 min 20 min ------ ------ Total Time 60 min 27 min The server upgrade improved CPU performance, but not I/O performance. The faster CPU's were able to do their job faster, hence they spent a higher percentage of their time waiting for disk I/O. Since batch time decreased by half the high wait I/O isn't a real problem. If you do not have anything to compare (upgrade and historic performance data) against it is harder to show and prove this. Hints: filemon disk response time reads should be under 10ms, and writes under 5 ms; spread the data over more disk drives; If running a database, can old data be archived and indexes rebuild? AIX53 LDAP users management (TL5 also includes AD enhancements) Filesystems refuse to unmount If lsof reports nothing, fuser without parameters reports nothing, then try: fuser -dVu /dev/somelv rsh and the rlogin attribute In smitty you find the following line: User can LOGIN REMOTELY(rsh,tn,rlogin)? It changes the rlogin attribute lsuser -a rlogin <user> From /etc/security/user * rlogin Defines whether the user account can be accessed by remote * logins. Commands rlogin and telnet support this attribute. * Possible values: true or false. From man rsh: "If you need to execute an interactive command on a remote host, use either the rlogin command or the rsh command without specifying the Command parameter. If you do not specify the Command parameter, the rsh command executes the rlogin command instead." Note on Secure shell: The attributes (like rlogin) only affect the ssh and scp commands if the "UseLogin" attribute is set to "yes" in the ssh daemon configuration file on the server. Usefull references: User account control man rsh man rshd /etc/security/user /etc/hosts.equiv man rhosts (.rhosts file) Conclusion The rlogin attribute does not affect rsh (or remsh) *with* command parameter specified. It does affect rsh *withouth* command parameter becourse then the rlogin client is actually triggered. At this time the rlogin attribute only affect rlogin (same as rsh withouth command), telnet and Secure shell if the UseLogin attribute is set. Knowing this, the part inbetween backets in "smitty user" is, at least, misleading! rsh and the rcmds option To controll rsh *with* command parameter (and also rexec) you should use the rcmds=deny option in /etc/security/user. rcmds Specifies whether the user account can be accessed with the rsh or exec commands. A value of allow indicates that the account may be accessed by rsh and rexec. A value of deny indicates no account access by rsh and rexec commands. A value of hostlogincontrol indicates that the account access is controlled by hostallowedlogin and hostsdeniedlogin attributes. rcmds=deny rexec, rsh, rcp, ssh, scp rcmds=hostlogincontrol and hostsdeniedlogin=<target_hosts> rexec, rsh, rcp, ssh, scp, rlogin, telnet, ftp, login Note: rcmds disallows execution of remote commands. Remote logins (rlogin) are still permitted. So to completely block rsh you need to set both the rlogin attrinbute and the rcmds option. JFS2 freeze/thaw See APAR: IY66043 http://www-1.ibm.com/support/docview.wss?uid=isg1IY66043 To freeze a filesystem: chfs -a freeze=<timeout in seconds> /fsname To thaw a filesystem: chfs -a freeze=off /fsname Online verification to check the LVCB and / or VGDA The mirscan command (introduced at 5.3 TL 3 I think). Note that this will generate significant amounts of I/O and takes a verry long time to run! mirscan -v vgname | -l lvname | -p pvname | -r reverse_pvname [ -a ] [ -o ] [ -q nblks ] [ -c lvcopy ] [ -s strictness ] [ -u upperbound ] -a Specifies that corrective action should be taken. print to ASCII file and backend scripts Example to setup a ASCII printer for printing to a file (all prints will be appended to the files). $ touch /dev/printfile $ smitty - ... - add print queue Add a Print Queue : file File (in /dev directory) Printer Type : Other ; generic Generic Printer New print queues to add: ASCII [printfile] (INITIALIZE printer? no) (Send FORM FEED after each file? yes) Result in /etc/qconfig printfile01: device = printfile01 printfile01: file = /dev/printfile01 header = never trailer = never access = both backend = /usr/lib/lpd/piobe Example of execution queue (invoke with: qprt -Psh myscript) /etc/qconfig sh: device = bshdev bshdev: backend = /usr/bin/ksh Example for backend scripting /etc/qconfig scr: device = scrdev scrdev: backend = /tmp/test1.sh /tmp/test1.sh #!/bin/ksh echo "newprint: $(date)" > /tmp/test1.out echo $* >> /tmp/test1.out echo $1 >> /tmp/test1.out echo $# >> /tmp/test1.out cat $1 >> /tmp/test1.out Usefull queue options: backend = /usr/lib/lpd/rembak -T120 recovery_type = sendmail [email protected] Tip: use remote printing to submit data. RMC subsystem keywords: ctrmc, rmcctrl The prefered method to restart the RMC susbsystem is not to use stopsrc or refresh but using rmcctrl. /usr/sbin/rsct/bin/rmcctrl -z /usr/sbin/rsct/bin/rmcctrl -A /usr/sbin/rsct/bin/rmcctrl -p Usefull print config commands $ enq -isA | grep DOWN | while read AA ZZ do print -n "$AA|" done; echo "" $ cat /etc/qconfig \ | grep -v "^*" \ | perl -p -e 's/^([^\t|\s])/\n\1/' \ | grep -p -E "xxx|yyy|zzz" \ | grep -E ":|host|rq" $ enq -isA | grep DOWN | while read AA ZZ do ls -ltr /var/spool/lpd/qdir/*:${AA}* | tail -1 done $ enq -A > /tmp/printerr.out 2>&1 $ sed '/^$/d' /tmp/printerr.out | grep -E "WARNING|ERROR" cleanup wtmp, sulog # convert binary to ASCII /usr/sbin/acct/fwtmp < /var/adm/wtmp > /tmp/wtmp # cut-off tail -1000 /tmp/wtmp > /tmp/wtmp2 # convert ASCII to binary /usr/sbin/acct/fwtmp -ic < /tmp/wtmp2 > /var/adm/wtmp # cut-off tail -1000 /var/adm/sulog > /tmp/sulog cat /tmp/sulog > /var/adm/sulog rm /tmp/wtmp2 /tmp/wtmp /tmp/sulog can i find the creation time of a file? No! All UNIX variants show you the access time of the file, modification time of the file and change time of the inode. Every time you change permissions or update the file inode this time is changed. for database files you will notice that all dates are the same :( istat, ls -li + fsdb or the perl stat function might be useful to you on AIX. User related commands I cannot remember pwdadm -q $USERNAME # Queries the status of the password pwdadm -c $USERNAME # Clears all password flags pwdadm -f ADMCHG $USERNAME # Resets the ADMCHG attribute lsuser -a time_last_login $USERNAME | cut -d = -f 2 | xargs perl -e 'print "time_last_login: ".localtime($ARGV[0])."\n"' lsuser -a account_locked $USERNAME chuser account_locked='true' $USERNAME chuser account_locked='false' $USERNAME lsuser -a unsuccessful_login_count $USERNAME chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s $USERNAME lsuser -a registry $USERNAME lsuser -a maxage $USERNAME lsuser -a minage $USERNAME ================== fast query export USERNAME= print -n "provide username: " ; read USERNAME ; lsuser -a time_last_login $USERNAME | cut -d = -f 2 | xargs perl -e 'print "time_last_login: ".localtime($ARGV[0])."\n"' ; lsuser -a unsuccessful_login_count $USERNAME ; lsuser -a account_locked $USERNAME ; lsuser -a registry $USERNAME ; pwdadm -q $USERNAME ; lsuser -a maxage $USERNAME ; lsuser -a minage $USERNAME finger | grep $USERNAME; who -u | grep $USERNAME; grep -p $USERNAME /etc/security/passwd; grep $USERNAME /etc/passwd mount all filesystems in a VG (reminder) Using this `( fsck -p $x && mount $x ) || break` in 1 single loop does not work, replay the logfile cannot be done if it is opened! fsck echo "Everything must be unmounted..." TIMESTAMP=$(date +%C%y%m%dT%H%M%S) for x in $( lsvg -l r3vld_vg01 | sed '1,2d' | grep " jfs. " | awk '{print $7}' | sort ) do echo "==========================================" echo "Checking $x ..." fsck -p $x | tee -a /tmp/fsck.$TIMESTAMP done grep -E "FIXED|SALVAGED|invalid" /tmp/fsck.$TIMESTAMP mount for x in $( lsvg -l r3vld_vg01 | sed '1,2d' | grep " jfs. " | awk '{print $7}' | sort ) do mount $x done umount for x in $( lsvg -l r3vld_vg01 | sed '1,2d' | grep " jfs. " | grep "open" | awk '{print $7}' | sort -r ) do umount $x done print to stderr print -u2 "data" echo "data" >&2 find reminders # old files $ find /oracle/FT5/sapcheck -xdev -mtime +730 -type f -name "*zip" -exec rm {} \; # bigest files $ find /var -ls -xdev | sort -nr +6 | head # search in files, mentione filename $ find /etc -type f -print | xargs grep "string" # pass more then 1 location for find to search $ ls -d sapdata* or* 920* 102* | xargs -I{} find {} -name "*\.tar*" -type f -ls # remove all files named a.out or *.o that have not been accessed for a week and that are not mounted using nfs $ find / \( -name a.out -o -name '*.o' \) -atime +7 ! -fstype nfs -exec rm {} \; # move $ find . -name "cntrl???.dbf" -exec echo mv {} /shredder/ \; disk size in MB bootinfo -s <hdiskXXX> gives you the size of the disk in MB Zie ook [[AIX, Zinvolle AIX Commando's]]