AIX useful commands
2012.04.26 23:32
원문 : http://www.ischo.net -- 조인상 // 시스템 엔지니어
Writer : http://www.ischo.net -- ischo // System Engineer in Replubic Of Korea
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
원문 : http://www.ischo.net -- 조인상 //시스템 엔지니어
+++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
Useful Disk Drive and Related AIX Commands:
The backup command creates copies of your files on a backup medium, such as a magnetic tape or diskette. 
Example : 
1. To backup file name system.data from current directory to floppy diskette, enter 
ls system.data | backup -i
Purpose : Configures devices and optionally installs device software by running the
programs specified in the Configuration Rules object class. 
Syntax  : cfgmgr [ -f | -s | -p Phase ] [ -i Device ] [ -l Name ] [ -v ] 
Flags   : 
    -l Name : Specifies the named device to configure along with its children. 
    -v      : Specifies verbose output. The cfgmgr command writes information about what it 
is doing to standard output. 
Example : 
To configure detected devices attached to the SCSI0 adapter, enter: 
cfgmgr -vl scsi0
To configure hdisk1, enter: 
cfgmgr -vl hdisk1
The dd command reads the InFile parameter or standard input, does the specified conversions, 
then copies the converted data to the OutFile parameter or standard output. 
Command to save data from a boot drive 
VGDA(Volume group descriptor area) : (if booted from disk, if not use /dev/hdiskN,
substituting the boot drive number)
dd if=/dev/ipldevice of=/tmp/vgda.orig bs=1024b count=2
BLV(Boot logical volume) : (Make sure lsvg -l rootvg shows type "boot" for LV NAME hd5, 
then:) 
dd if=/dev/hd5 of=/tmp/path/to/blv.orig bs=1024b
Purpose : Reports information about space on file systems. 
Syntax  : df [ [ -P ] | [ -I | -M | -i | -t | -v ] ] [ -k ] [ -s ] [FileSystem ... | 
File... ] 
Description : 
The df command displays information about total space and available space on a file system. 
Examples 
1.To display information about all mounted file systems, enter: 
df
2.To display available space on the file system in which your current directory resides, 
enter: 
cd /directory-name 
df . 
 
diag Command 
Purpose: Command line diagnostics 
To run microcode download, enter: 
diag -c -d  hdisk#   -T"download -F" 
To identify physical disks on PCI Raid, enter: 
diag -c -d hdisk# -T"identify" 
To make a diag trace, enter: 
touch /tmp/.DIAG_TRACE 
this will create a file called  ".dt.mcode" 
To get VPD data for disks attached to RAID:   
disg -cd scraidX -T "identify" 
AIX supported dos commands 
dosdel Command 
Purpose : Deletes DOS files. 
Syntax  : dosdel [ -v ] [ -D Device ] File ... 
-Ddevice : Specifies the name of the DOS device as /dev/fd0 or /dev/fd1. The default 
device is /dev/fd0. 
-v       : Writes information to standard output about the format of the disk. Use 
this flag to verify that a device is a DOS disk. 
Examples : 
To delete a DOS file on the default device, enter:     
dosdel file.ext 
----------------------------------------- 
dosdir Command 
Purpose : Lists the directory for DOS files. 
Syntax  : dosdir [ -l [ -e ] ] [ -a ] [ -d ] [ -t ] [ -v ] [ -D Device ] [ File ... | 
Directory ... ] 
Examples: 
To read a directory of the DOS files on /dev/fd0, enter:  
dosdir 
To read a directory of the DOS files on /dev/fd1, enter:   
dosdir -D/dev/fd1 
--------------------------------------------- 
dosformat Command 
Purpose : Formats a DOS diskette. 
Syntax  : dosformat [ -V Label ] [-D Device | -4 ] 
Examples: 
1.To format a 3.5-inch, 1.44M-byte diskette with the volume label "homework," type the 
following: 
dosformat -V homework 
--------------------------------------------- 
dosread Command 
Syntax  :  dosread [ -a ] [ -v ] [ -D Device ] File1 [ File2 ] 
Description : The dosread command copies the DOS file specified by the File1 variable to 
standard output or to the AIX file specified by the File2 variable. If no 
pathname is specified for the File2 variable, the DOS file is copied to 
the root directory. 
Examples 
To copy a text file from a DOS diskette to the AIX file system,enter: 
dosread -a chap1.doc chap1 
This command sequence copies the DOS text file \CHAP1.DOC on default
device /dev/fd0 to the AIX file chap1 in the current directory. 
---------------------------------------------- 
doswrite Command 
Syntax :  doswrite [ -a ] [ -v ] [ -DDevice ] File1 File2 
Description : The doswrite command copies the AIX file specified by the File1 parameter 
to the DOS file specified by the File2 parameter. The doswrite command 
copies files to a single DOS diskette.
Examples 
To copy a text file from the AIX file system to a DOS diskette, enter: 
doswrite -a chap1 chap1.doc 
This copies the AIX file chap1 in the current directory to the DOS text file \CHAP1.DOC on default device /dev/fd0. 
Description : Deletes entries from the error log 
Examples : 
1.To delete all entries from the error log, enter: 
errclear 0 
2.To delete all entries in the error log classified as hardware errors, enter: 
errclear -d H 0 
Description : The errlogger command creates an operator error log entry that contains an 
operator message up to 230 bytes in length. 
Example     : To create an operator message for system drive reconfiguration, enter: 
errlogger system drive reconfigured. 
Description 
The errpt command generates an error report from entries in an error log. 
Flags
-a                  Displays information about errors in the error log file in detailed  
format. 
-d ErrorClassList : Limits the error report to certain types of error records specified 
by the valid ErrorClassList variables: H (hardware), S (software), 0 (errlogger command messages),  and U (undetermined). The ErrorClassList variable can be separated by , (commas), or enclosed in "" (double quotation marks) and separated by , (commas) or space characters. 
-J ErrorLabel     : Includes the error log entries specified by the ErrorLabel variable. 
The ErrorLabel variable values can be separated by commas or enclosed in double-quotation marks and separated by commas or blanks. When combined with the -t flag, entries are processed from the error template repository. (Otherwise, entries are processed from the error log repository.) 
Examples : 
1.To display a complete summary report, enter: 
errpt 
2. To display a complete detailed report, enter: 
errpt -a 
3. To display all hardware errors, enter: 
errpt -adH 
4. To display a detailed report of all errors logged for the error label  DISK_ERR4, 
enter: 
errpt -a -J DISK_ERR4 
File System Commands 
chfs : Change File System Size 
       chfs -a size=<new size>  <file system>
example: to change /tmp size,   
chfs -a size=32000 /tmp 
lspv : Displays information about a physical volume within a volume group 
       lspv -p hdiskx 
lsvg : Displays information about volume groups(breakdown of LV) 
       lsvg -L rootvg 
To find where anLBA falls on the disk directory structure: 
Find Byte offset :  LBA=  06DD107 (Byte offset= 06DD107*200=DBA20E00 ) Find PP size 
[if PP size = 16M, then use 16*1034^2= 0x1000000,  PP size 32M=x2000000] 
Divide Byte offset by PP size : 0xDBA20E00 / 0x1000000 = 0xDB [219 decimal] 
Find where PP= 219 falls using lspv command, in this example, it is = hd4 = (/) 
ftp Command: 
Transfers files between a local and a remote host. 
get    To download a file 
put    To upload a file 
Note: use "b" for binary file transfer. 
quit   To quit the ftp connection 
Use "mget" and "mput" for multiple file transfer. 
lquerypv Command 
View the content of physical volume(PV) 
Syntax : 
lquerypv -h /dev/hdiskN  hex_start  hex-length 
Example : 
lquerypv -h /dev/hdisk1 0 1000 
displays the first 1000 Bytes stored on physical disk "hdisk1". 
Note : Byte 1000 has drive DEFECT info lquerypv -h /dev/hdisk1 1000 
Description
The ls command writes to standard output the contents of each specified Directory parameter or the name of each specified File parameter, along with any other information you ask for with the flags. If you do not specify a File or Directory parameter, the ls command displays the contents of the current directory. 
To copy error log to a diskette, enter: 
ls /var/adm/ras/errlog | backup -ivp 
To copy microcode to a diskette, enter: 
ls /etc/microcode/file_name |backup -ivq 
To copy error log to a tape, enter: 
ls /var/adm/ras/errlog | backup if /dev/rmtX 
To create a diskette of microcode download, enter: 
ls /etc/microcode/file_name | backup -ivq 
lsattr Command 
Purpose : Displays attribute characteristics and possible values of attributes for devices 
in the system. 
Syntax
lsattr { -D [ -O ] | -E [ -O ] | -F Format } -l Name [ -a Attribute ] ...[ -f File ]
   [ -h ] [ -H ] 
Description
The lsattr command displays information about the attributes of a given device or kind of device. If you do not specify the device logical name (-l Name), you must use a combination of one or all of the -c Class, -s Subclass, and -t Type flags to uniquely identify the predefined device. 
You must specify one of the following flags with the lsattr command: 
-D         Displays default values. 
-E         Displays effective values (valid only for customized devices 
specified with the -l flag). 
-F Format  Specifies the user-defined format. 
-R         Displays the range of legal values. 
Examples
    1.To list the current attribute values for the SCSI adapter scsi0, enter: 
lsattr -l scsi0 -E 
Displays configuration, diagnostic, and vital product data (VPD) information about the system.  Use the lscfg command to display vital product data (VPD) such as part numbers, 
serial numbers, and engineering change 
Usage   : lscfg [ -rv ] | [ [ -r ] | [ -v ] [ -l Name ] ] 
Example : 
1. To display the VPD for all DASD devices, enter: 
lscfg -vl hdisk* 
The system displays information for the DASD(hdisk) devices , as follows: 
DEVICE  LOCATION            DESCRIPTION
hdisk0 04-B0-00-2,0  2.2 GB SCSI Disk Drive
Manufacturer................IBMRISC
Machine Type and Model......DFHSS2F
Part Number.................74G6976
ROS Level and ID............34323432
Serial Number...............68C26279
EC Level....................486509
FRU Number..................74G6996
Device Specific.(Z0)........000002029F00001E
Device Specific.(Z1)........RAMST04B
Device Specific.(Z2)........09RI
Device Specific.(Z3)........96221
Device Specific.(Z4)........0002
Device Specific.(Z5)........22
Device Specific.(Z6)........E28308
2. To get a hard copy of hdisk configuration, enter: 
lscfg -vl hdisk* > /dev/lpo 
3. To display VPD for all devices, enter: 
lscfg -vp 
4. To display system FW, enter: 
lscfg -vp |grep alterable 
Purpose     : Displays devices in the system and their characteristics. 
Description : The lsdev command displays information about devices in the Device 
Configuration database. You can display information about all devices in the Customized Devices object class using the -C flag. 
-C          Lists information about a device that is in the Customized Devices object class. 
The default information displayed is name, status, location, and description. This flag cannot be used with the -P flag. 
-c Class    Specifies a device class name. This flag can be used to restrict output to 
devices in a specified class. 
Example : To list the disks that are in the Customized Devices object class, enter:  
lsdev -Cc disk 
  The system displays a message similar to the following: 
  hdisk0 Available 04-B0-00-2,0 2.2 GB SCSI Disk Drive 
lsdev -C |grep scsi    to find scsi# 
Displays information about a logical volume. 
Display Physical Volume of hard disk drive 
Usage   : lspv <hdisk#>; 
Example : <lspv hdisk0> will display physical volume of hard disk 0 
Lists software products 
Usage :  lslpp {-d|-f|-h|-i|-L|-l|-p} [-B | -I] [-acJq] [-O{[r][s][u]}] [fileset ... | 
ptf_id ... | all]        OR
lslpp -w [-cq] [-O{[r][s][u]}] [ filename ... | all ] 
Example : To display software(device drivers, diags, etc) for SCSI devices, type 
lslpp -l *.scsi.* 
Displays system resources for available devices in the system. 
Example : 
1.To list bus attributes for the token ring device, enter: 
lsresource -l tok0 
The system displays a message similar to the following: 
TYPE   DEVICE         ATTRIBUTE       S G CURRENT VALUE 
----- --------------  --------------- - - ----------------------- 
M     tok0            dma_bus_mem         0x003b2000 - 0x003f1fff 
O     tok0            bus_io_addr         0x000086a0 - 0x000086af 
N     tok0            bus_intr_lvl                  3 
A     tok0            dma_lvl                       7 
Purpose :  Displays information about volume groups. 
Syntax  :  lsvg [ -L ] [ -o ] | [ -n DescriptorPhysicalVolume ] | [ -i ] [ -l | -M | -p ] 
VolumeGroup ... 
Example : 
1. To display the names of all active volume groups, enter: 
lsvg -o 
2. To display the names of all volume groups within the system, enter: 
lsvg 
3. To display information about volume group vg02, enter: 
lsvg vg02 
Purpose : Creates an installable image of the root volume group either in a file or onto a 
bootable tape. 
Syntax : mksysb [ -b Number ] [ -e ] [ -p ] [ -v ] [ -X ] [ -i | -m ] Device | File
odmget command: 
Retrieves objects from the specified object classes into an odmadd input file. 
Syntax   : odmget [ -q Criteria ] ObjectClass ... 
Examples : 
odmget PdDv 
odmget -q class=disk PdDv 
odmget -q "name=hdisk1" CuAt 
odmget -q "name=hdisk0" CuDv 
Description : The restore command reads archives created by the backup command and extracts 
the files stored on them. The diskette device, /dev/rfd0, is the default media for the restore command. 
Example: 
1. To list the names of files in either a file-name or file-system archive on the 
diskette device /dev/rfd0, enter: 
restore -Tq 
2. To restore all files in diskette device, enter: 
restore 
3. To restore a specific file, enter: 
restore -xv  system.data 
This command extracts the file system.data into the current directory from the 
diskette device 
Syntax       : rmdev -l Name [ -d | -S ] [ -f File ] [ -h ] [ -q ] [ -R ] 
Description  : The rmdev command unconfigures or both unconfigures and undefines the device 
specified with the device logical name (the -l Name flag). The default action unconfigures the device while retaining its device definition in the Customized Devices object class. 
Flags
-d        Removes the device definition from the Customized Devices object class. 
-l Name   Specifies the logical device, indicated by the Name variable, in the 
Customized Devices object class. 
Examples
1. To unconfigure the hdisk1 device while retaining its device definition in the 
Customized Devices object class, enter: 
rmdev -l hdisk1 
The system displays a message similar to the following : hdisk1 defined 
2. To remove the hdisk1 device definition from the Customized Devices object class, 
enter: 
rmdev -dl hdisk1 
The system displays a message similar to the following : hdisk1 deleted 
3. To remove "scsi1" and all attached devices to scsi1 adapter: 
rmdev -l scsi1 -dR 
View previous commands 
enter 
            set -0 vi 
then     <Esc> k     to view previous commands 
Open DASD : To open DASD device, enter   </dev/hdisk2 
To see Current Directory, type       pwd 
Uname     : To get system model      uname -M 
 
							 
				 
				
감사합니다. 유용하게 쓰겠습니다.