AIX UNIX Commands
Commnads Using "ls" # lsvg (lists all volume groups) # lsvg rootvg (lists details of this volume group) # lsvg -o (lists only active volume groups) # lsvg -l rootvg (provides information about logical volumes in the rootvg group) # lsvg -p rootvg (lists info about all physical volumes within a volume group) # lslv lv02 (will provide info about selected logical volume within the volume group) # lslv hd6 (will provide information about selected logical volume within the volume group) # lslv -l lv00 (gives info about the distribution of a particular physical volume within a volume group) # lslv -m lv00 (gives a map of which physical volumes contain which physical partitions for the logical partitions of the logical volume)# lslv -m hd5 (Determaine the boot disk by using this command)
# lsvg -o (lists volume groups that are active)
# lsvg -M rootvg
(-M Lists the following fields for each logical volume on the physical
volume:
PVname:PPnum [LVname: LPnum [:Copynum] [PPstate]])
# lsvg (lists volume group)
# lsvg -o | lsvg -i -l
(-o active volume groups, lsvg -l to list logical volumes within volume
group, -i reads the
list of volume groups from standard input)
# lsvg -o | lsvg -l rootvg (list active logical volumes within volume group)
# lspv
(lists all Physical volumes and PV ID and volume group)
# lspv hdisk# (information about physical volume specifying hdisk#)
# lspv -l hdisk#
(Lists the following fields for each physical partition on the physical
volume
LPs, PP, Distribution of the number of physical partitions)
# lspv -p hdisk0 (lists details of the hard disk:mount points, region,state, PP range, LV ID)
# lsdev -C -H | grep hdisk (lists info about the device in device object class)
# lspv -M hdisk0
(lists the following fields for each logical volume
PVname:PPnum [LVnum [:Copynum] [PPstate]])
# lsdev -C -s scsi -H (lists all SCSI devices in box)
# lsdev -C -c disk (listing physical disks on your system using lsdev)
# lsjfs (lists journaled file systems)
# lsfs (lists all file systems)
# lsfs -v jfs (lists all defined Journaled file systems)
# lsfs -v nfs (lists all defined NFS file systems)
# lsfs -v cdrfs (lists all defined CD-ROM file systems)
# lssrc -a | pg
(lists Unix subsystems that are active and inactive)
# lsdev -P (lists all supported devices)
# lsdev -Cc tape (lists tape drive that is available) # lsdev -Cc tty# (to list a configued terminal) # lsdev -Cc memory (to see what hardware memory devices are being used) # lsdev -Pc tape (lists tape devices that are defined and can be configured on system) # lscfg (lists the hardware installed on your system)
# lscfg -vl ent0 (get MAC address of ethernet card in server) # lscfg -v (list all configured devices in detail) # lsdev -l rmt0 -d (deletes tape drive rmt0) # lsdev -Pc tape (list predefined tape device) # lsattr -D -l rmt0 (list tape attributes) # lsdev -P -H (lists all devices that can be installed) # lsdev -C -H (list all predefined devices. Provides name, status, location and description of device) SMIT: devices, list devces, list All Supported Devices # lsps -a (displays paging space info) # lsps -s (just displays amount of paging space and percent used) # lsdev -C | grep -i mem (memory and if it is available for use by the system) # lsattr -HE -l sys0 -a realmem (memory present on the system [will work for any user] Amount of usable physical memory in Kbytes) # lsattr -E -l mem0 (memory installed in system) # lsattr -EH -l sys0 (list system settings: memory, maxuproc, keylock, etc....) # lsattr -E -l(list the attributes of a device) # lslpp -L bos.* (List installed software) # ls -l *.diff | wc -l (will list all files ending with .diff and give a count of how many files it found)
Managing files
# diff chap1.back chap1 (To compare two files. This displays the differences between the files chap1.bak and chap1)
# diff -w prog.c.bak prog.c (To compare two files while ignoring differences in the amount of white space)
# zcat(used to view a compressed file without uncompressing that file)
# which <command> (will find the full path of the excitable Unix command )
# file /full/directory/path (will tell you the file format of a specific file)
# rm -rf /* (to wipe out all files and directories in the volume)
Unix Subsystems
# lssrc -l -s inetd (get a list of a specific subsystem) # lssrc -a (get a list of all subsystems) # startsrc -s(to start a subsystem) # stopsrc -s (to stop a subsystem) # refresh -s (refresh a subsystem)
System Preformance commands# bootinfo -r (real memory in kilobytes [will work only as root user])
# lsattr -E -l sys0 (kernal attributes)
# pg /etc/.init.state (run level of server)
# iostat 5 (reports cpu statistics and I/O stats)
# oslevel (reports the operating system version)
# vmstat 1 120 (reports virtual memory statistics)
# ps aux | head -5 (to obtain an overall view of current 5 most active system activities)
# uptime
(uptime of system,number of users online, load average in 3 time intervals
5min,10min,15min)
# sar -u 2 40 (Collects, reports, or saves
system activity information -u reports per processor at
2 seconds for the next 40 seconds)
# pstat -s (checks swap space: The number to the far right is available swap space)
Managing memory# lsps -a (displays paging space info)
# lsps -s (just displays amount of paging space and percent used)
# lsdev -C | grep -i mem (memory and if it is available for use by the system)
# lsattr -HE -l sys0 -a realmem (memory present on the system [will
work for any user])
# mkps -a -n -s 30 rootvg hdisk0 (create temporary paging space of 30 logical partitions)
# lsattr -E -l mem0 (memory installed in system) # lsattr -EH -l sys0 (list system settings: memory, maxuproc, keylock, etc....) # lsdev -Cc memory (to see how much real memory is on the system) # bootinfo -r (real memory in kilobytes [will work only as root user]) # swapon -a (to activate all paging spaces defined in /etc/swapspaces [Unix runs this command in /etc/rc during bootup]) # mkps -s 20 -a rootvg (create a extra paging space[-s 20 sets the paging size to 20x4meg of Physical Partitions] in Physical Partitions of 4meg on NYHQs system [-a active the paging space at the next restart] rootvg is the volume group within which to create the paging space) # mkps -s 2 -n rootvg (the -n option will active paging space immediately) # chps -a n hd6 (change default paging space so it is not used at next reboot [paging space can now be deleted when inactived after reboot]) # rmps hd6 (remove inactive paging space) # sysdumpdev -p /dev/paging00 (changing the dump device to a temporary swap space or to another AIX 4.1 swap space) SMIT: # smit mkps (Adding another paging space from smit) # smit chps (change/ Show characteristics of a paging space from smit)
Remote copy commands
(In the following rcp commands, the local host is listed in the /etc/hosts.equiv file at the remote host) # rcp localfile host2:/home/eng/jane (localfile from the local host is copied to the remote host host2) # rcp host1:/home/eng/jane/newplan host2:/home/eng/mary (to copy a remote file form one remote host to another host) # rsh(remote shell)
Printing Commands
# qprt -P-da (to print a text file to postscript printer) # qprt -P : -da (to print to a printer attached to a queue servicing multiple printers) # qprt -da -Psicu_prt -z1 t_bedmaster (to print landscape ) # export PRINTER=data (will change the default print queue for the currnet user shell to queue name "data") # rmque data (remove a print queue from the command line) # qcan -P (cancel all print jobs in a queue) # qcan -X (cancel all print jobs in all queues) # qadm -U (will bring up the print queue from the command line) # qadm -D (will bring down the print queue form the command line) # qadm -X (as root user all print jobs will be canceled [check man pages for more info]) # qmov -mdata -#11 (moving print job #11 from the cisprt queue to the data queue) # qmov -mdata -Pcisprt (moving all jobs on queue cisprt to the data queue) # qchk -A (lists all queues) # enq -A (lists all queues ) # qchk -A (lists all queues) # qchk (only lists the default printer queue) # qhld -P (to hold print jobs existing in queue) # qhld -P -r (to release all print jobs in queue) # lpstat (lists all queues)
Archive commands
# lsdev -l rmt0 -d (deletes tape device rmt0)
# tar -cvf /dev/rmt0 <directory path> (archive to tape device rmt0)
# tar -xvf /dev/rmt0 (restore archived files from device rmt0)
# errpt -ad H | pg (In the error log if you see TAPE_ERROR6 = tape drive needs cleaning)# tar -cvf /dev/rmt0 -C /clone . ([must sit below the /clone dir] will save files using relative path names and can be restored to the directory
# 'tar -cvf /dev/rmt0 /home /user' (will save all of the files in the selected directories using absolute pathnames)
# tar -cf /dev/rmt0 -C /home . -C /home2 . -C /chem public
(will save files using relative pathnames. Will restore relative to the
current directory (in other words, relative to the
directory from which the restore command was given)
# tctl -f /dev/rmt0 rewind (rewinds the tape)
# mt -f /dev/rmt0 rewind (rewinds the tape)
tctl -f /dev/rmt0 status (displays the status of tape dirve)
tctl offline /dev/rmt0 (will rewind the tape then eqect the tape)
dd if=/dev/rmt0 ibs=1024 obs=2048 of=/dev/rmt1 (To copy blocks from a tape with 1KB blocks to another tape using 2KB blocks)
dd if=/etc/inittab of=/dev/rmt0 (To make a backup of /dev/initab directory "dd" [ if=InFile parameter or standard input] [OutFile parameter or standard output])
# cpio -o (command reads file path names from standard input and copies these files to standard output, along with path names and status information.)
# cpio -i (command reads from standard input an archive file created by the cpio -o command and copies from it the files with names that match the Pattern parameter. These files are copied into the current directory tree.)
# cpio -ov <filenames >/dev/rfd0 (To copy files onto diskette. This copies the files with path names listed in the filenames file in a compact form onto the diskette (>/dev/rfd0). The v flag causes the cpio command to display the name of each file as it is copied. This command is useful for making backup copies of files. The diskette must already be formatted, but it must not contain a file system or be mounted.)
# find . -cpio /dev/rfd0 -print (This saves the directory tree that starts with the current directory (.) and includes all of its subdirectories and files) # cpio -idmv < /dev/rmt0 (This copies the files previously saved onto the /dev/rmt0 device by the cpio command back into the file system (specify the -i flag). The d flag allows the cpio command to create the appropriate directories if a directory tree is saved. The m flag maintains the last modification time in effect when the files are saved. The v flag causes the cpio command to display the name of each file as it is copied.)
# cpio -i "*.c" "*.o" </dev/rfd0 (To copy selected files from diskette.This copies the files that end with .c or .o from diskette. Note that patterns "*.c" and "*.o" must be enclosed in quotation marks to prevent the shell from treating the * (asterisk) as a pattern-matching character. This is a special case in which the cpio command itself decodes the pattern-matching characters)
# cpio -ir </dev/rfd0 (To rename files as they are copied from diskette. The -r flag causes the cpio command to ask you to rename each file before copying it from diskette. For example, the message:Rename <prog.c> asks whether to give the file saved as prog.c a new name as it is copied. To rename the file, type the new name and press the Enter key. To keep the same name, you must enter the name again. To avoid copying the file at all, press the Enter key.)# find . -print | cpio -pdl /home/jim/newdir (To copy a directory and all of its subdirectories, enter: mkdir /home/jim/newdir This duplicates the current directory tree, including the
# find /home -print | cpio -ov >/dev/rmt0
(Backup using "cpio" -o command reads file path names from standard
input and copies these files to standard output, along with
path names and status information. The "find" command is used to produce
a list, backup is written to starndard output)
# cpio -itv < /dev/rmt0 (list contents of cpio backup)
User security commands
# who /etc/security/failedlogin (contains all logins that failed [grows until cleaned]) # who /var/adm/wtmp (records all login and logout events [grows until cleaned]) # who | wc -l (to tell how many users are logged into the shell) # who -a (Processes the /etc/utmp file) # lsuser -a id home ALL (lists all the users from /etc/passwd, /etc/security/limit /etc/security/user file) # /var/adm/sulog (contains all invocations of the su command) # /etc/security/lastlog (contains detailed info about lastlogin) # xlock -password "root" (will lock the main console using root password to unlock) # ps -t tty# (process related to a terminal) # last | pg (will show the last time a user logged in most recently comes first) # export -p (displays the user environment) # fuser -u /dev/tty# (provides the login name for local processes) # kill -l (exit status,stops kill commands Ex: ctrl+C) # kill -9 `ps -ef | awk '$1=="chavez" {print $2}'` (blow away all user chavez's processes) # lsuser -a sugroups root (who can su to root [must be root to use command]) # chuser sugroups= "system,adm" root (making groups that can su to root) # chown -R harvey /home/iago (changes the user owner to harvey and all the files under the directory) # chown new-owner.newgroup(to change owner and group)
Process commands
# ps -ef (to list all processes, except kernel processes) # ps -ef | grep fs (search for font server process) # ps ax | grep(where process can be hide or TE) # ps aux | head - (will list processes in the order of decreasing CPU usage)
Network commands
# lscfg -vl ent0 (get MAC address of ethernet card in server) # ypcat hosts (will tell you if all the IP addresses are updated with the /var/yp make hosts command) # ifconfig en0 (network card status, netmask, inet, broadcast) # netstat -rn (shows routing of network card)# netstat -i (displays the contents of various network-related data structures for active connections.
# netstat -s | grep overflow (If socket overflows are in the 1000s then something is wrong with the network and needs to be investigated)
Find commands # find /var -size +1000 -ls (will find a file in /var which is over 1000 blocks) # find / -perm 777 -ls (to find files or directories with the 777 permissions) # find /-print | xargs grep 'text' (to search at a file with a specific line of text) # find /full/dir/path -print | xargs grep 'text' (will search a directory for a file with specific text content) # find /home -name .profile cp /etc/security/.profile {}\; (will find all the old .profiles and replace with new .profile)
# find / -name core -print -exec rm {}\; (Will find core files and do a cleanup)
System Protection commands
# last (states the last time a user logged in) # last root (states the last time a user logged in as root) # at -l (to list the jobs that maybe running with the at command) # at -r job (to cancel a job running with the at command)
Mounting NFS file System
1. Create directory on Unix_box1 which Unix_box2 directory will mount
to
- login as root on Unix_box1
- type mkdir <directory> (create /NFS_mount directory)
2. Exporting NFS file system from Unix_box2 so it can attach to Unix_box1
- login as root on Unix_box2
- enter smitty
Communications Applications and Services
NFS
Network File System (NFS)
Add a Directory to Exports List
(the /user directory will be the accessable NFS file system located on Unix_box2)
[Entry Fields]
* PATHNAME of Directory to Export
/user
* MODE to export directory
read-write
+
HOSTS & NETGROUPS allowed client access
[]
Anonymous UID
[0]
HOSTS allowed root access
[]
HOSTNAME list. If exported read-mostly
[]
Use SECURE OPTION?
no
+
Public filesystem?
no
+
* CHANGE export now, system restart or both
both
+
PATHNAME of alternate Exports file
[]
3. Mounting NFS file system on Unix_box1 so it will attach to Unix_box2
- login as root on Unix_box2
- enter smitty
Communications Apps & Services
NFS
Network file system (NFS)
Add a file system for mounting
(the full path of the accessable file system will be /user/baselines/training, which is mounted over the /NFS_mount directory)
[Entry Fields]
* PATHNAME of mount point
/NFS_mount
* PATHNAME of Remote Directory
[/user/baselines/training]
* HOST where remote directory resides
[box1_host]
Mount type NAME
[]
* Use SECURE mount option?
no
+
* Remount file system now,
both
+
update /etc/filesystems or both?
* /etc/filesystems entry will mount the directory
yes
+
on system RESTART.
* MODE for this NFS file system
read-write
+
* ATTEMPT mount in background or foreground?
background
+
NUMBER of times to attempt mount
[]
#
Buffer SIZE for read
[]
#
Buffer SIZE for writes
[]
#
NFS TIMEOUT. In tenths of a second
[]
#
NFS version for this NFS file system
any
+
Transport protocol to use
any
+
Internet port NUMBER for server
[]
#
* Allow execution of SUID and sgid programs
yes
+
in this file system?
* Allow DEVICE access via this mount?
yes
+
* Server supports long DEVICE NUMBERS?
yes
+
* Mount file system soft or hard
hard
+
Allow keyboard INTERRUPTS on hard mounts?
yes
+
Minimum TIME, in seconds, for holding
[]
#
attribute cache after file modification
Maximum TIME, in seconds, for holding
[]
#
attribute cache after file modification
Minimum TIME, in seconds, for holding
[]
#
attribute cache after directory modification
Maximum TIME, in seconds, for holding
[]
#
attribute cache after directory modification
Minimum & Maximum TIME, in seconds, for
[]
#
holding attribute cache after any modification
The Maximum NUMBER of biod daemons allowed
[]
#
to work on this file system
* Use acls on this mount?
no
+
Number of NFS retransmits
[]
#
* Exchange POSIX pathconf information?
no
+
* Inherit group IDs?
no
Mounting File Systems Commands
# mount (checks all the mounted file systems) # mount nyhq_admin:/user/emtek/baselines/training /DEV_admin (to mount NFS file system) # unmount nyhq_admin:/user/emtek/baselines/training /DEV_admin (to mount NFS file system) # mount -o ro -v cdrfs /dev/cd0 /mnt ([mount CD-ROM]-o options, ro read only, -v Vfsname type of file system, cdrfs CD-ROM file system ) Mount/Unmount a file system SMIT: smit mountfs # showmount -a (displays a list of all clients that have remotely mounted a file system from a specified machine in the Host parameter)
Managing Users, Groups and Passwords
# mkuser wpdavids (to make a user from the command line)
# mkuser -a wpdavids (making wpdavids an administrative user)
# mkuser su=false wpdavids (sets the su attribute to false)
# pwdadm wpdavids (to assign a password to the user from command line) # passwd (type this to change your password when logged in) # /usr/lib/security/mkuser.sys (is run during the user creation process. This creates the users home directory and .profile file. This shell script can be modified to perform any function that is required when setting up a user) # /etc/motd (The Message Of The Day file, which is displayed when users login) # $HOME/.hushlogin (if this file exists in a users home directory, then the contents of the /etc/motd file will not be displayed to that user) # rmuser -p cheves (to remove a user, the -p option will remove authentication from /etc/security/* files. The users home directory is not removed) # lsgroup ALL (lists all groups created on the system) # mkgroup -a(-a is used to indicate that the new group is to be an administrative group) # mkgroup -A (-A option makes the invoker of the mkgroup command the group administrator) # rmgroup (will remove a group no option are with this command)
Regaining root's Password for RS/6000 43/P 1. PCI: Boot from CD-ROM 2. Select option 3 from the installation and Maintenance menu: Start Maintenance Mode for System Recovery 3. Follow the options to obtain a shell by activating the root volume group 4. Set and export TERM variable 5. # vi /etc/security/passwd (Delete root's encripted password) 6. #sync; sync 7. PCI: Reboot the system
Booting the System# bootinfo -k (key positions on computer case of server [must be root]
# bootinfo -r (real memory in kilobytes [will work only as root user])
# bootinto -p
(will determaine the hardware platform type on your machine.rs6k=Micro
Channel-based uni-processor models,
rs6ksmp= Micro Channel-based symmetric multiprocessor models, rspc= ISA-bus
models, chrp=PCI-bus models)
# bootlist -m service rmt0 hdisk0 (Will change the order of the boot list. Will boot the system into service mode using rmt0 first and hdisk0 second)
# bootlist -m normal hdisk0 hdisk1 rmt0 fd (To make a boot list for Normal mode with devices listed on the command line)
# bootlist -m normal -o (Display the bootlist [version 4.2 or later])
# bosboot -a -d hdisk0 (update info in the boot logical volume)
# lslv -m hd5 (Determaine the boot disk by using this command)
# bosboot -a -d /dev/hdiskn (Recreate boot image)
Accessing a System That Will Not Boot:
In order to access the system:1. Turn the system key (if present) to the Service position or alternatively press F5 on PCI based system to boot
2. A screen will appear asking asking you to press a function key (such
as F1) to select the proper display as the system
console
3. Welcome to Base Operating System Installation and Maintenance
screen will appear. Select Start Maintenance Mode for system
Recovery and press Enter
4. You will enter Maintenance and select Access a Root Volume Group
5. Choose the Volume Group whose logical information you want to display.
6. Select one of the options from the Volume Group Info screen and press
Enter
1.
Choice 1 Seleting this choice imports and activates the volume group and
mounts the file systems for this root volume group
before providing you with a shell and a system prompt.
2. Choice 2 Selecting this choice imports and activates the volume
group and provides you with a shell and system prompt before
mounting the file system for this root volume group.
Common Boot Time LEDs and Their Solution:
7. Damaged Boot Image LED 201
1. Access your rootvg following the procedure described
above from
“Accessing a System That Will
Not Boot”
2. Check / and /tmp filesystems. If they are almost
full create more space.
3. Determine the boot disk by using the command
lslv -m hd5
4. Re-create boot image using bosboot -a -d /dev/hdiskn
5. Check for CHECKSTOP errors in the error log.
If such errors are
found, it is probably failing hardware.
6. Shutdown and restart the system.
8. Invalid Boot List LED 223-229
1. Set the key mode switch to service (F5 for systems
without keylock)
and power up the machine.
2. If display continues normally, change the key
mode switch to Normal
and continue with step 3. If you
do not get the prompt, go to step 4.
3. When you get the login prompt, login and follow
the procedure
described in 3.2.1, “Using
the bootlist Command” on page 28 to
change your bootlist. Continue
with step 7.
4. Follow the procedure, “Accessing a System That
Will Not
Boot” to access your rootvg
and continue with step 5.
5. Determine the boot disk by using the command
lslv -m hd5.
6. Change the bootlist following the procedure ,
“Using the
bootlist Command”
9. LED 551, 555, and 557 Corrupted File System, Corrupted
JFS log, and so on.
1. Follow the procedure described “Accessing a System
That
Will Not Boot”. To access
the rootvg before mounting any
file systems (Option 2 on
the Maintenance screen).
2. Verify and correct the file systems as follows:
fsck -y /dev/hd1
fsck -y /dev/hd2
fsck -y /dev/hd3
fsck -y /dev/hd4
fsck -y /dev/hd9var
3. Format the JFS log again by using the command:
/usr/sbin/logform /dev/hd8
4. Use lslv -m hd5 to find out the boot disk.
5. Recreate boot image by using the command:
bosboot -a -d /dev/hdiskn
Where n is the disk number of
the disk containing boot logical volume.
System Initialization and
Boot 35
10. Super Block Corrupted LED 552, 554, and 556
or Corrupted Customized
ODM Database
1. Repeat steps 1 through 2 for LEDs 551, 555, and
557.
2. system is corrupted and needs to be repaired.
Enter the command:
dd count=1 bs=4k skip=31 seek=1
if=/dev/hdn of=/dev/hdn
where n is the number of the file
system.
3. Rebuild your JFS log by using the command:
/usr/sbin/logform /dev/hd8
4. If this solves the problem, stop here otherwise
continue with step 5.
5. Your ODM database is corrupted. Restart your
system and follow the
procedure given in, “Accessing
a System That Will Not Boot”
to access rootvg with
Choice 2.
6. Mount the root and usr file system as follows:
mount /dev/hd4 /mnt
mount /usr
7. Copy system configuration to a back up directory:
mkdir /mnt/etc/objrepors/backup
cp /mnt/etc/objrepors/Cu* /mnt/etc/objrepos
8. Copy configuration from RAM file system as follows:
cp /etc/objrepos/Cu* /mnt/etc/objrepos
9. Unmount all file systems by using the umount
all command.
10. Determine bootdisk by using the lslv -m hd5 command.
11. Save the clean ODM to the boot logical volume by using the
command:
savebase -d/dev/hdiskn
12. Reboot, if system does not come up, reinstall BOS.
11. Corrupted /etc/inittab file LED 553
1. Access the rootvg with all file systems
mounted by following the
procedure described
in “Accessing a System That Will Not Boot”
2. Check for free space in /, /var and
/tmp by using df command.
3. Check the /etc/inittab file and correct
the inittab problems if there is
one empty inittab file,
missing inittab file or wrong entry in inittab file.
4. Check problems with:
/etc/environment file
/bin/sh
/bin/bsh
/etc/fsck
/etc/profile
/.profile
5. Shutdown the system and reboot.
System Initialization and
Boot 37
Creating Devices
To add a device to a system you must know the following - device class, type and subclass - adapter and connetion location - device attribute To define a device SMIT: "Define tape drive" # mkdev -d tape -t 350mb \>scsi -p scsi0 -w 40 To configure an already defined device SMIT: "configure a defined tape drive" # mkdev -l rmt0 To stop a defined device SMIT: "Configure a defined tape drive" # mkdev -S rmt0 To unconfigure device SMIT: "Remove a tape drive" - Delete from database=no # rmdev -l rmt0 To remove a device permanently SMIT: "Remove a tape drive" - Delete from database=yes # rmdev -l rmt0 -d # cfgmgr (which runs at IPL reads the identifying number and searches in the ODM in the predefined database for the necessary programs to configure the device [can be typed at command line]) # mkdev -c diskette -t fd -s siofd -p fda0 (to add a diskette drive) # mkdev -l tty0 (to add a tty device)# mkdev -l 'hdisk#' (To make an already defined physical volume device available to use)
Managing Logical VolumesMake logical volumes
Logical Volumes
SMIT: smit vl (manage logical volumes)
To add a file system on a previously defined logical volume
SMIT: smit crjfslv
Add a Standard journaled file system
SMIT: smit crjfs
Managing Volume Groups
smit mkvg (manage volume groups) # extendvg -f rootvg hdisk3 (Add disk 3 to the rootvg volume group)# reducevg <VGname> hdisk# (to remove a disk from a volume group)
To make a volume group
# mkvg -y <vg name> -d 10 -s 8 hdisk1 hdisk5
(The following example shows the use of the "mkvg" command to create a
volume group, using the physical volumes hdisk1
# varyoffvg # exportvg # chpv -vr # chpv -va # importvg -y bkvg hdisk07 (To import the volume group
bkvg from physical volume hdisk07)
Note: importvg
# varyonvg <newvg> (Activate a volume group -n
flag will suppress the invocation of the "syncvg" at vary on time. The
-f flag can be used to force a VG to be varied on even
# varyoffvg <myvg> (deactivates a volume
group)
# reorgvg -i <volume group> [ Logical Volumes ]
(The "reorgvg" command is used to reorganize the physical partition allocation
for a volume group according to
- JFS file system created with 600 megs (1,200,000 blocks)
File
system name
/DIR_mount
3.Enter smitty to mount file system on Unix_box1
# chpv -va # lslv -m hd5
(Determaine the boot disk by using this command)
Physical volumes
# migatepv [-l lvname] sourcePV targetPV (move the contents of a physical
volume)
# mkvg -y <vg name> -d 10 -s 8 hdisk1 hdisk5
(The following example shows the use of the "mkvg" command to create a
volume group, using the physical volumes hdisk1
# reducevg <VGname> PVID (to remove
a disk from a volume group)
smit mkvg
(manage volume groups)
Moving Data from a failing disk before it is removed
for replacement:
1.Determaine which disks are in the volume group. Make sure that the
source and destination physical volumees are in the
# lsvg -p hdisk0
2. If you are planning to migrate to a new disk, such as when you have
a failing disk, perform the following steps:
b. If the disk is listed
and in the available state, make sure it does not belong to another volume
group using the following command. (In the following
# lspv
c. If the disk is not listed
or is not available, you need to check or install the disk.
d. Add the new disk to the
volume group using the command:
# extendvg VGName hdiskNumber
3. Make sure that you have enough room on the target disk for the source
that you want to move.
a. Determaine the number
of physical partitions on the source disk by
# lspv SourceDiskNumber | grep "USED PPs"
b. Determine the number of
free physical partitions on the destination disk or disks
# lspv DestinationDiskNumber | grep "FREE PPs"
Add
the free physical PPs from all of the destination disks. If the sum is
larger than the number
4. Follow this step only if you are migrating data from a disk in the
rootvg volume group. If you are migrating
Check to see if the boot logical volume (hd5) is
on the source disk:
#
lspv -l SourceDiskNumber | grep hd5
If you get no output, the boot logical volume is
not located on the source disk. Continue to step 5.
If you get output similar to the following:
# migratepv -l hd5
SourceDiskNumber DestinationDiskNumber
Note:
*
The migratepv command connot migrate striped logical volume. Use cplv command
and then use the rmlv command
Next you will get a message warning you to perform
the bosboot command on the destination disk.
Note:
Next Enter:
then:
then:
Migrating data from a disk in a user-defined volume
group:
5. Execute SMIT fast path # smitty migratepv
6. Choose the SOURCE physical volume
7. Choose the DESTINATION physical volume
8. To remove the source disk from the volume group
# reducevg VGNname SourceDiskNumber
9. To physically remove the source disk
# rmdev -l SourceDiskNumber
-d
# /etc/hosts
(is a TCP/IP network configuration file. It is accessed by all commands
that use the network. The file contains a list of IP addresses, hostnames
# /etc/hosts.equiv
(Contains a list of TCP/IP "trusted" hosts. If machine A is a trusted host
of machine B, then all users on machine A may rlogin to
# /etc/export
( Lists all the filesystems that are available to other machines via NFS)
/etc/passwd
(Is the password file. Each line in the file holds al the information on
a single user. A line consists of seven fields, separated by a colon)
Editing /etc/inittab
# chitab
(Changes records in the /etc/inittab file To change the run level of a
record for tty2, enter:
# mkitab
(Adds records to the /etc/inittab file)
# sitab -a
(lists all records to the /etc/inittab file)
# rmitab
(Removes records from the /etc/inittab file)
# setenv TERM vt100
(will set the terminal environment working from a serial port for
# setenv TERM ibm3151
( will set the terminal for "C" shell environment)
# TERM=ibm3151;export TERM
(will set the terminal environment for a root user)
SMIT: smit mkvg
# mkvg (used
to create volume groups -y
allows the use of administrative commands])
and hdisk5, with a physical partition size of 8 KB. The volume group is
limited to a maximum of 10 physical volumes)
to system management mode] All file systems located on the volume must
be unmounted)
table, special file, and /etc/filesystem entries are added automatically
[see exportvg])
The important thing to remember when moving volume groups from system to
system, is that the "exportvg" command is alway run on the source
system prior to importing the volume group to the target system. A volume
group that has a paging space volume on it cannot be exported while the
paging
space is active. Run the command chps -a -n paging_space <name>.
Then reboot the system so the paging space is inactive. If you do not activate
the volume group through
smitty importvg, you mst run the "varyonvg" command. If you imported a
volume group that contains file systems, or if you activated the volume
group through smitty importvg,
it is highly recommended that you run fsck command before you mount the
file systems. If you are moving the volume group to another system, be
sure to unconfigure the disks
before moving them.
when inconsistencies are detected)
the allocation characteristics of each logical volume.The volume group
must be varied on and must have free
partitions before you can use "reorgvg" command. The relocatable flag of
each logical volume must be set to "y" using
the "chlv -r" command example: # reorgvg -i rootvg lv03 lv04
lv07)
Managing file systems
# dircmp proj.ver1 proj.ver2 (To summarize the differences between the files in two directories)
# mkfs (builds the file system structure within a logical volume)
To specify the volume and file system name for a new file system,
enter:
mkfs -lworks -vvol001 /dev/hd3
This command creates an empty file system on the /dev/hd3 device,
giving it the volume serial number vol001 and file system name works.
The new file system occupies the entire device. The file system has
a default fragment size (4096 bytes) and a default nbpi ratio (4096).
Mount/Unmount a file system
SMIT: smit mountfs
Change / show a standard Journaled file system
# smit chjfs
Remove a Journaled file system
The (rmfs) command is the high level command to remove a file system. In order to remove a file system, It must
be unmounted from the overall file tree, and this cannot be done if the file system is in use or a process is using
the file system or has it as a current directory. (rmfs) will remove any info for the file system from the ODM and
/etc/filesystems. When the fle system is removed, the logical volume on which it resides is also removed.
# df -I (shows space used)
# df -k (reports free space in 1KB blocks [megabytes])
# du -s -k /home (The -s flag instructs the du command to display only the sum total of disk
usage of the /home directory and the files it contains. The -k option display kilo bytes)
# fsck (If no file system name is specified, the "fsck" command will check all filesystems
which have the check=true attribute set in the /etc/filesystems)
# lslv -m hd5 (Determaine the boot disk by using this command)
Using smitty to create a Journaled file system
1. Create a Journaled File System called /DIR_mount on Unix_box1
2. Enter smitty to create a JFS file system on Unix_box1
System Storage Management (Physical & Logical Storage)
File systems
Add /Change /Show /Delete File Systems
Journaled File Systems
Add a Journaled File System
NEW mount point
[/DIR_mount]
SIZE of file system (in 512-byte blocks)
[1212416]
Mount GROUP
[]
Mount AUTOMATICALLY at system restart?
yes
+
PERMISSIONS
read/write
+
Mount OPTIONS
[]
+
Start Disk Accounting?
no
+
Fragment Size (bytes)
4096
Number of bytes per inode
4096
Compression algorithm
no
Large File Enabled
false
Allocation Group Size (MBytes)
8
System Storage Management (Physical & Logical Storage)
File Systems
Mount a File System
Mirroring volumes
# mklvcopy -k (synchronizing a new copy to a perfect image of the existing volume)
# syncvg (synchronize a mirroring volume)
Managing Physical Volumes
# mkdev -c disk -s scsi -t osdisk -p scsi2 -a pv=yes (disk is assainged the next available hdisk#)
# smit cfgmgr (will do the same as the above command)
# diag (use the diag command to verify that the system can access the new device)
# diag -d scdisk0 -c (To run diagnostics on the scdisk0 device, without questions)
# chdev -l hdisk# -a -pv=yes (To make a new disk available to the logical volume manager)
# chpv -a n hdisk1 (turns off the allocation permission for physical volume hdisk1)
# chpv -a y hdisk1 (turns on the allocation permission for physical volume hdisk1)
# chpv -v r <hdisk#> (used to set the state of a physical volume to unavailable)
# chpv -v -a <hdisk#> (will make a physical volume available to the system)
# chpv -vr # rmdev -l <hdisk#> (will unconfigure a physical volume and chane its state from available to defined)
# rmdev -l <hdisk#> -d (to remove a disk from the system)
# lslv -m hd5 (Determaine the boot disk by using this command)
# mkdev -l 'hdisk#'
(To make an already defined physical volume device available to use)
SMIT:smit pv
# migratepv -l lv02 hdisk1 hdisk2
(example of migratepv: will move physical partitions in logical volume
lv02 from hdisk1 to hdisk2)
and hdisk5, with a physical partition size of 8 KB. The volume group is
limited to a maximum of 10 physical volumes)
# extendvg -f rootvg hdisk3 (Add disk 3 to
the rootvg volume group)
same volume group. If the source and destination physical volumes
are in the same volumes are in the same volume group,
proceed to step 3.
a. Make sure the disk is
available by entering the following.
# lsdev -Cc disk
example, hdisk1 can be used as a destination disk.)
hdisk0 00000782345789 rootvg
hdisk1 00000789345902 none
using the following command. (SourceDiskNumber will be of the form hdiskNumber)
using the following command for each destination disk.
of USED PPs from step 3, you will have enough space for the migration.
data from a disk in a user-defined volume group,
proceed to step 5.
* This migration commmand is not allowed if the volume group is varied
on in concurrent mode.
* When execute the bosboot command, you must also execute mkboot
-c
# bosboot -a
-d /dev/DestinationDiskNumber
# bosboot -m
normal DestinationDiskNumber
# mkboot -c -d /dev/SourceDiskNumber
Changing Kernal device attributes
# chdev -l sys0 -a maxuproc=100 (to change characteristics of the kernal device maxuproc)
# chdev -l rmt0 -a ret=yes (to change attributes of the tape device)
Unix log commands
# alog -o -t boot | pg (creates and maintains fixed size files created form standard input)
# errpt -a (details of the error log)
# errpt -ad H | pg (tape drive error log TAPE_ERR6 = tapedrive needs cleaning)
Important files
# /etc/inetd.conf
(Is the Internet daemon file. It holds the instructions used by /etc/inetd
to manage network service daemons.
Enables TCP/IP services like telnet, rsh, login, shell)
and hostname aliases)
machine B without supplying a password)
# /etc/qconfig (contains stanzas for each queue & controls the qdaemon print queue scheduler)
# /etc/inittab (controls the initialization process and regulates the operation of serial interfaces)
# /etc/init
(Is run as the last ste p of the startup process and attempts to read the
/etc/inittab file
to specify the run level of the operating system. If the initdefault run
level does not exist the
user is prompted to enter the run level at console. If the /etc/inittab
file does not exits, the
the init command places the system in the maintenance run level by default.The
init command rereads the
/etc/inittab file every 60 seconds. If the /etc/inittab file has changed
since the last time the init command read it, the
new commands in the /etc/inittab file are executed.)
The 7 fields of the password file:
1. Login name
2. Encrypted passwd
3. UID
4. Default GID
5. GCOS field including full name, office location, extension number, and
home phone.
6. Home Directory
7. Login shell
"chitab tty002:23:respawn:/usr/sbin/getty /dev/tty")
Run Level
Identifier
Action
Command
tty002
23
respawn
/usr/sbin/getty/dev/tty
Managing cron jobs
# crontab -l (will list the crontab file)
# crontab -e (to edit the crontab file)
# crontab -r (to remove a crontab file from the crontab directory)
# cd /var/spool/cron/crontabs/user (jobs specified by the crontab files for users)
NOTE: CRON CAN ONLY BE USED BY ROOT UNLESS cron.allow & cron.deny is setup
# cd /var/adm/cron/cron.deny (if this file exits anybody can use cron except
those listed in it)
# cd /var/adm/cron/cron.allow (if this file exits, only users listed can use cron,
root included)
crontab file format:
minute hour day month day_of_week command
00-59 0-23 1-31 1-12 Sun-Sat /fullpath/job to be ran
0-6
To run commands at a later time
# at
sudo commands
/usr/local/bin (path to setup in user's .profile so they can use soo-doo)
/usr/local/etc/visudo (path to run "visudo" command to edit the soo-doo config file)
setting terminal environments
"C" shell environment)
Commands related to Operating System Install or Update
lppchk -v (Verifies that the / (root), /usr and /usr/share parts of the system are valid with each other)
oslevel (level of operating system)
oslevel -g (lists filesets at levels later than the current maintenance level)
Misc. commands
# which
More Unix stuff
calculating diskspace
creating 55 meg partition 55x2048=112640 size of file system
(in 512 byte blocks 112630)
112640/2048=55meg
Subject: 1.201: How do I do remote backup?
There seems to be several ways of doing this. The first approach is a
one-liner to allow tar to reference another machine's device. The
second is more complete but uses a similar approach. The latest
addition to this section claims to be able to support mksysb on a
remote machine. Thanks to all the contibutors.
tar -b1 -cf - . | rsh REMOTEHOST "dd ibs=512 obs=1024 of=/dev/TAPEDEVICE"
[Ed.: The usave.sh script has been moved to section 8.06. I've verified
this script works fine. However, it may be slow for large filesystems
since it creates a temp file of filenames in /tmp.]
There are also several commercial solutions. One is IBM's SYSBACK/6000
product. See Question 1.209 for more information.
Open Microsystems sells a product called DistribuTAPE which supports
mksysb to a remote tape drive under AIX 3.2, 4.1 and 4.2. DistribuTAPE
supports remote tape drives by placing a pseudo tape driver on the
client system, and a server daemon on the server. More information at
http://www.openmic.com/
Question: How do I mount a floppy disk as a file system ?
From: [email protected] (Olaf Pors)
You can build a filesystem on a floppy and mount it, however the
filesystem will be read only. The reason that the filesystem will be
read only is because AIX Version 3.1.5 cannot create a journal log on a
diskette. The intended use is for temporary access to read only data.
The diskette file system must be unmounted after use and during system
backup procedures or errors could occur.
To make the read only filesystem on a floppy:
1. Make a subdirectory on an existing filesystem and place all of the
files that the diskette will contain into this subdirectory.
2. Enter the following command to create a prototype file containing
information about the new filesystem, in the example /dir_struct
is the pathname of the subdirectory created in step 1, and
proto_filename is the name of the prototype file to be created.
proto /dir_struct > proto_filename
3. Place a formatted floppy into the drive.
4. Edit the prototype file and replace the first line with the following: