quot; *.doc Display lines that end with "IBM". grep -v "^ *quot; testfile > goodfile Remove all blank lines from testfile and save output to goodfile. head Displays the first 10 lines (default) of a file. Example: head -25 /tmp/phase2.out (Displays the first 25 lines of the file /tmp/phase2.out.) id Displays the system identity of the user. Example What it does id Displays the UID and GID of the current user. Example output: uid=0(root) gid=0(system). id -ru Displays only the UID of the current login process (0 for root). last Displays information about previous logins stored in the /usr/adm/wtmp accounting file. Example What it does `last reboot head -5` last roger Shows when user roger logged in and out. last tty0 Displays login and logout times for port tty0. login Initiates a new user session. Example: login -h rs6000 root (Logs into the root account on a machine with the hostname rs6000.) logout Terminates all processes on the current session and logs out the user. Example: logout (Logs you out of the system and returns to the login prompt.) (Note: exit performs the same action as logout.) lsitab Lists the contents of the /etc/inittab file. Example: lsitab -a lslicense Lists the maximum number of users that can log in concurrently. Example: lslicense Output example: Maximum number of concurrent users: >32 kill Sends a signal to stop or suspend a running process. Example: kill -l (Displays a list of valid signals to use with the kill command.) nl Adds line numbers to the beginning of each line in a file. Example: nl /etc/passwd > /tmp/user.list (Creates a numbered output file /tmp/user.list from /etc/passwd.) nice Runs a command at a lower priority. Higher numbers = lower priority. Only the super-user (root) can set a higher priority using negative numbers. Example What it does nice -n 15 make Runs the make command at low priority (15). nice -10 /usr/bin/mview Runs the mview application at high priority (-10). nvdmetoa Converts EBCDIC files to ASCII. Example What it does nvdmetoa <AS400.dat >AIXver3.dat Converts an EBCDIC file from an AS400 system to an ASCII file for AIX. nvdmetoa 132 <AS400.txt >AIXver3.txt Converts an EBCDIC file with 132 characters per line into an ASCII file with 132 bytes per line + 1 byte for linefeed. od Dumps file contents in ASCII, octal, hex, or extended character set. Example: od -c /tmp/rc.net.out (Displays bytes as ASCII characters.) To check function key control codes: od -cd <Press FUNCTION KEY> <Press SHIFT + FUNCTION KEY> <Press ALT + FUNCTION KEY> rmitab Removes an entry from /etc/inittab. Example: rmitab ice (Removes the ice entry from /etc/inittab.) sed Performs stream editing on text files. Example What it does sed -e "s/reports/report/" < /tmp/mytest > /tmp/mytest1 Replaces "reports" with "report" in /tmp/mytest. sed -e 's/ *$//' < SOURCE_FILE > DESTINATION_FILE Removes trailing spaces (not internal spaces) from each line in a file. sed '/total/d' /tmp/report > /tmp/report1 Deletes all lines containing the word "total". sed '/^$/d' /tmp/report > /tmp/report1 Deletes all blank lines from a file. sed 's/[ ]//g' /ibm/report > /tmp/report Removes all tabs from a file. shutdown Shuts down the system. Example What it does shutdown +0 Shuts down the system immediately. shutdown -Fr Shuts down and reboots the system. shutdown -Fm Shuts down into maintenance mode. (Only available from the console.) split Splits a large file into smaller files. Each file will have up to a specified number of lines. New filenames follow this pattern: Kopiëren Bewerken original_filename_xaa, original_filename_xab, original_filename_xac, etc. stopsrc Gracefully stops all System Resource Controller (SRC) subsystems. Example: stopsrc -a strip Removes the symbol table and debugging information from an executable file, reducing its size. Example: strip /usr/bin/uniplex su Runs a sub-shell as another user. Example What it does su roger Switches to user roger, but does not execute their .profile. su - root Fully switches to root, loading /etc/environment, /etc/security/user, and .profile. sum Displays a checksum for a file. Used to verify file integrity after transfers. Example: sum /unix tail Displays the last 10 lines of a file (default). Example: tail /tmp/phase2.out tee Captures output within a pipeline to a file for later review. Example: find . -cpio /dev/fd0 -print | tee /tmp/BACKUP.LOG (A list of backed-up files is stored in /tmp/BACKUP.LOG.) telinit Modifies the system run-level. Example What it does telinit q Forces init to re-read /etc/inittab. telinit 1 Switches to single-user (maintenance) mode (same as init 1). who Displays information about logged-in users. Example What it does who -b Shows the last reboot timestamp. who -r Displays the current run-level. who -u Shows logged-in users with activity timestamps. who -a /usr/adm/wtmp Shows login history. Files that keep growing Periodically, the following files need to be reduced in size. You can use the cat /dev/null command. Example: cat /dev/null >/var/adm/sulog Files: /var/adm/sulog /var/adm/cron/log /var/adm/wtmp /etc/security/failedlogin /var/adm/ras/errlog (use errclear with parameters) System Information ls -b (list garbage file names in octal) lscfg (lists installed devices, -v for versions, or -c) lsgroup (lists user groups) lsuser (lists users) lscons (displays the current console tty value) lsswconfig -a (lists the software catalog) lsdev -C -c <class> -H (lists devices) lsattr -l <class> -a <item> -E (for current attributes) Class values: tty, printer, tape, disk, adapter, dlc, bus, diskette, if, memory, logical_volume, mouse, port Setting 132 Columns for HP Laser Printers If you have trouble setting the column width to 132 columns for text reports, use this fix: If the default column width does not allow a value greater than 77, you need to edit the file containing the parameter limit. Edit the file: /var/spool/lpd/pio/@local/queuename (Replace queuename with the actual queue name.) Search for 77 in the file; there will likely be two entries containing {77}. Change 77 to 132. Volume Commands Definitions: PHYSICAL PARTITION (PP): Smallest unit a PV is divided into (e.g., 4 MB partition size). LOGICAL PARTITION (LP): One or more PPs. Represents a mirrored copy of a PP. Up to two copies of a PP can be mirrored, resulting in an LP count of three (two mirrors plus original). LOGICAL VOLUME (LV): One or more PPs. A file system resides on top of an LV. Only one LV is mapped to a file system. An LV cannot span across a VG. Up to 255 LVs in a VG. VOLUME GROUP (VG): One or more PVs. A collection of PVs that users view as a single oversized PV. A VG can contain any mixture of physical disk types. PHYSICAL VOLUME (PV): One or more LVs. Represents a hard disk (e.g., hdisk0). VGDA (Volume Group Descriptor Area): Stores information about all LVs and PVs in a VG. VGSA (Volume Group Status Area): Stores information about which PPs are stale and which PVs are missing within a VG. Steps to Re-Import VGs After a System Reinstall If the system halts with the message performing Auto varyon of Volume Groups on the console: Press CTRL-C to continue. Log in as root. Export all non-root volume groups: exportvg <VGName> Shut down and reboot the system: shutdown -Fr Re-import non-root volume groups: importvg -y <VGName> <PVName> Steps to Replace a Failing PV in a Non-Root VG Backup all filesystems found on the failing PV: lspv -l <PV> Identify how LVs are allocated on the PV: lslv -m <LV> Unmount all filesystems on that PV: umount <FILESYSTEM_NAME> Remove all LVs found on that PV: rmlv <LV> Remove the failing PV from the system: reducevg <VG> <PV> Remove the PV entry from the ODM database: rmdev -l <PV_NAME> -d Shut down the system: shutdown -F Physically replace the failed PV and install a new PV. Add the new PV to the VG: extendvg <VG> <PV> Recreate the removed LVs using a map file: mklv -y<LV> -m<MAP_FILE> <VG> <PP_NUM> <PV> Resize the filesystems on the new PV: mkfs /dev/<LV> Perform a filesystem check before mounting: fsck -f /dev/<LV> Mount all filesystems on that PV: mount <FILESYSTEM_NAME> Restore the data from your backup. Mirroring a Boot Logical Volume Each hard drive is a potential boot device. The bosboot command creates a bootable image in the BLV (boot logical volume), which is used to boot AIX. Commands: Set normal boot device: bootlist -m normal hdisk0 Set service mode boot devices: bootlist -m service fd0 rmt0 hdisk0 Create a bootable image in BLV: bosboot -u -d /dev/hdisk0 To mirror the BLV: Ensure all copies occupy the same physical partitions on each device. Use lmigratepp to move partitions and keep them synchronized. If mirroring, disable quorum checking: chvg -Qn rootvg If the system crashes, manually synchronize with: syncvg -v <VG> **Files that keep growing** Periodically, the following files need to be reduced in size. You can use the `cat /dev/null` command. **Example:** ``` cat /dev/null >/var/adm/sulog ``` Files: - `/var/adm/sulog` - `/var/adm/cron/log` - `/var/adm/wtmp` - `/etc/security/failedlogin` - `/var/adm/ras/errlog` (use `errclear` with parameters) --- **System Information** - `ls -b` (list garbage file names in octal) - `lscfg` (lists installed devices, `-v` for versions, or `-c`) - `lsgroup` (lists user groups) - `lsuser` (lists users) - `lscons` (displays the current console tty value) - `lsswconfig -a` (lists the software catalog) - `lsdev -C -c <class> -H` (lists devices) - `lsattr -l <class> -a <item> -E` (for current attributes) **Class values:** - tty, printer, tape, disk, adapter, dlc, bus, diskette, if, memory, logical_volume, mouse, port --- **Setting 132 Columns for HP Laser Printers** If you have trouble setting the column width to 132 columns for text reports, use this fix: 1. If the default column width does not allow a value greater than 77, you need to edit the file containing the parameter limit. 2. Edit the file: ``` /var/spool/lpd/pio/@local/queuename ``` _(Replace_ `_queuename_` _with the actual queue name.)_ 3. Search for `77` in the file; there will likely be two entries containing `{77}`. 4. Change `77` to `132`. --- **Volume Commands** **Definitions:** - **PHYSICAL PARTITION (PP):** Smallest unit a PV is divided into (e.g., 4 MB partition size). - **LOGICAL PARTITION (LP):** One or more PPs. Represents a mirrored copy of a PP. Up to two copies of a PP can be mirrored, resulting in an LP count of three (two mirrors plus original). - **LOGICAL VOLUME (LV):** One or more PPs. A file system resides on top of an LV. Only one LV is mapped to a file system. An LV cannot span across a VG. Up to 255 LVs in a VG. - **VOLUME GROUP (VG):** One or more PVs. A collection of PVs that users view as a single oversized PV. A VG can contain any mixture of physical disk types. - **PHYSICAL VOLUME (PV):** One or more LVs. Represents a hard disk (e.g., `hdisk0`). - **VGDA (Volume Group Descriptor Area):** Stores information about all LVs and PVs in a VG. - **VGSA (Volume Group Status Area):** Stores information about which PPs are stale and which PVs are missing within a VG. --- **Steps to Re-Import VGs After a System Reinstall** 1. If the system halts with the message `performing Auto varyon of Volume Groups` on the console: - Press `CTRL-C` to continue. - Log in as `root`. 2. Export all non-root volume groups: ``` exportvg <VGName> ``` 3. Shut down and reboot the system: ``` shutdown -Fr ``` 4. Re-import non-root volume groups: ``` importvg -y <VGName> <PVName> ``` --- **Steps to Replace a Failing PV in a Non-Root VG** 1. Backup all filesystems found on the failing PV: ``` lspv -l <PV> ``` 2. Identify how LVs are allocated on the PV: ``` lslv -m <LV> ``` 3. Unmount all filesystems on that PV: ``` umount <FILESYSTEM_NAME> ``` 4. Remove all LVs found on that PV: ``` rmlv <LV> ``` 5. Remove the failing PV from the system: ``` reducevg <VG> <PV> ``` 6. Remove the PV entry from the ODM database: ``` rmdev -l <PV_NAME> -d ``` 7. Shut down the system: ``` shutdown -F ``` 8. Physically replace the failed PV and install a new PV. 9. Add the new PV to the VG: ``` extendvg <VG> <PV> ``` 10. Recreate the removed LVs using a map file: ``` mklv -y<LV> -m<MAP_FILE> <VG> <PP_NUM> <PV> ``` 11. Resize the filesystems on the new PV: ``` mkfs /dev/<LV> ``` 12. Perform a filesystem check before mounting: ``` fsck -f /dev/<LV> ``` 13. Mount all filesystems on that PV: ``` mount <FILESYSTEM_NAME> ``` 14. Restore the data from your backup. --- **Mirroring a Boot Logical Volume** Each hard drive is a potential boot device. The `bosboot` command creates a bootable image in the BLV (boot logical volume), which is used to boot AIX. **Commands:** - Set normal boot device: ``` bootlist -m normal hdisk0 ``` - Set service mode boot devices: ``` bootlist -m service fd0 rmt0 hdisk0 ``` - Create a bootable image in BLV: ``` bosboot -u -d /dev/hdisk0 ``` To mirror the BLV: 1. Ensure all copies occupy the same physical partitions on each device. 2. Use `lmigratepp` to move partitions and keep them synchronized. 3. If mirroring, disable quorum checking: ``` chvg -Qn rootvg ``` 4. If the system crashes, manually synchronize with: ``` syncvg -v <VG> ``` --- **sysdumpdev** Operations performed on the system dump device: - Turn off the dump device: ``` sysdumpdev -p sysdumpnull ``` - Reactivate the dump device: ``` sysdumpdev -p hd7 ``` - Resynchronize the VG information in the ODM: ``` updatevg rootvg ``` lpstat Displays printer queue status information. First printer listed by lpstat is your default queue. In other words, if no queue name is given when the LP command is executed, then the print job will be submitted to the default printer. If the lpstat command hangs at a client machine, theres a good chance that the lpd daemon is not running on your print server. Execute the startsrc -s qdaemon command to start the lpd daemon. If this daemon fails to start, the lock file /etc/locks/lpd may be preventing this process from successfully starting. Delete this file and rerun startsrc -s qdaemon again. Example What it does lpstat Displays print queue status lpstat -t Displays Print queue status with more detail lpstat -plaser Displays print queue status for the queue laser only lptest Generates the line printer ripple test pattern Example What it does lptest 80 100 | pr -n Prints 100 lines of 80 column test pattern to the default print queue - where each line is prefixed with a line number lsquedev Lists the name of the printer queue attributes stored in the /etc/qconfig file Example What it does lsquedev -q ibm -d dlp0 List the attributes for the queue ibm associated with the device lp0 lsvirprt Displays the attributes for a virtual printer or printer queue Examples What it does lsvirprt -qlaser -dlp0 Lists printer queue attributes and their values. The 'q' (queue) and 'd' (device) flags are required. lsvirprt -qlaser -dlp0 -a _K Lists the condensed print attribute (_K) for the printer queue laser lssrc List the status of a subsystem Examples What it does lssrc -g spooler Display status of all the spooling daemons lssrc -a List status of all subsystems mkquedev Create another print queue to the same output device (multiple queues to one print device) When you submit jobs to these queues remember the qdaemon redirects stdin,stdout, and stderr to the NULL device (/dev/null). If you wish to see any output from your job, you will need to redirect stdout and stderr of that job to a specific file or CRT. Example What it does mkquedev -d ksh1 -q bsh -a backend=/bin/ksh Creates an additional printer queue to the 'bshdev' device named 'ksh1'. pr Paginate a file before printing it via the lp command. Separates files into pages with headers, footer margins and page numbers. It can also produce multicolumn output. Output of this command will default to the screen but is normally redirected to a file or line printer. Example What it does pr -l64 UserGuide.doc | lp Paginates the UserGuide.doc to 64 lines per page and pipes the output to the system default printer. qpri Set the priority of a print job. This command will only work with local print queues. If the job is ranked first in the queue, this command will only work once. If the first ranked job is changed a second time, the priority won't change. Default priority is 15. Use the lpstat -t command to see print queue priority. Examples What it does qpri -#169 -a 4 Lowers the priority of print job 169 to 4 from 15. If there are jobs with higher priority in the same print queue where job 169 resides, they will move ahead. qpri -#169 -a 20 Raises the priority of print job 169 from 15 to 20. If there are jobs with higher priority in the same print queue where job 169 resides, they will move behind job 169. startsrc -s qdaemon This command is used to start the spool daemon named qdaemon. By default, this daemon is started everytime the system reboots. stopsrc -s qdaemon This command Will stop the spool qdaemon. If the qdaemon is not running, all jobs submitted to the spooler will be queued. The job number for these print jobs will be marked 'new'. Once the qdaemon is restarted those queued jobs will be given a job number. Lock Files Occasion you may get a message lpd: lock file or duplicate daemon. This can be caused if there is a problem with the lpd daemon. When this happens Remove the file /etc/locks/lpd. This file should contain the Process ID (PID) for the currently running lpd daemon. Stop and start the print spooler. Backup/Restore Commands Relative vs Absolute Paths When restoring files backed up with the backup, cpio, or tar commands, find out FIRST whether RELATIVE or ABSOLUTE pathnames were used BEFORE the restore is initiated. We recommend using RELATIVE. Relative pathnames will have a ./ pre-fixed to their path. These files will be restored relative to the current directory. Absolute pathnames won't have the ., just the /. These are restored with the full pathname to the exact directory as specified on the archive device. backup Command typically used to backup files on an AIX platform. Distribution tapes for AIX are in this format. This command will span across multiple tapes. Backup by INODE is not recommended because it eliminates the capability to selectively restore files by filename. If you have more data to backup than can fit on one tape, you will probably want to perform INCREMENTAL backups for files that have been modified within the last 24 hours for each day of the work week, followed by making a complete backup of the system on the weekend. The error message Volume on /dev/rfd0 is not in backup format is generated when an attempt is made to extract a file NOT created by the backup command: If your backup was successful, the last item logged by 'backup' is the time the backup finished and the number of 512 byte block that were archived. Example message of a successful backup: Backup finished on Sat Aug 1 15:22:34 CDT 1992; there are 8700 blocks on 1 volumes. Options What it does -i Read standard input -v List names of files being backed up -f Name of output device (typically de/v/rmt0 for tape drive) -e Won't attempt to compress or pack files that are greater than 24 MB. -q Won't prompt user to insert tape -p Pack data. Backup images by default are NOT packed. If you wish to pack your data, use this option. The restore command has enough intelligence to determine if a backup image is packed or not and take appropriate action Examples What it does find /u -print | backup -ivf/dev/rmt0 Backup the file system /u to tape device using ABSOLUTE pathnames. find . -print | backup -iepqvf/dev/rmt0 | tee /tmp/BACKUP.LOG Backup files and directories under current directory (.) using RELATIVE pathnames. The tee (|) will take as input the output of the backup command (filenames being copied) and write them to the log file 'BACKUP.LOG' for later review. find /faxdata -mtime -1 -type f -print | backup -ivf/dev/rmt0.1 Find any REGULAR files (-type f) that have been modified within the past 24 hours (-mtime -1) and write them to the tape device but don't rewind (/dev/rmt*.1) the tape after backup has finished. backup -ivqf/dev/fd0 Backup files interactively. Select the file(s) to backup by typing in the file's name. When done, press ^D to finish. find / -print|backup -icvqf/dev/rmt0-1 If there is more than one tape drive attached to the system, then you can specify a range of devices to the -f flag of the backup command. (/dev/rmt0-1) compress, uncompress, pack, unpack, zcat Utilities to compress or expand data. The compress command reduces the size of the named file(s) and renames it with a .Z extension. Compressed files can be restored to their original form using the uncompress command. This utility appears to have a more EFFICENT packing scheme than the PACK/UNPACK commands. Examples What it does compress -v /tmp/junk File /tmp/junk is compressed and gets renamed to /tmp/junk.Z. -v displays the percentage of file shrinkage uncompress /tmp/junk.Z Restores file to original file type and file size and changes the name to /tmp/junk. 1)find . -print | backup -ivqpf /tmp/roger.bck 1) compress /tmp/roger.bck 2) find /tmp/roger.bck.Z -print | backup -ivqf/dev/fd0 The 3 commands will backup the current directory and compress that backup image to a floppy diskette. 3) restore -xvf/dev/fd0 4) uncompress < /tmp/roger.Z | restore -xvf- Restore the files archived from a floppy diskette. (In this example assume restored file=roger.Z) Uncompress the compressed image and restore this file back to the file system zcat /tmp/junk.Z > /tmp/junk1 Uncompresses /tmp/junk.Z into /tmp/junk1 find /u/COMPANY -print | xargs pack -f Packs all the files under the specified directory (/u/COMPANY) find /u/COMPANY -print | xargs unpack Unpacks all the files under the specified directory (u/COMPANY) cpio Copies files to/from an archive storage device. This command is often used to copy files from UNIX to AIX systems. This command will span across multiple tapes. cpio stands for CoPy Input to Output. Options What it does -c Writes header information in ascii format for portability across UNIX systems. The message Out of phase--get help is generated when an attempt is made to extract a file not in cpio format OR if the archive tape was written with the -c option. The cpio command doesn't have this option specified when attemping to extract files from the media (eg., cpio -icdumpv < /dev/rmt0) -r When restoring will prompt for new path/file to restore to -v List the file name as it's being copied -i Read from standard input, i.e. keyboard -u Copies unconditionally. Older file replaces a newer one. Files with older modification times will replace files with newer modification times. -d Creates directories, if applicable -t For table of contents -C1 Performs block I/O in 512 byte blocks, if the block size of the device that wrote the data on the tape was set to 512 bytes. Make sure you read with the same block size. If the block size that the data was written to and about to be read from are two different sizes, this message will be displayed: Cannot read from the specified device Examples What it does 5) cd /u/roger 6) find . -print | cpio -ocv > /dev/fd0 Reads file names using the find command and copies to the floppy drive (/dev/fd0). find . -cpio /dev/fd0 -print Saves files in current directory and writes this info to floppy. Same command as above except much faster. 7) cd /u/roger 8) cpio -icuvd < /dev/fd0 Restore files and directories saved on the floppy device. These files are restored under the current directory (/u/roger) Only if relative pathnames (./<filename>) were used. cpio -itvcC1 < /dev/rmt0 List the table of contents from a tape device. 9) cd /u/roger 10) find . -print | cpio -dumpv /u/jerry Copies all files FROM one directory TO another WITHOUT changing the permissions, owner/group or modification date of the file. Use the following command to verify that all files were copied: find /u/roger -print | wcfind /u/jerry -print | wc If the number of files encountered is the same for both directories its safe to assume that the directories are identical. NOTE: that the number of blocks allocated to the SOURCE directory (/u/roger) may be larger than the DESTINATION directory (/u/jerry), since compaction of the directory structure will have occurred at the destination end. cpio -imv /home/roger/.profile < /dev/fd0 Selectively restore the /home/roger/.profile file from floppy cpio -i "*.f" "*.c" </dev/fd0 Selectively restore only the *.f and *.c files from floppy dd Converts/copies files to/from an output device. DD stands for Data Dump. This command will NOT span across multiple tapes. Common utility found on most versions of UNIX. Examples What it does dd if=/dev/rmt0 bs=512k | cpio -icdmv Reads the files off the tape device faster because of the blocking factor (bs=blocksize of 512K or cache upto 1/2 MB at a time) dd if=rs6000.data of=/dev/rmt0.4 bs=1024 conv=ebcdic Copies the data from the input file (if=rs6000.dat) to the output tape device (/dev/rmt0). The rmt*.4 device extension means output is written in 1600 bpi format. This creates an EBCDIC low density tape, resulting in a 1024 byte blocked non-labeled file. To extract this file on the AS/400, create a physical file with a record length of 1024 bytes. Use the CPYFRMTAP command to copy the file. NOTE: When copying data from an EBCDIC machine, make sure your BLOCK SIZE is set to 0 on the tape device dd if=unixfile.txt of=DOSFILE.TXT conv=ucase Copies the data from the input file (if=unixfile.txt) to output name (of=DOSFILE.TXT) and converts the source data to UPPERCASE characters. tar -cvf- /u/roger | dd of=/dev/rmt0 bs=1024k Copies the ABSOLUTE path /u/roger using the tar utility. To speed this process up, these files are piped to the dd utility using a cache buffer size of 1 MB. dd if=/dev/rhdisk0 of=/dev/rhdisk1 bs=5120b Copies the raw physical volume named hdisk0 to the raw physical volume named hdisk1. This represents a copy disk utility. dd if=/dev/rmt0 of=/tmp/ascii_file conv=swab Copies the data from the tape device (if=/dev/rmt0) and creates an output file (/tmp/ascii_file) - which is BYTE swapped (conv=swab) as it is being written out. This needs to be done if your copying ascii files from a System V Unix machine (unisys to the RS/6000) dd if=/dev/rmt0.1 of=/tmp/data1 cbs=242 ibs=3240 conv=sync,unblock Useful when reading an ASCII file that is NOT delimited by a NL character. dd if=/dev/rmt0.1 of=/tmp/data1 cbs=147 ibs=2940 conv=ascii Will read a record size of 147 bytes, a block size of 2940 bytes, and convert the output to an ASCII file. mksysb High-level shell command for backing up mounted file systems in the rootvg volume group. mkszfile -f must be called prior to mksysb in order to create the /.fs.size file that mksysb uses to determine which files will be backed up. 8MM TAPE DEVICE An 8mm tape drive is the preferred method of backing up your system because that tape can be used to recreate the rootvg image if one or more physical volumes fail. Each of the file systems MUST have at least 500 blocks free when the mksysb backup is made. The system will need some work space in each file system when it is installing from a mksysb backup. To utilize the full 2.3 gb tape capacity... Set the blocksize to 1024 Edit the /usr/lpp/bosinst/diskette/startup2 file Change the following line from 512 to 1024. /etc/methods/chggen -a rmt0 -a block_size=1024 Create a new install/maint diskette MKSYSB can create a BOOTABLE tape. Further, the data is archived in TAR format. In order to look at the names of files backed up by this command, perform the following: tctl -f/dev/rmt1.1 fsf 3 tar -tvf/devrmt1.1 Example: mkszfile -f && mksysb /dev/rmt0 -f forces extending the /usr or /tmp file system if not enough working space (8 MB) exists. This command should ALWAYS succeed unless a tape has not been inserted into the archive device (eg., rmt0), or the tape is either write-protected or has defective media. restore Retrieve information from archive device created with the backup command. Default device is /dev/fd0. This command will read a backup image spread across multiple tapes. Examples What it does restore -Tvf/dev/rmt0 -T=table of contents, -v=list the file name being copied, -f=name of output device. Will list the tape's table of contents. If you forget to label the tape with the date that the tape was made, use this command to report back the date this archive was created. restore -xvf/dev/rmt0 ./usr/tmp/My* Restores all files that start with "My" from the /usr/tmp directory restore -xdvf/dev/rmt0 ./usr/tmp Restores the directory named /usr/tmp from tape device restore -xvf/dev/rmt0 Restores all the files located on the tape device that were backed up using the backup command. restore -xvf/dev/rmt0 ./tmp/TestFile -x=extract data from output device. Restores only the file named ./tmp/TestFile from the tape device. If the subdirectory /tmp doesn't exist in the current directory, then that subdirectory will be made prior to restoring 'TestFile'. 11) tctl -f/dev/rmt0 rewind 12) restore -s1 -Tvf/dev/rmt0.1 13) restore -s1 -Tvf/dev/rmt0.1 14. Rewind to the beginning of tape. 2. Review files on FIRST backup image. 3. Review files on SECOND backup image) Displays the table of contents for multiple backup images. s1=specifies that multiple backups are on the tape and that the restore command skips to the backup specified by the number associated with the 's' option. The 0.1 for the output device (-f flag) means that once the tape has been read, it will not rewind. If only the second backup image was needed, could have just typed in: restore -s2 -Tvf/dev/rmt0.1 15) tctl -f/dev/rmt0.1 fsf 3 16) restore -xvqf/dev/rmt0.1 ./unix If by chance the ./unix file was deleted, go back to your install tape and extract the file that needs to be restored. The first three images on the tape are BOSBOOT, INSTALL/MAINT, followed by the TOC (table of contents) image. restbyname -xvqf/dev/fd0 -Z /tmp/DISK.LIST Selectively restore ONLY those files listed in file /tmp/DISK.LIS tapechk Performs consistency checks on a tape device. Primarily used to check tapes written in backup format. Example: tapechk 2 ( Checks the first 2 files found on the tape device.) tar Probably the easiest command to use when transferring files from one UNIX system to another. This command will NOT span across multiple tapes. Tar stands for Tape ARchiver. When using this command while performing a SELECTIVE restore from a tape device (eg;., tar -xvf/dev/rmt0 ./etc/motd), the tar command will continue to run until the end of tape is encountered, even after the file has been found. The error message tar: directory checksum error (0 != 12345) Tar is an older utility than cpio or backup/restore is generated when an attempt is made to extract a file that is NOT in tar format. Options What it does -c Writes (creates) files (appends to archive device) -x Extract (read) files from archive device -v Verbose mode (displays names) -f Device name to use Examples What it does tar -cvf- * | dd of=/dev/rmt0 bs=128k Copies all the files and subdirectories from the current directory and pipes the output to the dd command for faster archiving. dd if=/dev/rmt0 bs=128k | tar -xvf- Use the dd command to read the tape device for faster archiving and pipe the output to the tar command to restore the archived files. tar -tvf/dev/rmt0 List the table of contents of the tape device. tar -cvf/dev/rmt0 /u/jones Copies the jones account to the archive device named /dev/rmt0. tar -xvf/dev/rmt0 tmp/newdata /tmp/olddata Selectively copies ONLY the newdata and olddata directories from the tape to the current directory. tar -cvf- * | xargs compress -v > /tmp/tar.Z Copies all the files from the current directory and compresses them into the file named tar.Z. tcopy Copies from one magnetic tape device to another. This command will work for copying multiple backup images from one media type to another. It will continue to copy until two end-of-tape marks are encountered. Examples What it does tcopy /dev/rmt0 Displays ALL the backup images and their size for the tape your currently viewing. tcopy /dev/rmt0 /dev/rmt1 Copies all the data from one media type to another until two end of tape marks are encountered. In the example above, rmt0 could be a 8mm device and rmt1 may be a 1/4" tape device. If the error message: tcopy: Cannot open /dev/rmt?' is displayed, make sure the destination device is not write-protected. tctl Command used to fast forward a tape device (Tape ConTroL). Examples What it does tctl -f/dev/rmt0 rewind Rewind the tape device. tctl -f/dev/rmt0.1 fsf Move tape forward to the second tape mark. The .1 on the rmt0 device instructs the device NOT to rewind after performing the command. Use this command to skip past unwanted tape images - assumming there are multiple archive images on the tape to skip past. tctl -f/dev/rmt0 retension Moves the tape to the beginning, end, and back to the beginning again. Used to retension the tape when encountering multiple read errors on restore operations. Backup files from a remote computer The local host MUST be included in remote's hosts /etc/hosts.equiv file. The local host and user name MUST be included in the $HOME/.rhosts file at the user account at the remote machine. Examples What it does rsh lanai -l roger "dd if=/dev/rmt0" | tar -xvf- Restores files FROM a remote tape drive on a host named 'lanai' tar -cvf- * | rsh lanai -l roger "dd of=/dev/rmt0 bs=64k conv=block" The tar command will write it's output to the rsh command which pipes the data to the remote host (lanai) and the tape drive (/dev/rmt0). Specify -l <UserName> if the local user is different from the remote user. tar -cvf- * | rexec lanai " dd of=/dev/fd0 bs=4096" Uses the floppy drive device on node lanai to store files in tar format. Commando’s Unix man = manual (opvragen handleiding bij een commando) df –sk = opvragen van de vrije ruimte van de hd realdir = het absolute pad du –sk = opvragen grote van een specifieke dir die je opgeeft mkdir = aanmaken directory rmdir = verwijderen directory rm –r [directorynaam] = verwijderden directory tar –tvf /dev/rmt0 –N 800 = geeft uitvoer van bestanden op tape tar –cvf /dev/rmt0 –N 800 [bestandsnaam] = bestanden op tape zette tar –xvpf /dev/rmt0 –N 800 [bestandsnaam] = bestanden terug laden van tape mt –f /dev/rmt0 rewind = terugspoelen van de tape mt –f /devrmt0.1 fsf 1 = het zetten van de juiste file system van de tape lscfg –vl rmt0 = gegevens van de tape unit opvragen lpstat –a [queuenaam] = status van de queue lsallq / lsallq |grep [queuenaam] = opvragen van alle queue op het systeem enable [queuenaam] = queue vrijgeven disable [queuenaam] = queue down brengen cancel [queuenaam] = verwijderen van de taken in de queue cancel [taaknummer] [queuenaam] = verwijderen van 1 of meerdere specifieke taken su – [username] = simulate user find (find . –name [bestandsnaam] –print) = zoeken van bestanden errpt = error report van server errpt –a = gespecificeerde error report crontab –l = lijst crontab –e = vi mode Acs herstarten op de p omgeving: psef acs | awk '{print$2}' | grep -v PID | xargs kill -9;/p/cqcs/acs p/prog/system/acs.cfg;psef acs Alle filesystem aktiviteiten monitoren door te tracen met output naar /tmp/filemon.log: filemon -o /tmp/filemon.log -O all: Aantal in *Project ingelogte gebruikers: ps -ef|grep -v "0:00"|grep -v tved|grep –v PID|grep csrun|wc -l Aantal processoren: lscfg -vp |grep proc |wc -l Actieve csruns op AIX: ps -ef|grep -v "0:00"| grep –v PID|grep csrun|sort -k 7|pg’ Actieve csruns op AIX maar dan de 10 drukste: ps -ef|grep -v "0:00"| grep –v PID|grep csrun|sort -k 7|pg’ | tail -10 AIXDump tape uitlezen: restore -s4 -qTvf /dev/rmt0.1 Alle extenties van files in een map weghalen bijv. .txt: ls |grep txt | sed 's/\(.*\).txt$/mv "&" "\1"/'|sh Alle processen van 1 gebruiker killen: ps -u [user-id] -o pid | grep -v PID | xargs kill -9 Alle processen van alle gebruikers killen behalve de taakverwerkers: psef csrun | grep -v root | grep -v PID | grep -v tved | awk '{print$2}' | xargs kill -9 Asynchrone i/o setting voor AIX: /usr/sbin/lsattr -El aio0 Attributes weergeven van een virtuele printer: lsvirpt -qqueue -ddevice -s__HTP Bestanden zoeken zonder owner of group: find / -fstype jfs \( -nouser -o -nogroup \) -ls Check of NFS aktief is: lssrc -a | egrep nfs Check welke Spoolers aktief zijn: lssrc -g spooler Cpu snelheid op AIX 5.2: prtconf –s Crontab Job om de 15 minuten van 7 tot 18u zonder output: 0,15,30,45 7,8,9,10,11,12,13,14,15,16,17,18 * * 1,2,3,4,5 shit hier 1>/dev/null 2>/dev/null Data van een dir inpakken: tar -cvf- * | xargs compress -v > naam.Z Datum laatste tapeclean: /usr/lpp/diagnostics/bin/utape Defuncts vinden en automatisch killen: ps -aekl | grep defunct | awk '{print $5}' | xargs kill -9 Disks boven 80% gebruik: df -k | perl -lne 'print if (split)[3] > 80' | awk '{print $4,"\t",$7}’ Extenties wijzigen van .txt naar .doc bij meerdere bestanden tegelijk: ls -1 | grep '\.txt