AIX Command Crib Sheet: Miscelleneous
AIX Command Crib Sheet: Miscelleneous
OS LEVEL : AIX
DATE : 29/01/2001
VERSION : 1.8
MISCELLENEOUS
oslevel Returns operating system level
Displays identifying info from the executable like version number, when
what (program)
compiled.
Extracts a binary file from encoded file and calls it the extract-file-name
find /source -print | cpio -pdm /target Copying directories using cpio, creates /target/source directory.
snap -ad (directory) Create a snapshot into a named directory other than the default (/tmp/ibmsupt)
TERMINALS
tty Displays what the tty/pty number of the terminal is.
termdef reports the termtype setup in smit for the tty port that termdef is run on.
penable tty0 adds getty line into /etc/inittab for tty0 and starts getty
for i in 0 1 2 3 4 5 6 7
do Create ttys on ports 0 to 7 on adapter sa2 :-
mkdev -c tty1 -t tty -s rs232 -p sa2 -w$i -a login=enable -a term=vt100
done
NETWORK
host (ip or hostname) Resolves a hostname / ip address
chdev -l (device name) -a hostname=(hostname) Changes hostname permanently Examples :chdev -l inet0 -a hostname=thomas
ifconfig (device name) detach Removes the network card from the network interface list
ifconfig lo0 alias 195.60.60.1 Create alias ip address for loopback
• examples : to reset the maximum size of the mbuf pool to its default size,
enter:
no -d thewall
no –a
no -o option=value (this value is reset at reboot)
• Examples : to change the maximum size of the mbuf pool to 3MB, enter:
no -o thewall=3072
no -o "ipforwarding=1"
traceroute (name or ipaddress) Displays all the hops from source to destination supplied.
N.F.S.
Exportfs Lists all exported filesystems
MKSYSB
mkszfile –f Creates /image.data file (4.x onwards)
CPIO ARCHIVE
CPIO RESTORE
Examples :
• Restore directory and contents
cpio -icdv < (filename or device)
cpio -icdv < /dev/rmt0 "tcpip/*"
cpio -icdv < (filename or device) ("files or directories to restore")
• Restore a named file
cpio -icdv < /dev/rmt0 "*resolve.conf"
TAR ARCHIVE
tar -cvf (filename or device) ("files or directories to archive") tar -cvf /dev/rmt0 "/usr/*"
TAR RESTORE
AIX ARCHIVE
AIX RESTORE
Lists archiv
restore -qTvf (filename or device)
dd ibs=64k if=/dev/rmt0 | cpio -icvt To restore/read the backup (cpio) on the remote machine
To restore/read the backup (cpio) on the local machine from the remote
rsh remhost "dd ibs=64k obs=32k if=/dev/rmt0" | dd ibs=32k | cpio -icvt
machine's (remhost) tape drive (/dev/rmt0)
rsh remhost "find /data -print | cpio -icv | dd ibs=32k" | dd ibs=32k obs=64k To run the backup (cpio) on a remote machine (remhost) and backup to the
of=/dev/rmt0 local machines tape drive (/dev/rmt0)
COPYING DISKETTES
COPYING TAPES
dd if=/dev/rmt0 of=(filename)
Editor
editor Commands
:g/xxx/s//yyy/ VI global change where xxx is to be changed by yyy ( ctrl V to enter any character)
Strips out ^M characters from ascii files that have been transferred as binary.To
sed 's(ctrl v ctrl m)g//g' old.filename > new.filename enter crontrol characters type ctrl v then ctrl ? where ? is whatever ctrl character
you need.
DEVICES
mknod (device) c (major no) (minor no) Creates a /dev/ device file.
mknod /dev/null1 c 2 3
TAPE DRIVES
tctl -f (tape device) fsf (No) Skips forward (No) tape markers
tctl -f (tape device) bsf (No) Skips back (No) tape markers
lpstat
cancel (job No
enable (queue)
disable (queue)
FILE SYSTEMS
chpv -v a (pv) Adds the removed disk back into the system.
Moves all LV's from one PV to another PV, both PV's must be in the same
migratepv (old pv) (new pv)
volume group.
mkvg -y(vg) -s(PP size) (pv) Create a volume group example:mkvg -y datavg -s 4 hdisk1
Removes the PVID disk reference from the VGDA when a disk has vanished
reducevg (vg) (PVID)
without the reducevg (vg) (pv) command being run first.
Note:
exportvg (vg) • Cannot export a VG if it has active paging space, turn off paging, reboot
before exporting VG.
• Exporting removes entries from filesystems file but does not remove the
mount points.
lqueryvg -Atp (pv) Details volume group info for the hard disk.
importvg -y (vg name) (pv) Import a volume group from a disk.
mklv (vg) (No of PP's) (pv Name optional) Create a logical volume
mklv -y (lv) (PP's) (pv name optional) Creates a named logical volume
mount all
Will create a file system on the whole of the logical volume, adds entry into
crfs -v jfs -d(lv) -m(mount point) -A yes
/etc/filesystems and will create mount point directory if it does not exist.
Will create a logical volume on the volume group and create the file system on
crfs -v jfs -g(vg) -m(mount point) -a size=(size of fs) -A yes the logical volume. All at the size stated. Will add entry into /etc/filesystems and
will create the mount point directory if it does not exist.
fsck (fs) Verify a file system, the file system must be unmounted!
fsck -p (fs) Will restore primary superblock from backup copy if the superblock is corrupt.
Mirroring
mklv -y (lv) -c(copies 2 or 3) (vg) (No of PP's) (PV Name optional) Creates a mirrored named logical volume.
Creates a copy of a logical volume onto another physical volume. The physical
mklvcopy -s n (lv) (copies 2 or 3) (pv)
volume MUST be in the same volume group as the orginal logical volume !
syncvg -l (lv)
syncvg -v (vg)
mkboot -c -d (/dev/pv) Zero's out the boot records on the physical volume.
savebase -d (/dev/pv) Saves customised ODM info onto the boot device.
SYSTEM DUMP
sysdumpdev –l Lists current dump destination.
Note :
(MCA machine can also dump if key is in service position and the reset button is
pressed)
lsps (ps)
mkps -s(No of 4M blocks) -n -a (vg) (pv) -n = don't activate/swapon now -a = activate/swapon at reboot
Remove paging space. PS must have been turned off and then the system
rmps (ps)
rebooted before it can be removed.
Note:
• Need to change the swapon entry in /sbin/rc.boot script if you are changing
the default paging space from /dev/hd6.
• You also need to do a "bosboot -a -d /dev/hdiskx" before the reboot.
/etc/swapspaces
File that lists all paging space devices that are activated/swapon during reboot.
SCHEDULING
crontab –l List out crontab entrys
at (now + 2 minutes, 13:05, etc) {return} Schedule a job using at Command or schell script {return} {CTRL D}
at -l
SECURITY
Where :
examples :
umask 022 =
• new file permissions of 755
• read write and execute for owner
• read and execute for group
• read and execute for other
•
USERS
printenv
Displays number of users logged in, time since last reboot, and the machine load
uptime
averages.
REMOTE USERS
INITTAB
telinit S Switches to single user mode.
odmget -q "name-lp1" CuAt |more Gets lp1 info from customised database.
odmget -q "name=lp1" CuAt > lp1.CuAt Export ODM info to text file.
ERROR LOGGING
/usr/lib/errdemon –l Displays errorlog attributes.
• H=Hardware
• S=Software
• O=Information
• V=Undetermined
errclear (days) Deletes all error classes in the errorlog.
errclear -d (class) (days) Deletes all error class entries in errlog.
Note :
• The errclear command will delete all entries older than the numbers of days
specified in the days paramenter.
• To delete ALL entries used 0.
errlogger "message up to 1024 chrs" Enters an operator notifaction message into the errorlog.
PERFORMANCE MONITORING
vmstat (drive) (interval) (count) Reports virtual memory statistics.example: vmstat hdisk0 5 20
sar -u -P ALL 10 10 Displays %usr %sys %wio %idle for all processors
DOS DISKETTES
Dosdir Reads directory listing of a diskette
dosdir (directory) Reads directory listing of a named directory
dosread -D/dev/fd0 C41.TXT c41.txt Gets C41.TXT from diskette drive fd0
dosread -D/dev/fd0 DIRECTORY/C41.TXT c41.txt (-D option can be dropped if using fd0)
SENDMAIL
refresh -s sendmail Prints out sendmail version, compile defines and system information