2161486 aix tip for command
Post on 10-Apr-2018
223 Views
Preview:
TRANSCRIPT
-
8/8/2019 2161486 AIX Tip for Command
1/24
AIX Tip of the Week: UNIX "join" Command
Audience: AIX Users
Date: December 1998
A little known, but useful, UNIX data manipulation tool is the join command. The function of the join commjoin. It combines common lines from two sorted text files based on a common field. The output of the join co
remainder of each line from both files. Unmatched lines are not included in the output.
The following example illustrates the use of the join command. In this example, a hypothetical inventory file
on the part number. The inventory file is a two column file containing a list of part numbers and its quantity ocolumn file containing the part number and its description. The common field between the two files is the par
the part number.
Example
$ cat description.txtPart Number; Description1; Pencils2; Erasers3; Paper Clips, Regular3A; Paper Clips, Large4; Paper, Regular 8.5x114A; Paper, Legal Size5; Envelope6; Staples7; Tape8; Hole Punch9; Glue
10; Pen, Blue10A; Pen, Red10B; Pen, Black10C; Pen, Green....etc...
$ cat inventory.txtPart Number; Quantity on Hand1; 43; 163A; 244; 06; 18; 810; 210B; 14....etc....
$ join -t";" inventory.txt description.txtPart Number; Quantity on Hand; Description1; 4; Pencil3; 16; Paper Clips, Regular3A; 24; Paper Clips, Large4; 0; Paper, Regular 8.5x11
-
8/8/2019 2161486 AIX Tip for Command
2/24
6; 1; Staples8; 8; Hole Punch10; 2; Pen, Blue10B; 14; Pen, Black....etc....
Note that only the matching lines are displayed. Unmatched lines are discarded. See the man page for the join
AIX Tip of the Week: Accesing Remote Tape Drives
Audience: AIX Users and Administrators
Date: April 1999
One of the advantages of UNIX is the ability to share remote devices, such as tape drives. The "rdump/rrestorbackup/restore files to a tape drive on a remote system. However, because these commands require a ".rhost"
security exposure.
One alternative is to use the more secure "rexec" command which prompts for a user id/password. The follow"rexec" command to access remote tape drives. In this example, the "tape_host" is the TCP-IP hostname of th
"data_host" is the system where the files reside. The example also assumes you have a valid user id/password
To create a backup to a remote system with a tape, issue the following command from the "data_host."
tar -cvf - * | dd bs=1k | rexec tape_host "dd bs=1k of=/dev/rmt0"
To restore this tape, issue the following command from the "tape_host" system.
dd bs=1k if=/dev/rmt0 | rexec data_host "dd bs=1k | tar -xvf-"
The general concept illustrated above can be extended to other remote devices such as diskettes, CD-ROMs a
AIX Tip of the Week: Using an RS/6000 System with a Graphics Display as an "X" Termina
Audience: AIX Users
Date: May 7, 1999
Any RS/6000 with a graphics terminal can be used as an "X" terminal**. An "X" terminal functions as a grapa TCP/IP network. The following command starts a CDE session from a remote host on a local graphics displ
X -query "remote_host_name"
Where "remote_host_name" is the TCP/IP name of the remote host. To run this command, you must be logge
-
8/8/2019 2161486 AIX Tip for Command
3/24
display in the command line mode.
The following keystroke combination terminates the session:
Ctrl-Alt-Backspace
This command should work for any combination of UNIX systems that support X11 and XDM, including Su
Comments:
1. Prerequisites: X11 and xdm software must be installed on both hosts. Both are included int the AIX b
by default, but xdm may/may not be installed depending on the AIX.
2. My tests indicate that this command may fail on systems with multiple network adapters.
Audience: AIX Administrators and End Users
Date: November 12, 1999
Highlighting text on computer terminals is useful for drawing attention to important information. To highligh
sessions, use the "tput" command. The types of highting available with "tput" includes blinking, bold, reverse
The attached "today" script uses the "tput" command to highlight today's date in the output of the "cal" comm
July 1999Sun Mon Tue Wed Thu Fri Sat
1 2 34 5 6 7 8 9 1011 12 13 14 15 16 1718 19 20 21 22 23 2425 26 27 28 29 30 31
** Depends on the terminal's capability. Some ASCII terminals/emulators don't support all of the tput options
more information.
#!/usr/bin/ksh# Script Name: today# v1.0 Calendar with today's date highlighted# Bruce Spencer, IBM
# tput commands to control highlighting# note: some terminals do not support all tput optionsRVR=`tput smso` # reverseEND_RVR=`tput rmso` # end reverseBLNK=`tput blink` # blinkUNDER=`tput smul` # underlineEND_UNDER=`tput rmul` # underlineCLEAR=`tput clear` # clear screenBELL=`tput bel` # bell soundBOLD=`tput bold` # boldDIM=`tput dim` # dimINVIS=`tput invis` # invisibleEND=`tput sgr0` # turn off dim, blink, bold, dim, invisible
-
8/8/2019 2161486 AIX Tip for Command
4/24
# Clear Screenecho ${CLEAR}
# Convert month abbreviation to month numberset `date`case ${2} in
Jan) MONTH=1;;Feb) MONTH=2;;Mar) MONTH=3;;Apr) MONTH=4;;May) MONTH=5;;Jun) MONTH=6;;Jul) MONTH=7;;Aug) MONTH=8;;Sep) MONTH=9;;Oct) MONTH=10;;Nov) MONTH=11;;Dec) MONTH=12;;*) MONTH=0;;esac
DAY=`echo ${3} | sed "s/^0//"`cal $MONTH ${6} | sed "s/ ${DAY}/ ${RVR}${DAY}${END_RVR}/"
# Examples of different formatting# echo "${UNDER}Underline: Happy Thanksgiving!${END_UNDER}"# echo "${BOLD}Bold: Happy Thanksgiving!${END}"# echo "${DIM}Dim: Happy Thanksgiving!${END}"# echo "${BELL}BELL: Happy Thanksgiving!${END}"# echo "${INVIS}Invisible: Happy Thanksgiving!${END}"# echo "${BLINK}Blink: Happy Thanksgiving!${END}"
Finding Files Containing a String
Audience: AIX Administrators
Date: December 10, 1999
Here's a useful technique for searching for files in all subdirectories which contain a specific string.
find . -type f -print | xargs -i grep -il "searchstring" {}
where:
"searchstring" is the desired search string"find . -type f -print" lists all files in the current directory and it subdirectories
"xargs" feeds the file names from the pipe into the grep command at the curly braces {}The "grep -il" lists the files containing the "searchstring" (-i = case insensitive)
I use this command to find files on a web site that contain references to specific URL. Another variation wou
"searchstring" with another string by changing the "grep" to "sed" command. To save typing, put this comma
#!/usr/bin/ksh# Script name: locatefind . -type f -print | xargs -i grep -il "$1" {}
To run, type locate searchstring, where searchstring" is the name of the search string.
-
8/8/2019 2161486 AIX Tip for Command
5/24
Working with Diskettes in AIX
Audience: AIX Users
Date: January 7, 2000
The following is a list of the most common commands for reading floppy diskettes in AIX.
Diskette Format Command to View Diskette Commen
PC DOS dosdir -l Part of th
Related cdosforma
Unix tar -tvf /dev/rfd0
Unix restore -Tvq Diskettescomman
Unix cpio -itv
-
8/8/2019 2161486 AIX Tip for Command
6/24
files that have changed in the past 24 hours. Here's a trick to identify these files. The trick involves creating a
the end of the desired time frame, then using the find command's "-newer" flag to locate the files.
touch -t mmddhhmm touched_file
find / -newer touched_file -ls
Where:
touched_file is any file name you choose
mm is month
dd is day
hh is hour (24 hour format)
mm is minute
This trick is useful for finding log files with new entries, or files that are filling up a directory. Other useful fi
identifying files larger than nn blocks, "-user" for locating file by user, and "-type" by type of file. See the AIX
The following Korn shell script illustrates the use of these commands.
#!/usr/bin/ksh# Purpose: identify files starting in the current directory# that have changed *today* within the past nn hours# You'll have to modify this script to work around midnight# Bruce Spencer, IBM 2/11/00USAGE="Usage: $0 n \t\t\t# where n= 1-24 hours"
# check for syntax errors
if [[ $# -ne 1 ]] thenecho $USAGEexit 1
fi
if [[ $1 -gt 24 ]] thenecho $USAGEexit 1
fi
HH=$(date +%H)
if [[ $1 -gt $HH ]] then
echo "Error: The requested time span $1 is greater than current time $HH"exit 1
fi
# Passed checks
let hh=HH-$1
if [[ $hh -lt 10 ]] then#hours must be two digitstimestamp="$(date +%m%d)0${hh}00"
elsetimestamp="$(date +%m%d)${hh}00"
-
8/8/2019 2161486 AIX Tip for Command
7/24
fi
# Create a "touch file" in /tmp to avoid write permissions problemtouch_file="/tmp/${LOGNAME}junk"
touch -t $timestamp $touch_filefind . -xdev -type file -newer $touch_file -lsrm $touch_file
AIX Tip of the Week: Using the Korn Shell select to Create Selection Menu's
Audience: AIX Administrators and End Users
Date: May 11, 2000
The Korn shell select command can be used to create a selection menu. To illustrate, the attached shell script for a hypothetical operator console:
XYZ Operator Console
1) SystemBackup2) ListActiveUsers3) ManageDatabase4) MonitorPerformance5) Quit
Choose a number:
Korn Shell Script that Creates Above Menu
#!/usr/bin/ksh# Shell script to illustrate the use of# the Korn shell "select" command# to create selection menus# B.Spencer 5/11/00
echo "XYZ Operator Console"echo
# PS3 is an environment variable# that sets the menu promptPS3="Choose a number: "
# The select command creates the menuselect CHOICE in SystemBackup ListActiveUsers ManageDatabase MonitorPerformance Quitdocase $CHOICE in
SystemBackup) mksysb -i /dev/rmt0;;ListActiveUsers) who;;ManageDatabase) svrmgr;;
MonitorPerformance) topas;;Quit) exit;;
*) echo "\nInvalid Choice\n";;esac
done
-
8/8/2019 2161486 AIX Tip for Command
8/24
AIX Tip of the Week: Use Perl to Create Web Pages
Audience: AIX Administrators and End Users
Date: June 6, 2000
Perl (Practical Extraction Report Language) is a programming language that combines the best features of sed
convenience of shell scripts. Some of Perl's uses include:
Write shell scripts
Extract/combine data from one or more files
"Clean" data prior to importing into a database
Create CGI programs to dynamically build web pages.
The attached Perl programs illustrate some of these capabilities. The first, mk-index.pl, builds the AIX
http://www.aiche-norcal.org/AIXtip. It builds the index page by extracting descriptive information frosorts the tips by category, builds the HTML file with hyperlinks, and appends a red "New" label if themk_index.pl
Perl is standard in AIX 4.3.3, and can be obtained for prior releases fromhttp://www-frec.bull.com/cg
AIX Tip of the Week: Simplifying I/O Redirection
Audience: AIX Users
Date: December 8, 2000
One way to capture the results of multiple commands in a file would be:
cmd1 > $resultscmd2 >> $results:cmdN >> $results
Another way would be to use the Korn shell "grouping" syntax, which we could use to rewrite the above as:
( cmd1
cmd2:cmdN
) > $results
The grouping technique has several advantages, including less typing, reduced I/O overhead (N file opens vs
such as using a ">" that erases all the accumulated data in the file.
AIX Tip of the Week: Using AIX's "skulker" Command to Purge Unwanted Files
http://www.aiche-norcal.org/AIXtiphttp://users.ca.astound.net/baspence/AIXtip/mk_aiche.plhttp://www-frec.bull.com/cgi-bin/list_dir.cgi/download/out/http://www-frec.bull.com/cgi-bin/list_dir.cgi/download/out/http://www.aiche-norcal.org/AIXtiphttp://users.ca.astound.net/baspence/AIXtip/mk_aiche.plhttp://www-frec.bull.com/cgi-bin/list_dir.cgi/download/out/ -
8/8/2019 2161486 AIX Tip for Command
9/24
Audience: Systems Administrators
Date: September 1, 2000
AIX'sskulkercommand is a shell script that can be used to periodically purge obsolete or unneeded files. Th
cron job during off-peak periods (uncomment the "skulker" line in root's crontab). You can modify skulkertosee:
http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/skulker.htm
AIX Tip of the Week: Using stty to Set Backspace Key
Audience: AIX Users
Date: October 22, 2000
Sometimes when you telnet into a system,the backspace key produces output similar to:
$ lss^[[2~^[[2~^[[2~
To fix, type:
$ stty erase "BackspaceKey"
The permanent solution is to edit your ".profile" and insert the following line:
stty erase '^H'
AIX Tip of the Week: Using a Web Browser to FTP Files
Audience: AIX Users
Date: November 25, 2000
Any web browser can be used to ftp files using the standard URL syntax:
ftp://username:password@remote_host_name **
For security reasons, you should not include the password in the URL. The system will prompt for the missin
-------
**Note: the full URL ftp syntax is
http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/skulker.htmhttp://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/skulker.htm -
8/8/2019 2161486 AIX Tip for Command
10/24
ftp://username:password@remote_host_name:port/path;type=[a,d,i]
Whereport = the port number for ftp (if different from standard)
path = the directory path, relative to the user id's home directory
type = transfer type: a = ascii, d = directory listing, i = binary (default)
AIX Tip of the Week: Perl Trick to Edit Multiple Files with One Command
Audience: AIX Users
Date: January 20, 2001
Here's a Perl trick that can simplify editing multiple files to make the same change. To illustrate, the followin
"LOTUS" to "IBM" in all files in the current directory.
$ perl -p -i -e "s/LOTUS/IBM/g" *
As with any global change command, be sure to back up the files before running the command.
Determining the Size of AIX Memory
Audience: Systems Administrators
Date: February 16, 2001
This week's tip provides two useful commands for determining the size of AIX memory.
For non root users, use the command:
lsattr -El sys0 | grep realmem
A simpler command for root users is:
bootinfo -r
To determine what is occupying memory, use the svmon command. Only root can run the svmon command.
http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/svmon.htm
http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/aixbman/prftungd/2365c71.htm
Installing and Using AIX "man" Pages
http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/svmon.htmhttp://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/aixbman/prftungd/2365c71.htmhttp://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/svmon.htmhttp://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/aixbman/prftungd/2365c71.htm -
8/8/2019 2161486 AIX Tip for Command
11/24
Audience: Users
Date: March 9, 2001
The "man" command provides online help for AIX commands. The most common form is
man command
which lists the help page for "command". If you don't know the name of a command, or if you want to find re
option:
man -ksearchstring
Man pages are not installed by default in AIX. The following filesets must be installed for man to work. The f
Documentation CD.
bos.html.en_US.topnav.navigate - Top Level Navigation
bos.html.en_US.nav - Online Navigationbos.html.en_US.cmds.cmds1 - AIX Commands Reference 1bos.html.en_US.cmds.cmds2 - AIX Commands Reference 2bos.html.en_US.cmds.cmds3 - AIX Commands Reference 3bos.html.en_US.cmds.cmds4 - AIX Commands Reference 4bos.html.en_US.cmds.cmds5 - AIX Commands Reference 5bos.html.en_US.cmds.cmds6 - AIX Commands Reference 6
The following filesets are optional, for AIX system calls
and C library functions, respectively.
bos.html.en_US.techref.base - AIX Base Tech Refbos.html.en_US.techref.commo - AIX Commo Tech Ref
Using "infocmp" To Create Terminfo Files
Audience: Systems Administrators
Date: June 14, 2001
When a telnet session does not correctly display full screen applications (like vi and smitty), the problem is u
definitions. The solution is to copy the "terminfo" file for the terminal to the remote server. If a terminfo file ithe infocmp command.
To illustrate, here's how you can create a LINUX terminal definition for AIX, which does not have one.
On the Linux machine:
infocmp -I > linux.ti
-
8/8/2019 2161486 AIX Tip for Command
12/24
rcp linux.ti aixhost:/usr/lib/terminfo/linux.tirsh aixhost "tic /usr/lib/terminfo/linux.ti"telnet aixhost
The infocmp flag is an uppercase "i". The "aixhost" is the host name of the remote AIX system. This procedu
ftp Checkpoint Restart
Audience: AIX Users
Date: August 10, 2001
The AIX 4.3 ftp restart command allows you to resume an aborted file transfer at the point it stopped. This cunstable connections because if the connection fails, you only have to transfer the remaining portion of the fi
The restart command did not work per the AIX documentation. Here's the procedure I tested. After an aborte
Log onto the remote host, and "cd" to the target directory. Then issue the commands:
restart
put
Where is the size of the aborted file, in bytes.
The restart option is not 100% portable: I've successfully tested "restart" on AIX systems and between AIX/L
Windows, and it does not appear to be an option in the Solaris documentation.
Listing the AIX System Configuration
Audience: All
Date: January 30, 2002
You can use the prtconfcommand to list your AIX hardware configuration. including CPU's, memory, adapt
command is available the current version of AIX 4.3.3**, and on AIX 5. For those running older versions of Aprovide the same information.
General
prtconf - list system configurationlscfg [-v] - devices (-v = verbose for microcode levels, etc)lscfg -v - devices verbose (microcode level, firmware, etc)lsdev -Cc adapter - adapter cardslsdev -Cc disk - diskslsdev -Cc processor - CPU'slsattr -El sys0 - serial number, model number, memory
AIX
oslevel - AIX OS level
-
8/8/2019 2161486 AIX Tip for Command
13/24
instfix -i |grep ML - AIX maintenance levellslpp -l - installed SW and levels
Disk
lsvg -o - active volume groupslsvg -p vgname - disk drives in VGlsvg -l vgname - LV's in VGlslv lvname - LV detaillslv -l lvname - LV disk locationlspv - diskslspv -l hdisk# - LV's residing on a disk
Network
lsdev -Cc if -List network interfacesnetstat -rn -List network gateways
**If you can't upgrade to the current version of AIX, you can still download the prtconftool fromhttp://www
64 Bit Commands
Audience: Administrators
Date: February 9, 2002
Updated: 5/28/02
There are two common misconceptions about 64-bit applications. First, the 64 bit applications run faster. Sec
kernel.
64-bit applications improve performance when they can access more than 2 GB memory (a 32 bit limitation)
magnitude faster than disk. Otherwise, 64 bit performance is comparable to a 32 bit application.
Another misconception is that you need a 64 bit kernel to run a 64 bit applications. Both 32 and 64 bit kernelrequires the 64 bit extensions.
Here are a couple useful "64 bit" commands:
The bootinfo -y command tells whether the hardware is 32 or 64 bit enabled. Generally all hardware since th
The svmon -P . command lists whether a running application is 32 or 64 bit. It's listed under column
output. (This command also shows whether the application is multithreaded under the "Mthrd" column.)
The bootinfo -Kshows whether the kernel is running 32/64 bit. This command only works for AIX 5 which
(AIX 4 only runs a 32-bit kernel.) The administrator chooses which kernel at install time.
Another way to determine which kernel is running is the command: genkex | grep 64. You should see someth
http://www.alphaworks.ibm.com/tech/systemvhttp://www.alphaworks.ibm.com/tech/systemvhttp://www.alphaworks.ibm.com/tech/systemv -
8/8/2019 2161486 AIX Tip for Command
14/24
149bf58 a3ec /usr/lib/drivers/syscalls64.ext
Determing the CPU Clock Speed
Audience: All
Date: December 3, 2002
In AIX 5.1 pmcycles command lists the processor speed. The pmcycles command is part of the "bos.pmapi.p
If you have an AIX 4.3 system, the "uname -m" command provides a code that identifies the CPU. For more
http://publib.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixbman/prftungd/2365ax5.htm
http://publib.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixbman/prftungd/2365ax5.htmhttp://publib.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixbman/prftungd/2365ax5.htm -
8/8/2019 2161486 AIX Tip for Command
15/24
Appendix D. Determining CPU Speed
With operating system versions later than 4.3.3, the pmcycles command (part of the perfagent.tools fileset) mPerformance Monitor counters. The speed is returned in Mhz. The pmcycles options are as follows:
-m
Run on all processors
-dPrint decrementer speed
An example is as follows:
# pmcyclesThis machine runs at 451 MHz
If you are not on operating system version later than 4.3.3, there is no direct command to determine processo
uname command. Running the uname -m command produces output of the following form:
xxyyyyyymmss
where:
xx
00
yyyyyyUnique CPU ID
mm
Model ID (the numbers to use to determine CPU speed)
ss00 (Submodel)
By cross-referencing the mm values from the uname -m output with the table below, you can determine the pr
Model ID Machine Type Processor Speed Architecture02 7015-930 25 Power10 7013-530 25 Power10 7016-730 25 Power11 7013-540 30 Power14 7013-540 30 Power18 7013-53H 33 Power1C 7013-550 41.6 Power
20 7015-930 25 Power2E 7015-950 41 Power30 7013-520 20 Power31 7012-320 20 Power34 7013-52H 25 Power35 7012-32H 25 Power37 7012-340 33 Power38 7012-350 41 Power41 7011-220 33 RSC43 7008-M20 33 Power43 7008-M2A 33 Power46 7011-250 66 PowerPC47 7011-230 45 RSC
48 7009-C10 80 PowerPC
-
8/8/2019 2161486 AIX Tip for Command
16/24
Using the "date" Command to Determine the Last Day of the Month
Audience: All
Date: October 31, 2003Updated: November 9, 2003
Determining the last day of a month in a shell script can be complicated because each month has a different nyear. Here's a trick with the "date" command that simplifies this calculation. I use it to archive rotating month
reports.
#!/usr/bin/ksh
# Pacific Time: TZ=-16 (see below for explanation)if [ `TZ=-16 date +%d` = "01" ]; then
# Run these commands ...
fi
The timezone setting (TZ) setting tricks the date command into thinking it is 24 hours ahead. The syntax is co
forward, and a "+" sign means backward. Second, "TZ" is relative to GMT time. To illustrate, here are a few one day:
GMT: TZ=-24
EST: TZ=-19CST: TZ=-18
PST: TZ=-16
This trick can be used to calculate yesterday, tomorrow or two weeks from now.
Subject: Is There an AIX "unerase" Command?
Audience: Administrators
Date: April 26, 2004
Unfortunately, there is no "unerase" command in Unix. The best alternative is to restore from a backup (You
As a last resort, you can try a data recovery tool, such as the one at
http://www.compunix.com
(For others, search the web for "aix data recovery".) However, don't depend on these tools to recover data. No
A better strategy is prevention. My suggestions are
1. Never work as root for non administration tasks. Work as a regular user id
2. Alias the "rm" command as "rm -i".3. Copy files before editing
4. Make regular backups
http://www.compunix.com/http://www.compunix.com/ -
8/8/2019 2161486 AIX Tip for Command
17/24
-
8/8/2019 2161486 AIX Tip for Command
18/24
-
8/8/2019 2161486 AIX Tip for Command
19/24
-
8/8/2019 2161486 AIX Tip for Command
20/24
-
8/8/2019 2161486 AIX Tip for Command
21/24
-
8/8/2019 2161486 AIX Tip for Command
22/24
-
8/8/2019 2161486 AIX Tip for Command
23/24
-
8/8/2019 2161486 AIX Tip for Command
24/24
top related