You are on page 1of 54

COMMANDS

Kernel How would I know if I am running a 32-bit kernel or 64-bit kernel? To display if the kernel is 32-bit enabled or 64-bit enabled, type:
bootinfo K

How do I know if I am running a uniprocessor kernel or a multiprocessor kernel?


/unix is a symbolic link to the booted kernel. To find out what kernel mode is running, enter ls -l /unix and see what file /unix it links to. The following are the three possible outputs from the ls -l /unix command and their corresponding kernels: /unix -> /usr/lib/boot/unix_up /unix -> /usr/lib/boot/unix_mp /unix -> /usr/lib/boot/unix_64 # 32 bit uniprocessor kernel # 32 bit multiprocessor kernel # 64 bit multiprocessor kernel

Note: AIX 5L Version 5.3 does not support a uniprocessor kernel. How can I change from one kernel mode to another? During the installation process, one of the kernels, appropriate for the AIX version and the hardware in operation, is enabled by default. Let us use the method from the previous question and assume the 32-bit kernel is enabled. Let us also assume that you want to boot it up in the 64-bit kernel mode. This can be done by executing the following commands in sequence:
ln -sf /usr/lib/boot/unix_64 ln -sf /usr/lib/boot/unix_64 bosboot -ad shutdown r /dev/hdiskxx /unix /usr/lib/boot/unix

The /dev/hdiskxx directory is where the boot logical volume /dev/hd5 is located. To find out what xx is in hdiskxx, run the following command:
lslv -m hd5

Note: In AIX 5.2, the 32-bit kernel is installed by default. In AIX 5.3, the 64-bit kernel is installed on 64bit hardware and the 32-bit kernel is installed on 32-bit hardware by default. Hardware

How would I know if my machine is capable of running AIX 5L Version 5.3? AIX 5L Version 5.3 runs on all currently supported CHRP (Common Hardware Reference Platform)-based POWER hardware. How would I know if my machine is CHRP-based? Run the prtconf command. If it's a CHRP machine, the string chrp appears on the Model Architecture line. How would I know if my System p machine (hardware) is 32-bit or 64-bit? To display if the hardware is 32-bit or 64-bit, type:
bootinfo y

How much real memory does my machine have? To display real memory in kilobytes (KB), type one of the following:
bootinfo -r lsattr -El sys0 a realmem

Can my machine run the 64-bit kernel? 64-bit hardware is required to run the 64-bit kernel. What are the values of attributes for devices in my system? To list the current values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 E

To list the default values of the attributes for the tape device, rmt0, type:
lsattr -l rmt0 D

To list the possible values of the login attribute for the TTY device, tty0, type:
lsattr -l tty0 -a login R

To display system level attributes, type:


lsattr -E l sys0

How many processors does my system have? To display the number of processors on your system, type:
lscfg | grep proc

How many hard disks does my system have and which ones are in use? To display the number of hard disks on your system, type:
Lspv

How do I list information about a specific physical volume? To find details about hdisk1, for example, run the following command:
lspv hdisk1

How do I get a detailed configuration of my system? Type the following:


Lscfg

The following options provide specific information:


-p -v

Displays platform-specific device information. The flag is applicable to AIX 4.2.1 or later. Displays the VPD (Vital Product Database) found in the customized VPD object class.

For example, to display details about the tape drive, rmt0, type:
lscfg -vl rmt0

You can obtain very similar information by running the prtconf command. How do I find out the chip type, system name, node name, model number, and so forth? The uname command povides details about your system.
uname -p uname -r uname -s uname -n uname -a uname -M

Displays the chip type of the system. For example, PowerPC. Displays the release number of the operating system. Displays the system name. For example, AIX. Displays the name of the node. Displays the system name, nodename, version, machine ID. Displays the system model name. For example, IBM, 9114-275.

uname -v uname -m uname -u

Displays the operating system version. Displays the machine ID number of the hardware running the system. Displays the system ID number.

AIX What version, release, and maintenance level of AIX is running on my system? Type one of the following:
oslevel r lslpp -h bos.rte

How can I determine which fileset updates are missing from a particular AIX level? To determine which fileset updates are missing from 5300-04, for example, run the following command:
oslevel -rl 5300-04

What SP (Service Pack) is installed on my system? To see which SP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL4, and SP2 installed would be:
oslevel s 5300-04-02

Is a CSP (Concluding Service Pack) installed on my system? To see if a CSP is currently installed on the system, run the oslevel -s command. Sample output for an AIX 5L Version 5.3 system, with TL3, and CSP installed would be:
oslevel s 5300-03-CSP

How do I create a file system? The following command will create, within volume group testvg, a jfs file system of 10MB with mounting point /fs1:
crfs -v jfs -g testvg -a size=10M -m /fs1

The following command will create, within volume group testvg, a jfs2 file system of 10MB with mounting point /fs2 and having read only permissions:
crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2

How do I change the size of a file system? To increase the /usr file system size by 1000000 512-byte blocks, type:
chfs -a size=+1000000 /usr

Note: In AIX 5.3, the size of a JFS2 file system can be shrunk as well. How do I mount a CD? Type the following:
mount -V cdrfs -o ro /dev/cd0 /cdrom

How do I mount a file system? The following command will mount file system /dev/fslv02 on the /test directory:
mount /dev/fslv02 /test

How do I mount all default file systems (all standard file systems in the /etc/filesystems file marked by the mount=true attribute)? The following command will mount all such file systems:
mount {-a|all}

How do I unmount a file system? Type the following command to unmount /test file system:
umount /test

How do I display mounted file systems? Type the following command to display information about all currently mounted file systems:
Mount

How do I remove a file system? Type the following command to remove the /test file system:
rmfs /test

How can I defragment a file system? The defragfs command can be used to improve or report the status of contiguous space within a file system. For example, to defragment the file system /home, use the following command:
defragfs /home

Which fileset contains a particular binary? To show bos.acct contains /usr/bin/vmstat, type:
lslpp -w /usr/bin/vmstat

Or to show bos.perf.tools contains /usr/bin/svmon, type:


which_fileset svmon

How do I display information about installed filesets on my system? Type the following:
lslpp -l

How do I determine if all filesets of maintenance levels are installed on my system? Type the following:
instfix -i | grep ML

How do I determine if a fix is installed on my system? To determine if IY24043 is installed, type:


instfix -ik IY24043

How do I install an individual fix by APAR? To install APAR IY73748 from /dev/cd0, for example, enter the command:
instfix -k IY73748 -d /dev/cd0

How do I verify if filesets have required prerequisites and are completely installed? To show which filesets need to be installed or corrected, type:
lppchk v

How do I get a dump of the header of the loader section and the symbol entries in symbolic representation?
Type the following: dump Htv

How do I determine the amount of paging space allocated and in use? Type the following:
lsps a

How do I increase a paging space? You can use the chps -s command to dynamically increase the size of a paging space. For example, if you want to increase the size of hd6 with 3 logical partitions, you issue the following command:
chps s 3 hd6

How do I reduce a paging space? You can use the chps -d command to dynamically reduce the size of a paging space. For example, if you want to decrease the size of hd6 with four logical partitions, you issue the following command:
chps d 4 hd6

How would I know if my system is capable of using Simultaneous Multi-threading (SMT)? Your system is capable of SMT if it's a POWER5-based system running AIX 5L Version 5.3. How would I know if SMT is enabled for my system? If you run the smtctl command without any options, it tells you if it's enabled or not. Is SMT supported for the 32-bit kernel? Yes, SMT is supported for both 32-bit and 64-bit kernel. How do I enable or disable SMT? You can enable or disable SMT by running the smtctl command. The following is the syntax:
smtctl [ -m off | on [ -w boot | now]]

The following options are available:


-m off -m on -w boot -w now

Sets SMT mode to disabled. Sets SMT mode to enabled. Makes the SMT mode change effective on next and subsequent reboots if you run the bosboot command before the next system reboot. Makes the SMT mode change immediately but will not persist across reboot.

If neither the -w boot or the -w now options are specified, then the mode change is made immediately. It persists across subsequent reboots if you run the bosboot command before the next system reboot.

How do I get partition-specific information and statistics?

The lparstat command provides a report of partition information and utilization statistics. This command also provides a display of Hypervisor information. Volume groups and logical volumes How do I know if my volume group is normal, big, or scalable? Run the lsvg command on the volume group and look at the value for MAX PVs. The value is 32 for normal, 128 for big, and 1024 for scalable volume group. How to create a volume group? Use the following command, where spartition_size sets the number of megabytes (MB) in each physical partition where the partition_size is expressed in units of MB from 1 through 1024. (It's 1 through 131072 for AIX 5.3.) The partition_size variable must be equal to a power of 2 (for example: 1, 2, 4, 8). The default value for standard and big volume groups is the lowest value to remain within the limitation of 1016 physical partitions per physical volume. The default value for scalable volume groups is the lowest value to accommodate 2040 physical partitions per physical volume.
mkvg -y name_of_volume_group -s partition_size list_of_hard_disks

How can I change the characteristics of a volume group? You use the following command to change the characteristics of a volume group:
Chvg

How do I create a logical volume? Type the following:


mklv -y name_of_logical_volume name_of_volume_group number_of_partition

How do I increase the size of a logical volume? To increase the size of the logical volume represented by the lv05 directory by three logical partitions, for example, type:
extendlv lv05 3

How do I display all logical volumes that are part of a volume group (for example, rootvg)? You can display all logical volumes that are part of rootvg by typing the following command:
lsvg -l rootvg

How do I list information about logical volumes?

Run the following command to display information about the logical volume lv1:
lslv lv1

How do I remove a logical volume? You can remove the logical volume lv7 by running the following command:
rmlv lv7

The rmlv command removes only the logical volume, but does not remove other entities, such as file systems or paging spaces that were using the logical volume. How do I mirror a logical volume? 1. mklvcopy LogicalVolumeName Numberofcopies 2. syncvg VolumeGroupName How do I remove a copy of a logical volume? You can use the rmlvcopy command to remove copies of logical partitions of a logical volume. To reduce the number of copies of each logical partition belonging to logical volume testlv, enter:
rmlvcopy testlv 2

Each logical partition in the logical volume now has at most two physical partitions. Queries about volume groups
To show volume groups in the system, type: Lsvg To show all the characteristics of rootvg, type: lsvg rootvg To show disks used by rootvg, type: lsvg -p rootvg

How to add a disk to a volume group? Type the following:


extendvg VolumeGroupName hdisk0 hdisk1 ... hdiskn

How do I find out what the maximum supported logical track group (LTG) size of my hard disk? You can use the lquerypv command with the -M flag. The output gives the LTG size in KB. For instance, the LTG size for hdisk0 in the following example is 256 KB.
/usr/sbin/lquerypv -M hdisk0 256

You can also run the lspv command on the hard disk and look at the value for MAX REQUEST. What does syncvg command do?

The syncvg command is used to synchronize stale physical partitions. It accepts names of logical volumes, physical volumes, or volume groups as parameters. For Ex, to synchronize the physical partitions located on physical volumes hdisk6 and hdisk7, use:
syncvg p hdisk4 hdisk5 To synchronize all physical partitions from volume group testvg, use: syncvg v testvg

How do I replace a disk? 1. extendvg VolumeGroupName hdisk_new 2. migratepv hdisk_bad hdisk_new 3. reducevg -d VolumeGroupName hdisk_bad How can I clone (make a copy of ) the rootvg? You can run the alt_disk_copy command to copy the current rootvg to an alternate disk. The following example shows how to clone the rootvg to hdisk1.
alt_disk_copy -d hdisk1

Network
How can I display or set values for network parameters? The no command sets or displays current or next boot values for network tuning parameters. How do I get the IP address of my machine? Type one of the following:
ifconfig -a host Fully_Qualified_Host_Name

For example, type host cyclop.austin.ibm.com. How do I identify the network interfaces on my server? Either of the following two commands will display the network interfaces:
lsdev Cc if ifconfig a

To get information about one specific network interface, for example, tr0, run the command:
ifconfig tr0

How do I activate a network interface?

To activate the network interface tr0, run the command:


ifconfig tr0 up

How do I deactivate a network interface? For example, to deactivate the network interface tr0, run the command:
ifconfig tr0 down

AIX: Commands compiled by: John Flecther


COMMAND bootlist PARAMETER -m normal <dev1> <dev2> DESCRIPTION Alters the list of boot devices (or the ordering of these devices in the list available to the system) Create a boot image on the default boot device Create a boot image at location and send to tape

bosboot

-a -ad /dev/rnt<x> -b <loc of bootimage>

cfgmgr chcons chdev chdisp -l <device> -a<params>

Configures devices by running the programs in /etc/methods directory. Redirects the system console to device or file, effective next startup Changes a device's characteristics. Changes the display used by the low-function terminal (LFT subsystem. Changes the default font selected at boot time. -a size=+<blocks> /<FS> Changes attributes of a file system. This one will increase the Filesystem . Changes attributes for groups. Rename logical volume from olvname to nlvname Changes attributes of a paging space. Changes the characteristics of a physical volume in a volume group. -q<q name> -a?host = x? Changes the queue name. Changes a subsystem definition in the subsystem object class. Changes or queries the trusted computing base attribute of a file.

chfont chfs

chgroup chlv chps chpv chque chssys chtcb

Users=x,y,z <grp name> -n <nlvname> <olvname> -s<no. pps> <ps name>

chtz. chuser chvfs chvg crfs -v <fstype> (jfs) -d <lvname> -m <mount point> -Ayes crfs -v <fstype> (jfs) -g <vgname> -a size=?<no blocks>? -m <mount point> -Ayes crvfs exportvg grpck hvirprt importvg -y <vgname> <hdisk x> lpstat lsallq lsallqdev None -n ALL rlogin=true <username>

Changes the system time zone information Changes attributes for the specified user. Changes entries in the /etc/vfs file. Sets the characteristics of a volume group. Create a File system on a pre-defined logical volume (which will auto mount at boot!)

Create a File system and its logical volume (uses default lvname)

Creates entries in the /etc/vfs file. Export a volume group Verifies the correctness of a group definition. Changes the attribute values of a virtual printer. Import a Volume Group onto hdisk x

List print queues Lists the names of all configured queues. Lists all configured printer and plotter queue device names within a specified queue. -El <devname> List detailed configuration for a device List all configured devices

lsattr lscfg

-v -l scsi* lsdev -Cc tape -Cc disk -C -s scsi -H lsdisp lsfont lsfs -l

List in detail List all scsi IO devices List configured tape devices List configured disks on devices List all defined scsi devices Lists the displays currently available on the system. Lists the fonts available for use by the display. List all filesystems in /etc/filesystems quering the LVM descriptor area and superblocks Displays the characteristics of file systems.

lsfs lsgroup lsitab lskbd ALL -a

Displays the attributes of groups.(checks NIS aswell!) Lists the records in the /etc/inittab file. Lists the keyboard maps currently available to the low-function terminal (LFT subsystem. Displays the number of fixed licenses and the status of floating licensing.

lslicense

lslpp lslv

-l <lvname> -l <lvname>

List all installed software List configuration details of a given Logical Volume List further configuration details of a given disk Shows print service information stored in the database. List pagaing space List configured disks List configuration details of a given disk List Logical Volumes/Filesystems on a given disk Displays the queue stanza name.

lsprtsv lsps lspv

-ch -a None <hdisk> -l <hdisk>

lsque

lsquedev lssrc lsuser lsvfs lsvg None <vgname> -l <vgname> mkcatdefs mkdev mkfont mkfontdir mkgroup mkitab mklv -y <lvname> <vgname> <no of pps> mklv mklvcopy mknamsv mknotify mkprtsv mkps mkque -a

Displays the device stanza name. List all subsystems Displays attributes of user accounts. Lists entries in the /etc/vfs file. List configured Volume groups List configuration details of a given Volume group List Logical Volumes/Filesystems on a given Volume Group Preprocesses a message source file. Adds a device to the system. Adds the font code associated with a display to the system. Creates a fonts.dir file from a directory of font files. Creates a new group. Makes records in the /etc/inittab file. Create a Logical Volume

Creates a logical volume. Adds copies to a logical volume. Configures TCP/IP-based name service on a host for a client. Adds a notify method definition to the notify object class. Configures TCP/IP-based print service on a host. Add an additional paging space to the system. Adds a printer queue to the system.

mkquedev mkserver mkssys mksysb.

Adds a printer queue device to the system. Adds a subserver definition to the subserver object class. Adds a subsystem definition to the subsystem object class. Backs up mounted file systems in the rootvg volume group for subsequent reinstallation Records size of mounted file systems in the rootvg volume group for reinstallation Sets the required values for starting TCP/IP on a host. Creates a new user account. Customizes a new user account. -y <vgname> -s <ppsize> <hdisk x> Create a Volume Group on hdisk x

mkszfile.

mktcpip mkuser mkuser.sys Mkvg

mkvg mkvirprt odmadd odmchange odmcreate

Creates a volume group. Makes a virtual printer. Adds objects to created object classes. Changes the contents of a selected object in the specified object class. Produces the .c (source and .h (include files necessary for ODM application development and creates empty objectclasses. Deletes selected objects from a specified object class. Removes an object class. Retrieves objects from the specified object classes and places them into an odmadd input file. Displays an object class definition on the screen. Verifies the correctness of local authentication information. Redefines the set of physical volumes of the given volume group in the

odmdelete odmdrop odmget

odmshow pwdck redefinevg

device configuration database. reducevg Removes physical volumes from a volume group. When all physical volumes are removed from the volume group, the volume group is deleted. Reorganizes the physical partition allocation for a volume group. Restores customized information from the boot image. Removes a delta from a Source Code Control System (SCCS file. Removes a device from the system. Removes folders and the messages they contain. Removes a file system. Removes a group. Removes records in the /etc/inittab file. Removes logical volumes from a volume group. Removes copies from a logical volume. Removes messages. Unconfigures TCP/IP-based name service on a host. Removes a notify method definition from the notify object class. Unconfigures a print service on a client or server machine. Removes a paging space from the system. Removes a printer queue from the system. Removes a printer or plotter queue device from the system. Removes a subserver definition from the subserver object class. Removes a subsystem definition from the subsystem object class. Removes a user account.

reorgvg restbase rmdel rmdev rmf rmfs rmgroup rmitab rmlv rmlvcopy rmm rmnamsv rmnotify rmprtsv rmps rmque rmquedev rmserver rmssys rmuser

rmvfs rmvirprt runcat

Removes entries in the /etc/vfs file. Removes a virtual printer. Pipes the output data from the mkcatdefs command to the gencat command. Saves base customized device data in the ODM onto the boot device. -s <subsystem> -s <subsystem> Start a subsystem Stop a subsystem Synchronizes logical volume copies that are not current. Verifies the correctness of a user definition. <vgname> Takes a Volume Group offline Deactivates a volume group. <vgname> Puts a Volume Group online Activates a volume group.

savebase startsrc stopsrc syncvg usrck varyoffvg varyoffvg varyonvg varyonvg

---------------------------------------------------------------------------MISCELLENEOUS ---------------------------------------------------------------------------http://www.rs6000.ibm.com/cgi-bin/ds_form Web based man pages

oslevel whence (program) whereis (program)

Returns operating system level Returns full path of program Returms full path of program

what (program) Displays identifying info from the executable like version number, when compiled. lslpp -L all lslpp -L (program set name) lslpp -f lslpp -ha list all installed software Check if software installed Lists filesets vs packages Lists installation history of filesets Checks id fix is installed

instfix -ik (fix number eg IX66617) instfix -ik 4330-02_AIX_ML compress -c file.txt > file.Z

Create a compressed file.

uuencode (infile) (extract-file-name) > (output file) Converts a binary file to an ASCII file for transfer by modem or email uudecode (encoded file) Extracts a binary file from encoded file and calls it the extract-file-name Examples :uuencode maymap maymap > maymap.enc uuencode maymap.enc od -c /tmp ls -i echo * alog -o -t boot Displays contents of the /tmp directory file Lists files with their inode numbers Lists files, can be used if ls is corrupt/missing View the boot log Changes the timezone in /etc/environment file Changes the language in /etc/environment file

chtz (timezone eg GMT0BST) chlang (language eg En_GB) ar -v -t (archive file) ar -v -x (archive file) ar -v -t /usr/lib/libC-r.a

List contents of an archive Extracts the archive Lists contents of the libC_r.a library

find /source -print | cpio -pdm /target Copying directories using cpio, creates /target/source directory. dump -nTv (binary executable) dump -c dump -o Displays the contents of an executable file

Displays string information Displays object file headers

dump -l dump -s snap -ao /dev/rmt0 snap -ad (directory) (/tmp/ibmsupt) /usr/dt/bin/dtconfig -d /usr/dt/bin/dtconfig -e /var/dt/Xpid

Displays line numbers Displays the text section Create a snapshot onto tape Create a snapshot into a named directory other than the default Disables desktop logins Enables desktop logins PID of the dtlogin process

-------------------------------------------------------------------------------TERMINALS -------------------------------------------------------------------------------tty termdef Displays what the tty/pty number of the terminal is. Reports the termtype setup in smit for the tty port that termdef is run on. Sets tty to a vt100 terminal type

chdev -l (device eg tty1) -a term=vt100 penable tty0 pdisable tty0

adds getty line into /etc/inittab for tty0 and starts getty disables the getty line and disables getty

penable / pdisable -a option is for all stty erase ^? stty erase ^H Set backspace key for vt100 terminals Set backspace key for wyse50 terminals

lscons Displays the console device chcons -a login=enable (device eg /dev/tty1) Changes the console device Create ttys on ports 0 to 7 on adapter sa2 :for i in 0 1 2 3 4 5 6 7 do mkdev -c tty1 -t tty -s rs232 -p sa2 -w$i -a login=enable -a term=vt100 done portmir -t /dev/tty0 Mirror current terminal onto /dev/tty0 portmir -o Turns off port mirroring -------------------------------------------------------------------------------NETWORK -------------------------------------------------------------------------------host (ip or hostname) Resolves a hostname / ip address

hostname hostname (hostname)

Displays hostname Sets the hostname until next reboot Changes hostname permanently

chdev -l (device name) -a hostname=(hostname) chdev -l inet0 -a hostname=thomas

ifconfig (device name) Displays network card settings ifconfig (device name) up Turns on network card ifconfig (device name) down Turns off network card ifconfig (device name) detach Removes the network card from the network interface list ifconfig en0 inet 194.35.52.1 netmask 255.255.255.0 up ifconfig lo0 alias 195.60.60.1 Create alias ip address for loopback route (add/delete) (-net/-host) (destination) (gateway) Adds or deletes routes to other networks or hosts, does not update the ODM database and will be lost at reboot. route add -net 194.60.89.0 194.60.90.4 lsattr -EHl inet0 odmget -q "name=inet0" CuAt refresh -s inetd kill -1 (inetd PID) netstat -i entstat -d (ethernet adapter eg en0) arp -a no -a Displays routes set in ODM and hostname Displays routes set in ODM and hostname Refresh inetd after changes to inetd.conf Refresh inetd after changes to inted.conf Displays interface statistics Displays ethernet statistics Displays ip to mac address table from arp cache

Displays network options use -o to set individual options or -d to set individual options to default. no -o option=value (this value is reset at reboot) no -o "ipforwarding=1" traceroute (name or ipaddress) ping -R (name or ipaddress) Displays all the hops from source to destination supplied. Same as traceroute except repeats.

-------------------------------------------------------------------------------N.F.S. -------------------------------------------------------------------------------exportfs exportfs -a Lists all exported filesystems Exports all fs's in /etc/exports file

exportfs -u (filesystem) mknfs rmnfs mknfsexp -d /directory mknfsmnt

Un-exports a filesystem Configures and starts NFS services Stops and un-configures NFS services Creates an NFS export directory Creates an NFS mount directory Mount an NFS filesystem

mount hostname:/filesystem /mount-point nfso -a nfso -o option=value nfso -o nfs_use_reserved_port=1

Display NFS Options Set an NFS Option

-------------------------------------------------------------------------------BACKUPS -------------------------------------------------------------------------------MKSYSB ------ -----mkszfile -f mkszfile -X mksysb (device eg /dev/rmt0) CPIO ARCHIVE ------------ --------find (filesystem) -print | cpio -ocv > (filename or device) eg find ./usr/ -print | cpio -ocv > /dev/rmt0 CPIO RESTORE ------------ --------cpio -ict < (filename or device) | more Lists archive cpio -icdv < (filename or device) cpio -icdv < (filename or device) ("files or directories to restore") eg cpio -icdv < /dev/rmt0 "tcpip/*" cpio -icdv < /dev/rmt0 "*resolve.conf" TAR ARCHIVE ----------- --------tar -cvf (filename or device) ("files or directories to archive") Restore directory and contents Restore a named file Creates /image.data file (4.x onwards) Creates /fs.size file (3.x)

eg tar -cvf /dev/rmt0 "/usr/*" TAR RESTORE ----------- --------tar -tvf (filename or device) Lists archive

tar -xvf (filename or device) Restore all tar -xvf (filename or device) ("files or directories to restore") use -p option for restoring with orginal permissions eg tar -xvf /dev/rmt0 "tcpip" Restore directory and contents tar -xvf /dev/rmt0 "tcpip/resolve.conf" Restore a named file AIX ARCHIVE ----------- -------find (filesystem) -print | backup -iqvf (filename or device) --- Backup by filename. eg find /usr/ -print | backup -iqvf /dev/rmt0 backup -(backup level 0 to 9) -f (filename or device) ("filesystem") --Backup by inode. eg backup -0 -f /dev/rmt0 "/usr" AIX RESTORE ----------- -------restore -qTvf (filename or device) Lists archive -u option updates /etc/dumpdates file

restore -qvxf (filename or device) Restores all restore -qvxf (filename or device) ("files or directories to restore") (use -d for restore directories) restore -qvxf /dev/rmt0.1 "./etc/passwd" restore -s4 -qTvf /dev/rmt0.1 Restore /etc/passwd file Lists contents of a mksysb tape

BACKUPS ACROSS A NETWORK ------------------------ --------------------To run the backup on a local machine (cpio) and backup on the remote machine's (remhost) tape drive (/dev/rmt0) find /data -print | cpio -ocv | dd obs=32k | rsh remhost \ "dd ibs=32k obs=64k of=/dev/rmt0"

To restore/read the backup (cpio) on the remote machine dd ibs=64k if=/dev/rmt0 | cpio -icvt To restore/read the backup (cpio) on the local machine from the remote machine's (remhost) tape drive (/dev/rmt0) rsh remhost "dd ibs=64k obs=32k if=/dev/rmt0" | dd ibs=32k \ | cpio -icvt To run the backup (cpio) on a remote machine (remhost) and backup to the local machines tape drive (/dev/rmt0) rsh remhost "find /data -print | cpio -icv | dd ibs=32k" \ | dd ibs=32k obs=64k of=/dev/rmt0 COPYING DISKETTES -----------------------------dd if=/dev/fd0 of=(filename) bs=36b dd if=(filename) of=/dev/fd0 bs=36b conv=sync COPYING TAPES ----------------------dd if=/dev/rmt0 of=(filename) dd if=(filename) of=/dev/rmt0 or tcopy or flcopy

-------------------------------------------------------------------------------VI Commands -------------------------------------------------------------------------------:g/xxx/s//yyy/ global change where xxx is to be changed by yyy sed 's(ctrl v ctrl m)g//g' old.filename > new.filename Strips out ^M characters from ascii files that have been transferred as binary. To enter crontrol characters type ctrl v then ctrl ? where ? is whatever ctrl character you need. -------------------------------------------------------------------------------DEVICES -------------------------------------------------------------------------------lscfg lscfg -v lscfg -vl (device name) lists all installed devices lists all installed devices in detail lists device details

bootinfo -b bootinfo -k bootinfo -r bootinfo -s (disk device) bootinfo -T lsattr -El sys0 -a realmem

reports last device the system booted from reports keyswitch position ------- 1=secure, 2=service, 3=normal reports amount of memory (/ by 1024) reports size of disk drive reports type of machine ie rspc reports amount of useable memory Creates a /dev/ device file.

mknod (device) c (major no) (minor no) mknod /dev/null1 c 2 3

lsdev -C lists all customised devices ie installed lsdev -P lists all pre-defined devices ie supported lsdev -(C or P) -c (class) -t (type) -s (subtype) chdev -l (device) -a (attribute)=(new value) chdev -l sys0 -a maxuproc=80 Change a device attribute

lsattr -EH -l (device) -D Lists the defaults in the pre-defined db lsattr -EH -l sys0 -a modelname rmdev -l (device) rmdev -l (device) -d rmdev -l (device) -SR lsresource -l (device) Change device state from available to defined Delete the device S stops device, R unconfigures child devices Displays bus resource attributes of a device.

Power Management (PCI machines) ------------------------------- -----------pmctrl -a rmdev -l pmc0 mkdev -l pmc0 Displays the Power Management state Unconfigure Power Management Configure Power Management

-------------------------------------------------------------------------------TAPE DRIVES -------------------------------------------------------------------------------rmt0.x where x = A + B + C A = density B = retension C = rewind 0 = high 0 = no 0 = no 4 = low 2 = yes 1 = yes

tctl -f (tape device) fsf (No) tctl -f (tape device) bsf (No) tctl -f (tape device) rewind tctl -f (tape device) offline tctl -f (tape device) status

Skips forward (No) tape markers Skips back (No) tape markers Rewind the tape Eject the tape Show status of tape drive

chdev -l rmt0 -a block_size=512 changes block size to 512 bytes (4mm = 1024, 8mm = variable but 1024 recommended) bootinfo -e diag -c -d (tape device) tapechk (No of files) < /dev/rmt0 answer of 1 = machine can boot from a tape drive answer of 0 = machine CANNOT boot from tape drive Hardware reset a tape drive. Checks Number of files on tape. Rewinds the tape !!!

-------------------------------------------------------------------------------PRINTERS / PRINT QUEUES -------------------------------------------------------------------------------splp (device) splp /dev/lp0 export $LPDEST="pqname" lsvirprt Displays/changes printer driver settings Set default printer queue for login session Lists/changes virtual printer attributes. Removes a virtual printer

rmvirprt -q queuename -d queuedevice qpri -#(job No) -a(new priority) qhld -#(job No) qhld -r #(job No) qchk -A lpstat lpstat -p(queue) qcan -x (job No) cancel (job No) enq -U -P(queue) enable (queue) enq -D -P(queue) disable (queue)

Change a queue job priority. Put a hold on hold Release a held job Status of jobs in queues Status of jobs in a named queue Cancel a job from a queue Enable a queue Disable a queue

qmov -m(new queue) -#(job No) startsrc -s qdaemon lssrc -s qdaemon stop -s qdaemon

Move a job to another queue Start qdaemon sub-system List status of qdaemon sub-system Stop qdaemon sub-system

-------------------------------------------------------------------------------FILE SYSTEMS -------------------------------------------------------------------------------Physical Volumes (PV's) ----------------------- -----lspv lspv (pv) lspv -l (pv) lspv -p (pv) chdev -l (pv) -a pv=yes chpv -v r (pv) chpv -v a (pv) chpv -a y (pv) chpv -a n (pv) migratepv (old pv) (new pv) Volume Groups (VG's) -------------------- ------lsvg lsvg (vg) lsvg -l (vg) lsvg -p (vg) lsvg -o varyonvg (vg) varyonvg -f (vg) varyonvg -s (vg) varyoffvg (vg) synclvodm (vg) mkvg -y(vg) -s(PP size) (pv) mkvg -y datavg -s 4 hdisk1 Lists all volume groups Lists the volume group details Lists all logical volumes in the volume group Lists all physical volumes in the volume group Lists all varied on volume groups Vary On a volume group Forces the varyon process Vary on a VG in maintenance mode. LV commands can be used on VG, but LV,s cannot be opened for I/O. Vary Off a volume group Tries to resync VGDA, LV control blocks and ODM. Create a volume group Lists all physical volumes (hard disks) Lists the physical volume details Lists the logical volumes on the physical volume Lists the physical partition usage for that PV Makes a new hdisk a pysical volume. Removes a disk from the system. Adds the removed disk back into the system. Changes pv allocatable state to YES Changes pv allocatable state to NO Moves all LV's from one PV to another PV, both PV's must be in the same volume group.

reducevg -d (vg) (pv) Removes a volume group reducevg (vg) (PVID) Removes the PVID disk reference from the VGDA when a disk has vanished without the reducevg (vg) (pv) command being run first. extendvg (vg) (new pv) exportvg (vg) Adds another PV into a VG. Exports the volume group eg deletes it!

Note : 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. chvg -a y (vg) lqueryvg -Atp (pv) importvg -y (vg name) (pv) importvg (pv) chvg -Q (y/n) (vg name) Logical Volumes (LV's) ---------------------- ------lslv (lv) lslv -l (lv) Lists the logical volume details Lists the physical volume which the LV is on Create a logical volume Creates a named logical volume Auto Vary On a volume group at system start. Details volume group info for the hard disk. Import a volume group from a disk. Same as above but VG will be called vg00 etc. Turns on/off Quorum checking on a vg.

mklv (vg) (No of PP's) (pv Name optional) mklv -y (lv) (PP's) (pv name optional) chlv -n (new lv) (old lv) extendlv (lv) (extra No of PP's) rmlv (lv)

Rename a logical volume Increase the size of an LV Remove a logical volume

mklv/extendlv -a = PP alocation policy -am = middle -ac = center -ae = edge -aie = inner edge -aim = inner middle migratepv -l (lv) (old pv) (new pv) Move a logical volume between physical volumes. Both physical volumes must be in the same volume group ! mklv -y (lv) -t jfslog (vg) (No of PP's) (pv Name optional) Creates a JFSlog logical volume. logform (/dev/lv) getlvcb -AT (lv) Initialises an LV for use as an JFSlog Displays Logical Volume Control Block information

File Systems (FS's) ------------------- ---lsfs lsfs -q (fs) mount mount (fs or lv) mount a / mount all mount -r -v cdrfs /dev/cd0 /cdrom Lists all filesystems Lists the file system details Lists all the mounted filesystems Mounts a named filesystem Mounts all filesystems Mounts cd0 drive over /cdrom

crfs -v jfs -d(lv) -m(mount point) -A yes Will create a file system on the whole of the logical volume, adds entry into /etc/filesystems and will create mount point directory if it does not exist. crfs -v jfs -g(vg) -m(mount point) -a size=(size of fs) -A yes Will create a logical volume on the volume group and create the file system on 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. chfs -A yes (fs) chfs -a size=(new fs size)(fs) rmfs (fs) Change file system to Auto mount in /etc/filesystems Change file system size

Removes the FS and will also remove the LV if there are no onther file systems on it. Reports the fragment status of the file system. Runs in report only defrag mode (no action). Defragments a file system.

defrag -q (fs) defragfs -r (fs) defragfs (fs)

fsck (fs) Verify a file system, the file system must be unmounted! fsck (-y or -n) (fs) Pre-answer questions either yes or no ! 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. mklvcopy -s n (lv) (copies 2 or 3) (pv) Creates a copy of a logical volume onto another physical volume. The physical volume MUST be in the same volume group as the orginal logical volume ! rmlvcopy (lv) (copies 1 or 2) rmlvcopy (lv) (copies 1 or 2) (pv) syncvg -p (pv) syncvg -l (lv) syncvg -v (vg) Removes logical volume copies. From this pv only! Synchronize logical partion copies

mirrorvg (vg) (pv) Mirrors the all the logical volumes in a volume group onto a new physical volume. New physical volume must already be part of the volume group. -------------------------------------------------------------------------------BOOT LOGICAL VOLUME (BLV) -------------------------------------------------------------------------------bootlist -m (normal or service) -o displays bootlist bootlist -m (normal or service) (list of devices) change bootlist bootinfo -b bootinfo -t bosboot -a -d (/dev/pv) mkboot -c -d (/dev/pv) savebase -d (/dev/pv) Identifies the bootable disk Specifies type of boot Creates a complete boot image on a physical volume. Zero's out the boot records on the physical volume. Saves customised ODM info onto the boot device.

-------------------------------------------------------------------------------SYSTEM DUMP -------------------------------------------------------------------------------sysdumpdev -l sysdumpdev -e sysdumpdev -L sysdumpstart -p sysdumpstart -s Lists current dump destination. Estimates dumpsize of the current system in bytes. Displays information about the previous dump. Starts a dump and writes to the primary dump device. Starts a dump and writes to the secondary dump device.

(MCA machine can also dump if key is in service position and the reset button is pressed) sysdumpdev -p (dump device) -P Sets the default dump device, permanently

Analyse dump file :echo "stat\n status\n t -m" | crash /var/adm/ras/vmcore.0 -------------------------------------------------------------------------------PAGING SPACE (PS's) -------------------------------------------------------------------------------lsps -a lsps -s lsps (ps) Lists out all paging space Displays total paging and total useage

mkps -s(No of 4M blocks) -n -a (vg) mkps -s(No of 4M blocks) -n -a (vg) (pv) -n = don't activate/swapon now -a = activate/swapon at reboot

chps -a n (ps) chps -s(No of 4M blocks) (ps) chlv -n (new name) (old name)

Turns off paging space. Increases paging space. Change paging space name

rmps (ps) Remove paging space. PS must have been turned off and then the system 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 crontab -e crontab -l > (filename) crontab (filename) crontab -r crontab -v /var/adm/cron/cron.allow /var/adm/cron/cron.deny /var/adm/cron/crontab List out crontab entrys Edit crontab entrys Output crontab entrys to a file Enter a crontab from a file Removes all crontab entrys Displays crontab submission time. File containing users allowed crontab use. File containing users denied crontab use. Directory containing users crontab entries. Schedule a job using at

at (now + 2 minutes, 13:05, etc) {return} Command or schell script {return} {CTRL D} at -l atq at -r (at job No) atrm (at job No) /var/adm/cron/at.allow /var/adm/cron/at.deny /var/adm/cron/atjobs

Lists out jobs scheduled to run via at command Removes an at job scheduled to run. File containing users allowed at use. File containing users denied at use. Directory containing users at entries.

-------------------------------------------------------------------------------SECURITY -------------------------------------------------------------------------------groups setgroups Lists out the groups that the user is a member of Shows user and process groups

chmod abcd (filename)

Changes files/directory permissions

Where a is (4 SUID) + (2 SGID) + (1 SVTX) b is (4 read) + (2 write) + (1 execute) permissions for owner c is (4 read) + (2 write) + (1 execute) permissions for group d is (4 read) + (2 write) + (1 execute) permissions for others -rwxrwxrwx -rwxrwxrwx -rwxrwxrwx | | | Owner Group Others -rwSrwxrwx = SUID -rwxrwSrwx = SGID drwxrwxrwt = SVTX chown (new owner) (filename) chgrp (new group) (filename) Changes file/directory owners Changes file/directory groups Do both !!!

chown (new owner).(new group) (filename) umask umask abc

Displays umask settings Changes users umask settings

where ( 7 - a = new file read permissions) ( 7 - b = new file write permissions) ( 7 - c = new file execute permissions) eg umask 022 = new file permissions of 755 = read write and execute for owner read ----- and execute for group read ----- and execute for other mrgpwd > file.txt passwd pwdadm (username) pwdck -t ALL lsgroup ALL mkgroup (new group) chgroup (attribute) (group) rmgroup (group) Creates a standard password file in file.txt Change current user password Change a users password Verifies the correctness of local authentication Lists all groups on the system Creates a group Change a group attribute Removes a group

-------------------------------------------------------------------------------USERS --------------------------------------------------------------------------------

passwd -f passwd -s chfn (username) chsh (username) (shell) env printenv id id (user) whoami who am i who / w who -b uptime (or who -m)

Change current users gecos (user description) Change current users shell Changes users gecos Changes users shell Displays values of environment variables Displays current user's uid and gid details Displays user uid and gid details Displays current user details Displays details of all users currently logged in. Displays system reboot time Displays number of users logged in, time since last reboot, and the machine load averages. Displays number of current user licensese Changes the number of user licenses

lslicense chlicense -u (number)

lsuser ALL Lists all users details lsuser (username) Lists details for user lsuser -a(attribute) (username or ALL) Lists user attributes lsuser -a home ALL mkuser -a(attributes) (newuser) chuser (attributes) (user) chuser login=false (user) rmuser -p (user) usrck -t ALL fuser -u (logical volume) Add a new user Change a user Lock a user account Removes a user and all entries in security files Checks all the user entires are okay. Displays processes using the files in that LV

lsattr -D -l sys0 -a maxuproc Displays max number of processes per user chdev -l sys0 -a maxuproc=(number) Changes max number of processes per user -------------------------------------------------------------------------------REMOTE USERS --------------------------------------------------------------------------------

ruser -a -f (user) ruser -a -p (host) ruser -a -r (host) ruser -d -f (user) ruser -d -p (host) ruser -d -r (host) ruser -s -F ruser -s -P ruser -s -R ruser -X -F ruser -X -P ruser -X -R

Adds entry into /etc/ftpusers file Adds entry into /etc/host.lpd file Adds entry into /etc/hosts.equiv file Deletes entry in /etc/ftpusers file Deletes entry in /etc/host.lpd file Deletes entry in /etc/hosts.equiv file Shows all entries in /etc/ftpusers file Shows all entries in /etc/host.lpd file Shows all entries in /etc/hosts.equiv file Deletes all entries in /etc/ftpusers file Deletes all entries in /etc/host.lpd file Deletes all entries in /etc/hosts.equiv file

-------------------------------------------------------------------------------INITTAB -------------------------------------------------------------------------------telinit S telinit 2 telinit q lsitab -a lsitab (ident eg tty1) mkitab ("details") chitab ("details") rmitab (ident eg tty1) Switches to single user mode. Switches to multi user mode. Re-examines /etc/inittab Lists all entries in inittab Lists the tty1 entry in inittab Creates a new inittab entry Ammends an existing inittab entry Removes an inittab entry.

chitab "tty1:2:respawn:/usr/bin/getty /dev/tty1" -------------------------------------------------------------------------------ODM -------------------------------------------------------------------------------odmget -q "name=lp1" CuDv |more Gets lp1 info from pre-defined database. odmget -q "name-lp1" CuAt |more odmdelete -o CuAt -q "name=lp1" Gets lp1 info from customised database. Deletes lp1 info from customised db.

odmget -q "name=lp1" CuAt > lp1.CuAt Export ODM info to text file. odmadd < lp1.CuAt Import ODM info from text file.

-------------------------------------------------------------------------------ERROR LOGGING -------------------------------------------------------------------------------/usr/lib/errdemon -l /usr/lib/errdemon /usr/lib/errstop errpt errpt -a errpt -j (identifier) Displays errorlog attributes. Starts error logging. Stops error logging. Displays summary errorlog report. Displays detailed errorlog report. Displays singe errorlog report.

Note : errorlog classes are H=Hardware S=Software O=Information V=Undetermined errclear (days) errclear -d (class) (days) Deletes all error classes in the errorlog. 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 230 chrs" Enters an operator notifaction message into the errorlog. -------------------------------------------------------------------------------PERFORMANCE MONITORING -------------------------------------------------------------------------------vmstat (drive) (interval) (count) vmstat hdisk0 5 20 vmstat -s vmstat -f vmstat -i iostat (drive) (interval) (count) iostat hdisk0 5 20 iostat -d (drive) (interval) (count) iostat -t (interval) (count) sar -u -P ALL 10 10 Reports virtual memory statistics. Diplays number of paging events since system start. Diplays number of forks since system start. Diplays number of interupts by device since system start. Reports i/o and cpu statistics. Limits report to drive statistics. Limits report to tty statistics. Displays %usr %sys %wio %idle for all processors

-------------------------------------------------------------------------------DOS DISKETTES -------------------------------------------------------------------------------dosdir dosdir (directory) Reads directory listing of a diskette 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) doswrite -D/dev/fd0 (unixfile) (dosfile) dosdel (dosfile) dosformat Writes a file to diskette

Deletes a dos file on diskette Formats the diskette

-------------------------------------------------------------------------------SENDMAIL -------------------------------------------------------------------------------sendmail -bi newaliases sendmail -bp mailq sendmail -q Creates new aliase db from /etc/aliase file. Displays the contents of the mail queue Processe the sendmail queue NOW

sendmail -bt -d0.4 < /dev/null Prints out sendmail version, compile defines and system information refresh -s sendmail kill -l (sendmail PID) Restart sendmail

-------------------------------------------------------------------------------SP / PSSP -------------------------------------------------------------------------------dsh (command) Efence Efence (node number) Eunfence (node number) Estart spmon -q spmon -d -G spmon -L frame1/node3 spmon -p off frame1/node3 spmon -p on frame1/node3 Runs the command on all the nodes Diplays which node are currently fenced Fences the node Unfences the node Starts the switch Starts SP monitor in gui Diag info, lists LED and switch info for all nodes Displays LED for node 3 in frame 1 Powers off the node Powers on the node

spled

Diplays all the nodes LED's in a updating gui

s1term -w (frame number) (node number) Opens serial terminal (read and write) s1term (frame number) (node number) Opens serial terminal (read only) Example :- s1term 1 1 Opens a serial terminal to console port on frame 1 node 1 which is read only. When rebooting a node use read only. splstdata -e -d -n -h -s -b -a -i Lists site environment database information Displays df command from each node Lists node configuration Diplays lscfg command from each node Lists switch node information Lists boot/installation information Lists LAN database information Displays netstat -in command from each node

AIX COMMAND GUIDE


INTRODUCTION
This is my unix command help file which has been built up over the years. This file was built primarily for my own reference and is not intended to be an authoratative guide to all commands for AIX - often if there is a very short description for a command, you can take this as RTFM. I am not a systems administrator, but have been called on to do the job occasionally (and install a box or two) - this helpfile should be ideal for people who use AIX, but aren't responsible for the deep magic required for hardware configuration. You may find this file helpful despite the numerous omissions nonetheless. This file was originally a plain text file but I have converted to HTML using Lemmy (A vi clone for Windows). Because it has been hand-converted from the original text document, there's a few hangovers from it that I just can't be bothered to remove such as the caps headings. Additionally, some browsers may not render certain characters. I've tried (and quite probably failed) to keep several conventions within this document - any command, if mentioned in the description of another command should have a bookmark link to the description of that command; all examples are in blue text - apologies to lynx users, but examples should be written so that they're recognisable anyway (and if you're using lynx, you probably know unix quite well anyway so I don't really know why I'm apologising ;-). If a command has more than one useful option, I've tried to put them into <UL> Unordered list tags. If a command stands almost alone, or is complex within itself, it doesn't appear in this file but in it's own separate file (with a link if I've converted it to html. Examples are vi and awk. BASIC FILE HANDLING ls

- list files in directory; use with options


-l (long format) -a (list . files too) -r (reverse order) -t (newest appears first) -d (do not go beyond current directory) -i (show inodes)

For a more detailed description of ls see ls -l more - used to control input by pages - like the dos /p argument with dir. e.g. $ more /etc/motd ************************************************************************** ***** ** ** * Welcome to AIX Version 4.1! * ** ** * Please see the README file in /usr/lpp/bos for information pertinent to * * this release of the AIX Operating System. * ** ** ************************************************************************** ***** motd: END Useful keys for use with more:

b (back a page) ' (go to top) v (vi the file) / (Search) q (quit) ' ' (down a page) Control-G (View current line number <CR> (down a line)

See also pg which is extremely similar

pg - used to control input by pages - like the dos /p argument. pg performs the same function as the more command but has different control, as it is based on ex Helpful keys for pg:

1 (go to top) $ (go to bottom)

h (help) / (Search) ? (Search back) q (quit) -1 (back a page)

pwd - show present working directory. e.g. $ pwd /usr/live/data/epx/vss2 To change the current working directory use cd cd - change directory (without arguments, this is the same as $ cd $HOME or $ cd ~) cp <source> <destination> - copies a file from one location to another. e.g. $ cp /etc/hosts /etc/hosts.backup # make a backup of the hosts file $ cp /etc/motd /tmp/jon/ # Copy file /etc/motd to directory /tmp/jon/ Options

-f (to force the copy to occur) -r (to recursively copy a directory) -p (to attempt to preserve permissions when copying)

synonym: copy mv <source> <destination> - move a file from one location to another. e.g. $ mv /tmp/jon/handycommands.txt . # move handycommands in /tmp/jon to current directory $ mv -f vihelp vihelp.txt # Move file vihelp to vihelp.txt (forced) Options

-f (to force the move to occur) -r (to recursively move a directory) -p (to attempt to preserve permissions when moving)

synonym: move

. rm <filename> - removes a file. e.g. $ rm /tmp/jon/*.unl # remove all *.unl files in /tmp/jon $ rm -r /tmp/jon/usr # remove all files recursively Options

-f (to force the removal of the file) -r (to recursively remove a directory)

du Recursively lists directories and their sizes. e.g. $ du /etc # list recursively all directories off /etc 712 /etc/objrepos 64 /etc/security/audit 536 /etc/security 104 /etc/uucp 8 /etc/vg 232 /etc/lpp/diagnostics/data 240 /etc/lpp/diagnostics 248 /etc/lpp 16 /etc/aliasesDB 16 /etc/acct 8 /etc/ncs 8 /etc/sm 8 /etc/sm.bak 4384 /etc The sizes displayed are in 512K blocks. To view this in 1024K blocks use the option -k lp -d<Printername> <Filename> send file to printer. e.g. $ lp -dhplas14 /etc/motd # send file /etc/motd to printer hplas14 $ lp /etc/motd # send file /etc/motd to default printer cat - print a file to stdout (screen). e.g. $ cat /etc/motd # display file /etc/motd to screen ************************************************************************** ***** ** ** * Welcome to AIX Version 4.1! * ** ** * Please see the README file in /usr/lpp/bos for information pertinent to * * this release of the AIX Operating System. * ** ** ************************************************************************** ***** cat is also useful for concatenating several files. e.g. $ cat fontfile IN* > newfile # appends fontfile and all files beginning with IN to newfile Though this might seem an essentially useless command, because most unix commands always take a filename argument, it does in fact come in extremely useful at more advanced levels. Awards are given out occasionally for the most useless usage of cat. If an option of '-' is specified, cat will take its input from stdin.

INPUTS, OUTPUTS AND WILDCARDS


Unix commands generally get their information from the screen, and output to it. There are three main 'streams' which unix uses to get/place it's information on. These streams are called:

stdin (Standard Input) - normally, what you type into the screen stdout (Standard Output) - normally, what is output to the screen stderr (Standard Error) - normally, error messages which go to the screen

any of these may be redirected by the following symbols: < <filename> take input from <filename> rather than the screen. e.g. $ ksh < x # will read all commands from the file x and execute them using the Korn shell. > <filename> take output from the command and place it in <filename>. e.g. $ ls > x will place the output of the command 'ls' in the file x >> <filename> take output from the command and append it to <filename>. e.g. $ ls /tmp >> x will place the output of the command 'ls' and append it to the file x 2> <filename> take any error messages from the command and put it in <filename>.

Ex: $ ls /tmp 2>/dev/null would throw away any error messages that are produced by ls (sorry, /dev/null is a file that, if written to, the information disappears never to be seen again). command1 | command2 Pipe - Takes the standard output of the first command, and turns it into the standard input of the second command. The output of the second command will then be put on the standard output (which, again, may be a pipe) e.g. $ ls | more will send the output of 'ls' into the command 'more', thus producing a directory listing which stops after every page. This method is called piping.

command1 & - the ampersand (&) forces command1 to run in the background. so that you may continue to type other commands in the shell, while command1 executes. It is not advisable to run a command in the background if it outputs to the screen, or takes it's input from the screen See also tee which allows splitting of the input stream and output to several different places at once. Wildcards B Bib Baby Fox Fib There are various wildcards which you may use. One is '*' which means 0 or more characters. e.g. 'B*' will match 'B,Bib and Baby' from the list above, another wildcard is '?' which matches 1 character, e.g. '?ib' will match 'Bib and Fib'. Wildcards differ depending on the program in use: awk derivatives (awk,sed,grep,ex,vi,expr and others) have the following special characters:

^ beginning of the line $ end of the line . any character

* one or more of the preceding character .* any number of characters \n Carriage return \t Tab character \<char> Treat <char> as is (so, \$ would try to match a '$')

Given the following four lines: Chargeable calls in bundle: $47.50 Chargeable calls out of bundle: $20.50 Other bundle charges: $0.00 Total Charge: $20.50 $ grep "^Charg.*bundle.*\$.*" would match the first two lines. In english - match all lines which start with 'Charg', then have any number of characters and then the word 'bundle', then have any number of characters, and then a dollar symbol, and then have any number of characters following to the end of the line

OTHER FILE HANDLING COMMANDS


type <command> - show where the source of a command is: e.g. $ type sendmail sendmail is /usr/sbin/sendmail This command is merely an alias for 'whence -v' whence <command> - show where the source of a command is: shell builtin command. See type Use option: -v for verbose mode which <command> - show where the source of a command is held. Almost the same as type and whence chmod <Octal Permissions> <file(s)> - change file permissions. e.g. $ chmod 666 handycommands changes the permissions (seen by ls -l) of the file handycommands to -rw-rw-rwr = 4, w = 2, x = 1. In the above example if we wanted read and write permission for a particular file then we would use r + w = 6. If we then wanted to have the file have readwrite permissions for User, Group and All, then we would have permissions of 666. Therefore the command to change is that above. $ chmod 711 a.out Changes permissions to: -rwx--x--x Additional explanation of file permissions and user/group/all meaning are given in the description of ls -l You may specify chmod differently - by expressing it in terms of + and - variables. For example $ chmod u+s /usr/bin/su will modify the "sticky bit" on su, which allows it to gain the same access on the file as the owner of it. What it means is "add s permission to user". So a file that started off with permissions of "-rwxr-xr-x" will change to "rwsr-xr-x" when the above command is executed. You may use "u" for owner permissions, "g" for group permissions and "a" for all. chown <Login Name> <file(s)>

- Change ownership of a file. Must be done as root. e.g. chown informix *.dat # change all files ending .dat to be owned by informix chgrp <Group Name> <file(s)> - Change group ownership of a file. Must be done as root. e.g. chgrp sys /.netrc # change file /.netrc to be owned by the group sys mvdir <Source Directory> <Destination Directory> - move a directory - can only be done within a volume group. To move a directory between volume groups you need to use mv -r or find <dirname> -print | cpio -pdumv <dirname2>; rm -r <dirname> cpdir <Source Directory> <Destination Directory> - copy a directory. See mvdir rmdir <Directory> - this is crap - use rm -r instead mkdir <Directory> - Creates a directory. e.g. $ mkdir /tmp/jon/ # create directory called /tmp/jon/ find <pathname> -name "searchkey" -print - search for files - e.g. $ find . -name "system.log" -print # will find all files (with full path names) called system.log - Wildcards are allowed, e.g. $ find /tmp -name "sl.*" -atime +0 -print # will print out all files in /tmp/ that start sl. and which haven't been accessed for a day. Helpful for finding lost files, or finding stuff in enormous directories. Other useful options include: -atime +<days> - finds files that haven't been accessed for 1+days also, ctime (creation time) and mtime (modify time) -prune - stay in current directory - don't look in dirs off the directory specified in path names - e.g. $ find /tmp -user "compgnc" -prune -print # will find all files in /tmp which user compgnc owns and will not search lower directories (e.g. /tmp/usr) -size +<blocks> - finds files that are bigger than <blocks> -exec rm {} \; - remove all files found...dangerous command - e.g. $ find /tmp -name "sl.*" -atime +0 -prune -print -exec rm {} \; # will remove all files in /tmp starting 'sl.' that haven't been accessed for a day. Spacing of this command is important! Most exec commands are possible: $ find /usr2/calltest -name "*.4gl" -print -exec grep "CHECK" {} \; | pg -ok - like exec only it prompts for confirmation after each occurence. e.g. $ find /tmp/disk7 -name "*" -print -ok doswrite -a {} {} \; # Please note that you MUST end any exec or ok option with an escaped semicolon (\;). -user <username> - finds all files owned by <username> -group <groupname> - finds all files with a group of <groupname>

ln -s <Directory> <symbolic link> - create a symbolic link to a different directory from current directory: e.g. $ ln -s /usr/uniplex/compgnc /u/compgnc/uni # would create a link called 'uni' in the directory /u/compgnc. From then on, typing cd uni would cd to /usr/uniplex/compgnc. You can also give two files the same name. e.g. $ ln make.e_enquiry makefile # would link the two files so that they are identical, and when you change one, you change the other. You may also create a symbolic link to a host(!).

Instead of typing 'rlogin hpserver' every time, by typing $ ln -s /usr/bin/rsh hpserver # will create a link so that whenever you type 'hpserver' it will execute a remote shell on the machine. Option -f forces the link to occur head -<Number> <FileName> - prints out the first few line of a file to screen. Specify number to indicate how many lines (default is 10). e.g. If you sent something to a labels printer and it wasn't lined up, then you could print the first few labels again using: $ head -45 label1.out | lp -dlocal1

tail -<Number> <FileName> - prints out the end of a file. Very similar to head but with a very useful option '-f' which allows you to follow the end of a file as it is being created.e.g. $ tail -f vlink.log # follow end of vlink.log file as it is created. wc -<options> <FileName> - Word Count (wc) program. Counts the number of chars, words, and lines in a file or in a pipe. Options:

-l (lines) -c (chars) -w (words)

To find out how many files there are in a directory do ls | wc -l split -<split> <FileName> - Splits a file into several files.e.g. $ split -5000 CALLS1 # will split file CALLS1 into smaller files of 5000 lines each called xaa, xab, xac, etc. tr <character> <other character> - translates characters. e.g. $ cat handycommands | tr "\t" " " # will take the file handycommands and translate all tabs into spaces. Useful when messing about with awk or you need to convert some input (e.g. that from tty) to a unique filename that does not contain special characters. e.g. $ tty | tr "/" "." # produces for example .dev.pts.7 od <options> <filename> - od converts nasty (binary save) files into character representations. Useful when backcompiling, examining raw .dat files,etc. Use with option '-c' for character display (recommended). script - starts recording everything in the shell to a file by default 'typescript'. Press ^D to finish the script. Provides a log of everything used. Has almost the same effect as $ ksh | tee typescript Used for debugging shells, seeing error messages which flash off the screen too quickly, etc. cut - cut's the file or pipe into various fields. e.g. $ cut -d "|" -f1,2,3 active.unl # will take the file active.unl which is delimited by pipe symbols and print the first 3 fields options:

-d <delimiter> -f <fields>

Not too useful as you can't specify the delimiter as merely white space (defaults to tab) Alternatively, you can 'cut' up files by character positioning (useful with a fixed width file). e.g. $ cut -c8-28 "barcode.txt" # would cut columns 8 to 28 out of the barcode.txt file. paste - paste will join two files together horizontally rather than just tacking one on to the end of the other. e.g. If you had one file with two lines: Name: Employee Number: and another file with the lines: Fred Bloggs E666 then by doing: $ paste file1 file2 > file3 # this would then produce (in file3). Name: Fred Bloggs Employee Number: E666 Note that paste puts horizontal tabs between the files, so you may need a sed 's/ //g' command to get rid of these. sort <filename> - sorts the information from the file and displays the result on standard output (stdout). e.g. $ sort /tmp/list_of_names # will sort the file into alphabetical order, and display it to the screen. Useful with option '-u' to filter out duplicates. uniq <filename> - filters out all duplicate lines from a file or input stream (file or stream must be sorted!). Useful with option -c which merely produces a count of unique lines. ex <filename> - ex is an old line editor, and almost never used now (similar to DOS edlin if you remember that - me, I've repressed it). You are most likely to come across ex within the vi editor - all commands beginning with a colon (:) are ex commands

EXTREMELY USEFUL COMMANDS


ls -l - lists files in a directory in long format. You cannot do without this. Here's a more detailed explanation. Ex:. $ ls -l Part 1 Part 2 Part 3 Part 4 Part 5 Part 6 Part 7 -rw-rw-rw- 1 root staff 28 Jan 16 09:52 README -rw------1 compjmd staff 4304 Jun 24 12:21 tabledict drwxrwxrwx 2 compjmd staff 512 Jul 1 16:30 testdir -rwxrwx--- 1 compjmd system 0 Jul 1 16:30 a.out ... is a sample listing. Part 1: Permissions - see chmod for explanation of these. If the first field is set, then the file in question is not really a file at all, but something else, key: o -: normal file o d: directory o l: symbolic link created by 'ln' o c or b: device of some sort

You may sometimes see an 's' where the 'x' should be in the permissions - this is normally on executable files which change other files. e.g. Permissions of 'sqlexec' the file that executes all informix queries should be '-rwsr-sr-x' - this then accesses tables with permissions of '-rw-rw----'. where the table files are owned by informix (group informix). the 's' flags allows changing of the database tables on a program level, but not on a unix level. (can change contents via sqlexec but not use 'rm' command on db file). Part 2: Number of links to this file (directories always have 2+). Part 3: The owner of the file - e.g. If the owner is 'compjmd' and permissions are set to -rw------- then only the user 'compjmd' may read or write to that file. Again, if owner is "compjmd" and permissions are -r-x------ then only the user compjmd may read or execute that file. Only the owner of a file or root may chmod it. Part 4: The group ownership of the file - (bloody hell, this is getting complicated). On a unix system there are certain 'groups' which users can belong to, held in the file '/etc/group'. You will notice that in this file there will be a main group, e.g. 'staff' which contains every user. Which means that any user listed under staff is in that group.....right...every file has a group attached to it. Which means that if a file had permissions ----rw---- and a group reference of 'system', then only users who were part of the group system could modify that file. To see which groups the current user belongs to do id. Sorry if this wasn't comprehensible but you should never need to use this anyway(!). Part 5: Size of the file in bytes Part 6: Time of last modification Part 7: The name of the file

Useful options (and there are loads more). All may be combined except where specified:

ls -a show files starting with '.' too ls -A show files starting with '.' but not '.' or '..' ls -c must be used with either option l and/or t - displays/sorts by modification ls -d do not show subdirectory listings ls -i display the i-node number of each file ls -t Put the listing in time order (see options u and c) ls -r Put the listing in reverse order - usually used with a -t ls -u must be used with either options l and/or t - displays/sorts by last-access

time

time vi <filename> - love it or loathe it - the standard operating system text-file editor. See Related help file. Vi You can also use 'view' which forces Read only (-R opt). vi +<number> enters the file at the specified line no. Also, vi +/<Search pattern> will enter the file and move to the first occurrence of <Search pattern>. e.g. $ vi +/"love it or loathe it" handycommands Users new to vi hate it. I personally managed to get through University without using it ever (I used Joe's own editor instead). If I accidentally went into vi, I had to ^Z and kill the job. Sigh. Five years of using vi means that I'm getting a little better at it now... (I'm actually typing this now in a vi-clone for Windows). grep <pattern> <file(s)>

- a phenomenally useful command which matches strings within files - e.g. $ grep D7523 mcall_reps.out # will find all the lines in mcall_reps.out that have the string "D7523" in it. Also incredibly useful for things like pipes,e.g. $ du | grep cred # (in /home directory will show all users that have 'cred' in their title). You may use regular expression matching - e.g. $ grep "main.*{" x.c # would match any line containing 'main' and an open curly brackets at any point in the line afterwards. There are two variations to grep - fgrep and egrep which do virtually the same things as grep, but are either faster (having less options) or more complex (but slower). See also section on Wildcards Options:

-v : show all lines that do not contain pattern. -y : don't bother matching case -i : don't bother matching case -c : show count of matching lines rather than the lines themselves -l : show filename's instead of matching lines.

ksh -o vi - The Korn Shell - pros might notice that I don't mention using the C-Shell at all - I've never used it, so that's why it doesn't appear. A Shell is a program that you run your commands in. Typing exit will end the current shell. The -o vi option of the korn shell allows vi commands to work at the shell prompt after pressing escape. For example, pressing escape and then 'k' will bring up the last command used in the shell. awk - this would be a damn useful command if I knew how to use it properly. see alternative page awkhelp man <command> - look at the manual, e.g. $ man ps # will list the manual page for the command ps

GENERAL INFORMATION COMMANDS


smon - monitor's system usage - F5 shows processes which are hogging the machine. Not available on AIX 4.1 and above sadly. uptime - shows how long the system has been up and how hard it is being hammered. The load average fields show how many jobs on average are waiting. <1 or less is very good, around 5 is pretty bad (though not unusual), >10 the machine is being seriously hammered. who - list users who are currently logged on (useful with option 'am i' - i.e. 'who am i' or 'whoami') w - list users and what they are doing, including idle time. The first line is the output from uptime id - similar to whoami except that it does a direct check to see who you are - who only checks /etc/utmp so any su commands will be ignored. ps - list processes currently running, by default on the current shell. Useful with options:

-t <tty> - show all processes running on a terminal -ef - show all processes -u <loginname> - show all processes owned by a user -flp <processid> - show as much information as you can about a process number -aux - show processes in order of usage of the processors. Useful to see what processes are hogging system resources.

fuser -u <filename> - show who is using a file.(system hogging command). Useful when trying to work out who has locked a row or table in an informix database for example. lpstat -p <printer> - show the current status of a printer and any jobs in the queue. lpstat without arguments prints all of them. enable <printer> - enable a printer queue. You must be root or a member of the printq group to run this command. disable <printer> - disable a printer queue. You must be root or a member of the printq group to run this command. enq <various parameters> - examine spool queue for printers. uname -a - will show you what machine you're currently on. ipcs - list semaphores and shared memory. ipcrm -s <semaphorenumber> - remove semaphore or shared memory. crontab - use -l to list all regular scheduled jobs. To alter them, use option -e at <now + ?? seconds/minutes/hours/days/years> - perform a job at a specified time. (Useful for running something at a later date). at retains the current environment. e.g. $ at now + 5 minutes echo "Phone Julie McNally" > /dev/tty616 ^D job compjmd.389748732 will be run at ??? Will echo to tty616 the message "Phone Julie McNally" in 5 minutes. e.g.2 $ at 0331235930 echo "April fools day!" > /dev/console ^D will echo "April fools day!" to the console at 11:59 and 30 seconds, on the 31st of march. Format for this is: [YYYY]MMDDhhmmss. at jobs are sometimes used in the place of crontab's because if the machine is off when the crontab is meant to take place, the job never happens. at jobs automatically start when the machine is switched on if the machine was down at the time. typing at -l will show you all the at jobs you have queued, at -r <atjob> will remove an at job (only the owner or root is allowed to do this). date - show current date and time. This command may also be used to set the system clock (ONLY WHEN EVERYONE IS LOGGED OFF) with a root user id. A date change is never

simple, even when adjusting things by an hour. The safest way to do it is to change the date then reboot the machine because otherwise the crontab daemon may start doing jobs at odd times. I believe there might be a 'go slow/fast' option to set the clock, and the clock will then run 'slower/quicker' until it catches up with the required time. last <username> - shows a list of recent logins. It looks at /var/adm/wtmp so it only shows initial logins, and not whether those users have been su'd to. fileplace -pv <filename> - show the physical (as in disk location) location of a file. Useful for tracing informix files, and perhaps for working out whether defragmentation copying is required.

SYSTEM COMMANDS
kill -<Signal> <process> - sends a signal (normally a kill) to a process. kill -9 terminates the job no questions asked, kill -15 tries to clear up as much as possible - e.g. remove semaphores and such-like. Other signals may be sent as well, see manual and /usr/include/sys/signal.h to see what signals you can send to a process. renice <priority> <process> - make a process not hog the system so much by setting its nice value. smit - system admin program for AIX df - list volume groups + usage. see also lsvg. Usually used with the -k flag so the number of blocks is displayed in 1024-blocks. cu -l <device> - log on to device such as a pad or a modem. See related files /etc/uucp/* and /etc/locks and /etc/services stty sane - Changes terminal settings back to normal. If a tetra module for example crashes your screen so that no keys function except ^C which doesn't even do very much then typing ^Jstty sane^J should cure the problem. To fully cure the problem you also need to type stty tab3 (and stty -ixon if you're feeling a little overzealous) stty - allows you to change terminal settings such as the interrupt key, quit key, etc. e.g. $ stty intr ^A # would change the interrupt key to being control-A $ stty quit ^L #would set the quit key (normally ^\) to control-L. other key changes are:

erase (normally ^H) xon (normally ^Q) xoff (normally ^S) eof (normally ^D)

To really annoy a systems administrator, change interrupt to 't' and quit to '^D' . hehehehehehe lscfg - show all connected devices lsvg - list volume groups (see related file diskhelp) lspv

- list physical disks (and see related file diskhelp) lspv without arguments will produce a list of all the hard-disks used. lspv <hard-disk-name> will produce a list of information about the hard disk. lspv -l <hard-disk-name> will show any logical volumes which are mapped on to that drive. lsdev - list devices. Options:

-C list Configured devices -P list Possible devices

produces different output when you are root. mkdev - make devices. e.g. To make a tty: # Script to add a tty. Options that need amending are: # -l name of tty to be created - e.g '-l tty600' wil create # a tty called 'tty600' # -p RAN name # -w Port number on RAN # -a Attributes (e.g. to set up auto login, etc.) mkdev -c tty -t 'tty' -s 'rs232' -l tty433 -p sa2 -w 2 -a term='wyse50' -a forcedcd='enable' -a login='enable' -a speed='19200' e.g. To create a printer (raw device): mkdev -c printer -t 'osp' -s 'rs232' -p 'sa3' -w '10' -l label2 -a xon='yes' -a dtr='no' -a col=500 It is highly recommended that you make and change devices using smit chdev - change devices. See mkdev cc - c compiler, use with

-o <object> to specify a target instead of a.out -O optimise -w or -W all warning flags.

shutdown - shutdown the system so that it may be switched off. Rather obviously, this may only be run by root. Options:

-f shuts the system down immediately (rather than waiting for a minute) -R reboot the system immediately after halt

oslevel - show the current revision of the operating system.

CONNECTIVITY
exit - end current shell process. If you log in, then type this command, it will return you to login. ^D (control-D) and logout (in some shells) does the same. rlogin

- login to a remote machine, e.g. $ rlogin hollandrs # log in to machine called hollandrs Useful with -l option to specify username - e.g. $ rlogin cityrs -l ismsdev # log in to machine cityrs as user ismsdev For further info about trust network see .rhosts file and /etc/resolv.conf (I think). telnet - very similar to rlogin except that it is more flexible (just type telnet with no arguments and then '?' to see the options). Useful because you can specify a telnet to a different port.

ftp - File Transfer Protocol - a quick and easy method for transferring files between machines. The .netrc file in your $HOME directory holds initial commands. type ftp without arguments and then '?' to see options) rcp - Remote copy. Copies a file from one unix box to another, as long as they trust each other (see .rhosts file or /etc/resolv.conf I think). Options

-f (to force the copy to occur) -r (to recursively copy a directory) -p (to attempt to preserve permissions when copying)

su - <loginname> - switch user, option '-' means that the users .profile is run, without option you merely assume the id and permissions of the user, without (for example) changing PATH and DBPATH, e.g. $ su - root # become root $ su root # gain permissions of root but don't change the current environment variables $ su - vlink # switch to user vlink If you are root, you may su to any other user without being prompted for a password. su without arguments is the same as 'su root'. Note that the 'su' option is not available on all UNIX machines as it can crash some of them. ping <hostname> - check that <hostname> is alive and well (do not expect an immediate response from a machine that is linked over an ISDN line). Firewalls often block ping packets after the Ping of Death so quite often you'll find you can't ping internet sites either. Options include: -q ping quietly -i<no> wait no of seconds between each packet sending. The default is 1 second. If you are using ping to keep an ISDN line up then using something like $ ping -i 5 -q hollandrs is ideal. -f Never use this! Sends as many packets as it possibly can as fast as possible, used for network debugging and is likely to slow networks horribly when used. Known as 'flood' pinging. -c <no> send no of packets before giving up

To check that your machine can ping, try pinging 127.0.0.1 - this acts as a feedback loop, checking the network card's ability to ping. rsh <hostname> <commands>

- remote shell - e.g. $ rsh altos more /tmp/chk # will run the command more the file /tmp/chk on the machine called altos. Useful in pipes for example. rsh on its own will execute a login. Use option '-l' to specify logon name. You can also use rcmd and remsh on other flavours of unix. host <ip address> - lookup the ip address in the /etc/hosts file and give its name

TAPES AND DISKS


Please see this page for more information on disks in AIX dd if=<filename or device> of=<filename or device> bs=<Block Size> conv=sync - direct (and I mean DIRECT) copy, normally to tape. Archaic syntax and very rarely used. flags:

if - input filename or device of - output filename bs - block size conv - ??

e.g. To write a file to tape use $ dd if=/etc/hosts of=/dev/rmt0 bs=1024 conv=sync # write hosts file to tape using dd cpio stands for copy in-out, and is extremely powerful if you can cope with the innumerable flags that you have to use(!) $ cpio -iBcvumd "etc/hosts" </dev/rmt0 # Grab /etc/hosts file from tape $ find /etc -print | cpio -oBcv >/dev/rmt0 # Write the contents of the /etc directory to tape $ find /etc -print | cpio -pdumv /usr2/etcbackup/ # copy directory /etc to /usr2/etcbackup and retain all permissions. meaning of the flags:

i - input o - output B - Block size of 5120 bytes c - read/write header info v - list file names u - unconditional copy - overwrites existing file. m - keep modification dates d - creates directories as needed. t - generate listing of what is on the tape. p - preserve permissions.

tapeutil -f <devicename> <commands> - A program which came with the tape library to control it's working. Called without arguments gives a menu. Is useful for doing things like moving tapes from the slot to the

drive. e.g. $ tapeutil -f /dev/smc0 move -s 10 -d 23 # which moves the tape in slot 10 to the drive (obviously, this will depend on your own individual tape library, may I suggest the manual?). doswrite -a <unix file> <dos file> - copy unixfile to rs6000's floppy disk drive in DOS format. -a option expands certain characters, for certain ascii conversions. dosdir <directory> - show list of files on a dos floppy disk. Useful with option -l (long format). Like dos command 'dir' dosread -a <DOS file> <unix file> - copy dos file in floppy disk drive to unix - if UNIXFILE is omitted, it outputs to the screen. dosdel <DOS file> - delete dos file on floppy disk. dosformat - format dos floppy disk (High Density) tar - Read/Write stuff to archive. tar cvf /dev/rmt0 <filenames> # will write files to tape tar xvf /dev/rmt0 will read files from tape tar tvf /dev/rmt0 will give a listing of what's on the tape. If you're using an archive file then replace /dev/rmt0 in the examples above with the name of the archive file.

SCREEN COMMUNICATION
echo - a command mainly used in shell scripts. Examples: $ echo "Hello" # will print Hello on your screen $ echo "Hello" > /dev/tty616 # will print Hello on someone elses screen (warning - can crash their screen!) $ echo $DESTF10 # will print the value of the environment variable DESTF10 $ echo "\033Fdemo demo" # will echo demo to the status bar at the top of a wyse terminal See also file shellscripts read - will read text from standard input and place it in the variable name specified. See file shellscripts line - waits until the user presses return before carrying on (writes what is typed to standard output). If used in a crontab/at job this instruction is ignored. See file shellscripts talk <user> - set up an interactive communication dialogue box between two users. Looks good but isn't really that useful. write <user> - writes a message to someone elses screen. Try typing 'write root' and then type a message, finishing with control-D. banner <message> - writes <message> in huge letters across your screen! (max: 10 chars per word) wall <message> - send a message to all people on a system. Can only be executed by root (I think). tput <argument>

- tty type independent attribute setting (requires TERM variable and TERMCAP to be set). I only know these few bits:

tput cnorm - turns the screen cursor on tput civis - turns the screen cursor off tput clear - clears the screen tput smso - turns all new text to bold tput rmso - turns all bold text off

tee (-a) <filename> - command used in pipes to take a copy of the standard output. e.g. $ ls | tee /tmp/x # would output ls normally and put a copy in /tmp/x. The option '-a' is used to append rather than replace files.

SOURCE CODE CONTROL SYSTEM (SCCS)


SCCS Overview The source code control system allows versions of a program to be stored in a special file, so that any version may be retrieved. There are a few commands involved (not all of them listed here). All source code files start with 's.' get -r<revision> <source code file> - get a program out of source code to read only. Missing out the -r flag gets the most recent version. e.g. $ get $SCUK/s.parser.c # extracts file parser.c from source code file $SCUK/s.parser.c as read only. See get -e for editing. get -e <source code file> - get a piece of code out for edit, so that the code may be modified and a new version created using 'delta'. e.g. $ get -e $SCUK/s.parser.c # extracts file parser.c from source code file $SCUK/s.parser.c for editing. See get for read-only. delta <source code file> - you must be in the directory with the modified piece of code when you execute this command. This adds the latest version to the source code file. e.g. $ delta $SCUK/s.parser.c # writes file parser.c to the source code file $SCUK/s.parser.c . See get -e for information on how to extract the file from source code. prs <source code file> - show comments/details on source code file. admin -r <revision no> -i <program> <source code file> - create a new source code file with progam. -r specifies the initial revision of the program and may be missed out (default is 1.1 I think). Must be spaced correctly! admin is also used for sccs administration, but it gets to fear and loathing time pretty fast. e.g. admin -iparser.c $SCUK/s.parser.c # creates a new source code file called $SCUK/s.parser.c from the file parser.c unget <source code file> - cancels a get -e

MISCELLANEOUS
strip <binary compiled file> - Removes all linking information within a compiled program - basically a way of cutting down the size of an executable. yes <word> - yes outputs the word 'yes' as fast as its' little legs can go. Never called on it's own. Always used in pipes. For example: $ yes | rm *.o # would confirm 'yes' whenever rm prompts for confirmation. You can also use it to output a different word e.g. $ yes please # would output 'please' to the screen until you kill it (prob. immediately).

SHELL SCRIPT COMMANDS


Are all held on a separate page now. Commands covered are export,if,for, shift, test, while, case, and a few others. sed '<pattern>' - used by myself for quick substitutions when tr doesn't seem to be doing its job properly. The syntax of the pattern is similar to vi ex command line. E.g. To substitute all spaces with colon symbols the command is sed 's/ /:/g' file1 # substitute all occurrences of spaces with colons in file1 and output to stdout. -------------- End of HandyCommands File ------------

You might also like