Tuesday, August 30, 2011

burn_cd - command to burn a cd

Command to burn a CD in AIX and Linux:

# burn_cd -d cd0 iso_image_file
Running readcd ...
Capacity: 2236704 Blocks = 4473408 kBytes = 4368 MBytes = 4580 prMB
Sectorsize: 2048 Bytes
burn_cd was successful.

Example:

# burn_cd -d cd0 iso_image_file

Creating large empty files in Linux / UNIX


To create large empty files in Linux or UNIX:
# dd if=/dev/zero of=filename bs=1024 count=desired
Example to create a 1GB file:
dd if=/dev/zero of=file_1GB bs=1024 count=1000
/or/
dd if=/dev/zero of=file_1GB bs=4096 count=250
/or/
dd if=/dev/zero of=file_1GB bs=2048 count=500

Example to create a 2GB file:

dd if=/dev/zero of=file_2GB bs=2048 count=1000
/or/
dd if=/dev/zero of=file_2GB bs=1024 count=2000

Example to create a 512MB file:

dd if=/dev/zero of=file_512MB bs=1024 count=500
/or/
dd if=/dev/zero of=file_1GB bs=512 count=1000


either use

# mkfile size myfile
where can be in KB, MB or GB using k, m or g as suffix. To create a 10 GB file, use

# mkfile 10240m myfile

If you run # mkfile -n 10240m myfile the file will be created, but the disk blocks will not get allocated, only when writing data into the file.

rsync examples from command line.

To copy all the files in /home/lokams/* of remote host to local directory /backup/home/lokams/# rsync -e ssh -avz --delete --exclude dir/* --delete-excluded --stats user@remotehost:/home/lokams/ /backup/home/lokams/

To copy the directory /home/lokams of remote host to local directory /backup/home. Directory "lokams" will get created in /backup/home.# rsync -e ssh -avz --delete --exclude-from=~/.rsync/excludeFile --delete-excluded --stats user@remotehost:/home/lokams /backup/home/

To ignore the permissions errors while copying to remote windows/mac systems, use "-rlt" option.# rsync -e ssh -avz --delete --exclude dir/* --delete-excluded --stats -rlt user@remotehost:/home/lokams/ /backup/home/lokams/

rsync behaves differently if the source directory has a trailing slash. Study and learn the difference between the following two commands before moving on. Use the -n option to rsync when testing to preview what would happen.
$ rsync -n -av /tmp .
$ rsync -n -av /tmp/ .

More rsync examples:
--------------------------


# rsync -crogpvltz -e ssh --exclude "bin" --exclude "ifany" --delete --delete-after --bwlimit 20 root@10.144.17.1:/apps/uae/ /apps/uae > /apps/uae/logs/sync.log

# rsync -avz -e ssh root@remotehost:/backup/reptest /backtmp/reptest/

# rsync -avz -e ssh /logstage/archive/DXBSEC/NODE0000/ db2inst1@10.20.202.236:/db2/archivelog/security/logstage/retrieve/DXBSEC/NODE0000/

# rsync -e ssh -avz --timeout=999 --delete --exclude dir-or-file-to-exclude --delete-excluded --stats -rlt user@remotehost:/home/lokams/

rsync useful options:
-------------------------

-a, --archive archive mode, equivalent to -rlptgoD
-n, --dry-run show what would have been transferred ( Preview mode )

-c - always checksum
-r - recursive into directories
-o - preserve owner
-g - preserve group
-p - preserve permissions
-t - preserve times
-v - verbose
-l - copy symlinks as symlinks
-z - compress file data
-P - show progress during transfer
-q - quite (decrease verbosity)
-e - specify the remote shell
-b - make backup
-R - Use relative path names
-u - skip files that are newer on the receiver

--stats give some file-transfer stats
--timeout=TIME set I/O timeout in seconds

--backup-dir - make backups into this directory
--bwlimit=KBPS - limit I/O bandwidth, KBytes per second
--delete - delete files that don't exist on the sending side
--delete-after - receiver deletes after transferring, not before
--daemon run as an rsync daemon
--address=ADDRESS bind to the specified address
--exclude=PATTERN exclude files matching PATTERN
--exclude-from=FILE exclude patterns listed in FILE
--include=PATTERN don't exclude files matching PATTERN
--include-from=FILE don't exclude patterns listed in FILE
--min-size=SIZE don't transfer any file smaller than SIZE
--max-size=SIZE don't transfer any file larger than SIZE


# --numeric-ids:
Tells rsync to not map user and group id numbers local user and group names
# --delete:
Makes server copy an exact copy of the source by removing any files that have been removed on the remote machine

How to Use Google to Search With in a Single Web Site?

Ever want to use Google to search a single Web site?

You can use Google's site: syntax to restrict your search to a single Web site. Make sure there's no space between site: and your Web site. Follow with a space and then your search terms. You don't need to use the "http://" portion of your URL.

site:google.about.com power search tricks

You could also widen the search to include all the About.com Guide sites:

site:about.com google

This same search can be widened to include all the Web sites within a domain.

site:edu text buyback dates

Google's site: syntax can be mixed with other syntax, such as AND and OR searches.

bosboot - make a disk bootable in IBM AIX

To make a disk bootable on the default boot logical volume on the fixed disk from which the system is booted in IBM AIX:

# bosboot -a

To create a bootable image called /tmp/tape.bootimage for a tape device:

# bosboot -ad /dev/rmt0 -b /tmp/tape.bootimage

To create a boot image file for an Ethernet boot:

# bosboot -ad /dev/ent0 

Example:


bosboot -a

bootlist - how to view/modify the boot list in IBM AIX

To modify the boot list in IBM AIX:

# bootlist -m normal hdisk# hdisk# 

Example:


bootlist -m normal hdisk0 hdisk1

To view the boot list in IBM AIX:

# bootlist -m normal -o 

Example:


bootlist -m normal -o

chdev - how to change the media speed of a network interface in IBM AIX

To change the media speed of a network interface in IBM AIX:

# chdev -l 'ent0' -a media_speed='100_Full_Duplex' '-P'

Possible values for media_speed are:

10_Half_Duplex
10_Full_Duplex
100_Half_Duplex
100_Full_Duplex
Auto_Negotiation

Note: The "-P" flag makes this a permament change. 

Example:


chdev -l 'ent0' -a media_speed='100_Full_Duplex' '-P'

chps - how to change your paging space (swap) in IBM AIX

To change your paging space (swap) in IBM AIX:

# chps [ -s LogicalPartitions | -d LogicalPartitions ] [ -a { y | n } ] PagingSpace

where:

-s : specifies the number of logical partitions to add.

-a : specifies to use a paging space at the next system restart. Valid values are "y" or "n".

-d : specifies the number of logical partitions to subtract.

Example to add 16 logical partitions to paging00:

# chps -s'16' paging00

Example to remove 16 logical partitions to paging00:

# chps -d'16' paging00

Example to add 16 logical partitions to paging00 and make the change effective through reboots:

# chps -s'16' paging00 -a'y' 

Example:


chps -s'16' paging00 -a'y'

chsec - reset the failed login count for a user in IBM AIX

To reset the "unsuccessful_login_count" variable of a user in IBM AIX

# chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s user 

Example:


chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s user

chpv - how to clear the boot record of a physical volume in IBM AIX

To clear the boot record of a physical volume (disk) in IBM AIX:

# chpv -c hdisk# 

Example:


chpv -c hdisk1

chhmc - to change the HMC network configuration or to enable and disable remote command execution

The chhmc command is used to change the HMC network configuration or to enable and disable remote command execution:

chhmc -c [network | ssh] -s [enable | disable | add | modify | remove]
[ -i ethØ | eth1 [ -a ip-address ] [ -nm network-mask ]]
[ -d network-domain-name ] [ -h host-name ]
[ -g gateway ] [ -ns DNS-Server ] [ -ds Domain-suffix ]
[ —help ]

where:
• -c – the type of configuration to modify. Valid values are ssh and network.
• -s – the new state value of the configuration. When the configuration type is ssh, the valid values are enable and disable. When the configuration type is network, the valid values are add, modify, and remove. Add and remove are valid only when specifying -ns or -ds.
• -i – the interface to configure. Valid values are eth0 and eth1. This parameter can be used only with -s modify.
• -a – the new network IP address. This parameter can be used only with the -i parameter.
• -nm – the new network mask. This parameter can be used only with the -i parameter.
• -d – the new network domain name. This parameter can be used only with -s modify.
• -h – the new host name. This parameter can be used only with -s modify.
• -g – the new gateway address. This parameter can be used only with -s modify.
• -ns – the DNS server to add or remove. This parameter can be used only with -s add or -s remove.
• -ds – the domain suffix to add or remove. This parameter can be used only with -s add or -s remove.
• -help – prints a help message.

The following are examples of the usage of this command.

To add and remove another domain suffix search other than mycompany.corp:

[hmcusr@hmcproj hmcusr]$ lshmc -n
Network Configuration:
Host Name: hmcproj
TCP/IP Interface Ø Address: 192.168.2.53
TCP/IP Interface Ø Network Mask: 255.255.255.Ø
Default Gateway: 192.168.2.254
Domain Name: mycompany.com
DNS Server Search Order: 192.168.2.6
Domain Suffix Search Order: mycompany.corp

[hmcusr@hmcproj hmcusr]$ chhmc -c network -s remove -ds mycompany.corp

[hmcusr@hmcproj hmcusr]$ lshmc -n
Network Configuration:
Host Name: hmcproj
TCP/IP Interface Ø Address: 192.168.2.53
TCP/IP Interface Ø Network Mask: 255.255.255.Ø
Default Gateway: 192.168.2.254
Domain Name: mycompany.com
DNS Server Search Order: 192.168.2.6
Domain Suffix Search Order: 

Example:


chhmc

chvg - notify a VG of the increase of a disk in IBM AIX

To examine all the disks in the volume group to see if they have grown in size in IBM AIX version 5.2 and onward :

# chvg -g 

From the man page:

1. The user might be required to execute varyoffvg and then varyonvg on the
volume group for LVM to see the size change on the disks.
2. There is no support for re-sizing while the volume group is activated in
classic or enhanced concurrent mode.
3. There is no support for re-sizing for the rootvg.
Example:

chvg -g datavg1

Commands to find memory utilisation of processes

To find memory usage, try these commands (may vary with version of UNIX):

# svmon -u | more
# svmon -P | more
# ps aux | more
# ipcs -ma | more

Command to find process which uses the most memory in AIX:

# svmon -P -t 1 (aix 4.3.3)
# svmon -Pau 1 (aix 4.3.2)

To find the memory utilisation of a certain proces:

# ps auwww [PID]

PID = process id 

Example:


svmon -u ; svmon -P ; ps aux ; ipcs -ma

fwtmp - how to manipulate connect-time accounting records

fwtmp manipulates connect-time accounting records by reading binary records in wtmp format from standard input, converting them to formatted ASCII records. The ASCII version is useful when it is necessary to edit bad records.

# fwtmp [-ic]

where :

-ic : denotes that input is in ASCII form, and output is to be written in binary form.

Example to convert a binary record in wtmp format to an ASCII record called dummy.file, enter:

# fwtmp < /var/adm/wtmp > dummy.file

Example to convert an ASCII dummy.file to a binary file in wtmp format called /var/adm/wtmp, enter the fwtmp command with the -ic switch:

# fwtmp -ic <> /var/adm/wtmp

Note: Depending on your flavour of Unix, the file may be called wtmpx or wtmp. 

Example:


fwtmp < /var/adm/wtmp > dummy.file

To get a list of all the failed logins in IBM AIX:

To read the file /etc/security/failedlogin, you need to use fwtmp:

# /usr/sbin/acct/fwtmp < /etc/security/failedlogin

To get information for a particular user:

# /usr/sbin/acct/fwtmp < /etc/security/failedlogin | grep username 

Example:


/usr/sbin/acct/fwtmp < /etc/security/failedlogin

genkld - list of shared objects in AIX

The genkld command extracts the list of shared objects currently loaded onto the
system and displays the address, size, and path name for each object on the
list. 

Example:


# genkld

how to change the reserve_policy so that multiple IBM VIO servers can access the same disk

In a p5 environment, for disk redundancy through two VIO servers, the default reserve policy on the disk needs to be changed to "no_reserve". This allows multiple VIO servers to see the disk and provide redundancy to LPARs. Here is the command:

# chdev -l hdisk# -a reserve_policy=no_reserve -P

This requires that the disk be removed from the system and brought back in. This can be accomplished with a reboot, or the following commands:

1. unmount and vary off the VG that the disk is part of.
2. rmdev -l hdisk#
3. mkdev -l hdisk#

NOTE: The "-P" makes the change in the ODM. Without it, the command will not work because it tries to update the disk while it is already configured in the sytem and an error will be reported. That is why the removal and restoration of the disk is required. 

Example:


chdev -l hdisk3 -a reserve_policy=no_reserve -P

how to check if any mksysb resources are allocated for use in IBM AIX

To see if any mksysb resources are allocated for use, the following command can be run:

# lsnim -a mksysb

With a remote hostname of "darkstar" and a mksysb resource with the name "darkstar_mksysb", the output will be similar to this:
# lsnim -a mksysb
darkstar:
mksysb = darkstart_mksysb 

Example:


lsnim -a mksysb

how to clone (make a copy of ) the rootvg in AIX

To clone rootvg in IBM AIX, 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


Example:

# alt_disk_copy -d hdisk1

how to detach a network device and update the ODM in IBM AIX

If "ifconfig" is used to detach a network device, the ODM is NOT updated and when the system is rebooted, the adapter will try and bring up its network interface because that is what the ODM instructs it to do.

To detach a network device and update the ODM, the following command needs to be used:

# chdev -l en0 -a state='detach'

This will detach the network device even across reboots. 

Example:


chdev -l en0 -a state='detach'

how to determine / disable if simultaneous multi-threading (SMT) is enabled in AIX

Your system is capable of SMT if it's a POWER5-based system running AIX 5L Version 5.3.

To determine if it is enabled:

# smtctl 

Example:


smtctl

How to disable simultaneous multi-threading (SMT) in AIX:

Your system is capable of SMT if it's a POWER5-based system running AIX 5L Version 5.3.

To disable smt:

# smtctl -m off [ -w boot | now]

Note: 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. 

Example:


smtctl -m off

how to display the process hierarchy / tree in AIX 5.3

New in AIX 5.3, to display the hierarchy of a process:
# ps -T 1
 PID    TTY  TIME CMD
   1      -  0:00 init
4258      -  0:00    |\--errdemon
4728      -  0:00    |\--hdlm_log_push_process
5458      -  0:00    |\--hdlm_link_proc
6488      -  0:00    |\--aioserver
7300      -  0:02    |\--syncd
8092      -  0:00    |\--httpd
9912      -  0:00    ;|   |\--httpd
13458      -  0:00    ;|   |\--httpd
17580      -  0:00    ;|   |\--httpd
17828      -  0:00    ;|   |\--httpd
20642      -  0:00    ;|    \--httpd
8514      -  0:00    |\--shlap
9496      -  0:00    |\--nfsd
11206      -  0:00    |\--random
12984      -  0:00    |\--rpc.lockd
13220      -  0:00    |\--srcmstr
6904      -  0:00    ;|   |\--portmap
7562      -  0:00    ;|   |\--sendmail
10404      -  0:00    ;|   |\--IBM.LPRMd
Example:

ps -T 1

how to disable a single path through one HBA to a disk in IBM AIX

This disables a single path through one HBA to a disk in IBM AIX. This instructs the system to start using an alternative path to the disk.

# chpath -l hdisk# -p fscsi# -s disable 

Example:


chpath -l hdisk# -p fscsi# -s disable

how to determine which application created the OS core file in AIX

To determine which application created the OS core file in AIX:

# /usr/sbin/lquerypv -h /path/to/core 6b0 64

The output of this command is neat, clean and easy to read. Here is an example:

# lquerypv -h core 6b0 64
000006B0 7FFFFFFF FFFFFFFF 7FFFFFFF FFFFFFFF |................|
000006C0 00000000 000007D0 7FFFFFFF FFFFFFFF |................|
000006D0 00120000 1312C9C0 00000000 00000017 |................|
000006E0 6E657473 63617065 5F616978 34000000 |netscape_aix4...|
000006F0 00000000 00000000 00000000 00000000 |................|
00000700 00000000 00000000 00000000 00000ADB |................|
00000710 00000000 000008BF 00000000 00000A1E |................|

The executable is located between the pipes on the right hand side of the output. In this case, the core was generated by Netscape. 

Example:


/usr/sbin/lquerypv -h /tmp/core 6b0 64

how to determine which eFixes are installed on your VIO Server

To determine which emergency fixes are installed on your Virtual I/O Server (VIOS):

1) Login to the VIO server as the user padmin

2) Setup your environment by issuing:

$ oem_setup_env

3) List installed efixes by label:

# emgr -P

4) To remove a specific efix by label (IY71303 in my example):

# emgr -r -L IY71303

5) Go back to the padmin restricted shell

# exit 

Example:


emgr -P

how to determine which MPIO path is associated to a vscsi adapter in AIX 5L

To determine which MPIO path is associated to a vscsi adapter in AIX 5L:

# lspath -F "name path_id parent connection status"

The output returns something similar to:

hdisk0 0 vscsi0 810000000000 Enabled
hdisk0 1 vscsi1 810000000000 Enabled
hdisk1 0 vscsi0 820000000000 Enabled
hdisk1 1 vscsi1 820000000000 Enabled

The first field is the hdisk.
The second field is the "Path" number (seen with 'lspath')
The third field is the parent (vscsi adapter)
The fourth field is the connection
The fifth field is the status (Enabled, Disabled, Missing, etc) 

Example:


lspath -F "name path_id parent connection status"