How do I extend the terminal width or set term variables with ksh? / Not Getting the full command info from ps in Unix terminal ?

To identify processes to kill we need to view the FULL output from the ps command (we use the comm field). But by default we are not able to view full command.  So here is the solution..

Solaris :

/usr/ucb/ps -awux

You may need two “w” options. From ps(1b):

-w Uses a wide output format (132 columns rather than 80). If the option letter is repeated, that is, -ww, uses arbitrarily wide output. This information is used to decide how much of long commands to print.

AIX / Linux :

I have a putty remote session or any terminal session with ksh shell. When I insert a long command I can see ‘<‘ suddenly appear on the line and my command begins to scroll horizontally between prompt and ‘<‘ sign while I keep on writing it.

I want to make it clear: a ‘<‘ sing does not appear at the end of the visible line (ie. limited by putty window) but in the middle of it. Is there a way to change it to higher value? I tried TERM, but did not set it.

Answer: You have to define $COLUMNS after you login or in .kshrc. Similarly, you can also define $LINES.

Open your .kshrc or edit .kshrc, and add

# echo $SHELL
/usr/bin/ksh
# export COLUMNS=1000
# ps -ef

 

Linux / Unix: How do I extend the terminal width or set term variables with ksh? / Not Getting the full command info from ps in Unix terminal ?

To identify processes to kill we need to view the FULL output from the ps command (we use the comm field). But by default we are not able to view full command.  So here is the solution..

Solaris :

/usr/ucb/ps -awux

You may need two “w” options. From ps(1b):

-w Uses a wide output format (132 columns rather than 80). If the option letter is repeated, that is, -ww, uses arbitrarily wide output. This information is used to decide how much of long commands to print.

AIX / Linux :

I have a putty remote session or any terminal session with ksh shell. When I insert a long command I can see ‘<‘ suddenly appear on the line and my command begins to scroll horizontally between prompt and ‘<‘ sign while I keep on writing it.

I want to make it clear: a ‘<‘ sing does not appear at the end of the visible line (ie. limited by putty window) but in the middle of it. Is there a way to change it to higher value? I tried TERM, but did not set it.

Answer: You have to define $COLUMNS after you login or in .kshrc. Similarly, you can also define $LINES.

Open your .kshrc or edit .kshrc, and add

# echo $SHELL
/usr/bin/ksh
# export COLUMNS=1000
# ps -ef

 

HP-UX : ICAP Quick How To

Use icapstatus to display Instant Capacity (iCAP) status and information:

# icapstatus
Software version:          B.08.00
System ID:                 test06
Serial number:             UFR99899X2
Product number:           A6752A
Unique ID:                 Z3e1999999999ffb4
System contact e-mail:  me @ mydomain.ca
From e-mail:               Set to the default ('adm')
Asset reporting:           on
Temporary capacity warning period:  15 days
Exception status:          No exception
Local nPartition Status
-----------------------
Total number of configured cores:                                            8
Number of Intended Active cores:                                             6
Number of active cores:                                                      6
Number of inactive cores:                                                    2
Additional cores that can be activated with current usage rights:           1
Number of cores that could be activated with additional usage rights:    0
Number of cores that can be activated with temporary capacity:            0
Number of cores that are deconfigured or attached to inactive cells:      1
Instant Capacity Resource Summary
---------------------------------
Number of cells without usage rights:                                        0
Number of inactive cells:                                                    0
Amount of memory without usage rights:                                  0.0 GB
Amount of inactive memory:                                              0.0 GB
Number of cores without usage rights:                                        1
Number of inactive cores:                                                    2
Number of cores using temporary capacity:                                  0
Temporary capacity available:                      30 days, 0 hours, 0 minutes
Projected temporary capacity expiration:                                   N/A
Allocation of Instant Capacity Resources among the nPartitions
--------------------------------------------------------------
           Intended Actual
nPar Total Active   Active =======Inactive======= Runs
ID   Cores Cores    Cores  Cores   Memory   Cells iCAP nPar Name
==== ===== ======== ====== ====================== ==== ======================
  0      8      6        6     2     0.0 GB    0  Yes  Partition 0 (local)
N/A      0    N/A      N/A   N/A     0.0 GB    0  N/A  Unassigned Cells


Use icapmodify to activate and deactivate cores.

icapmodify -t -a 1 “Temp use of one core:ASGAUR”

icapmodify -d 1 “Temp use of one core no longer required:ASGAUR”

Note: Replace ASGAUR with your name.

LogicalExtentsNumber is bigger than the maximum value allowed in hp-ux

If you get this error when trying to lvextend a lvol:

lvextend: “LogicalExtentsNumber” is bigger than the maximum value allowed.

It is becuse you have tried to use more than 65,535 logical extents — the limit for a logical volume.

Your only choice is to recreate the *volume group* (‘vgcreate’) and specify a larger extent size (‘-s pe_size’). The default pe_size of four (4) is small for today’s disks and file systems as is (8).

With 8, the maximum size of a lvol is: 8 * 65535 = 524280 MB which is 8 MB shy of 512 GB.

So, if you want a lvol bigger then 512 GB, then the PE size (which can only be set at vgcreate time – can not be changed after the fact) should be 16 or 32.

5 Useful Solaris Unix Administration Cheat Sheets

When I started in UNIX, I really fancy cheat sheets, as they give quick reference to the most useful commands. They are helpful to both new and experienced administrators.

Even the most experienced UNIX system administrators forget their commands, sometimes even the most basic of them. We usually write our commands somewhere, either in a small notebook or a digital copy, easily accessible to us when we needed to execute it.

Below is the list of the most useful Solaris cheat sheets and quick references in the net.

  • Solaris Administrator’s Quick Reference by Jialong He – This has been the most helpful quick reference guide I’ve used so far. It is nicely organized into categories, ranging from user initialization to basic shell programming. Alternative download here.
  • Solaris Quick Sheet by William Favorite – Another good quick sheet. It is based on Solaris 10, having commands on the new Service Management on Sol10. Mirror here.
  • Solaris Cheat Sheet by lyon – This is a unique cheat sheet, created by using FreeMind. It is composed of different images, derived from Sun SA Curriculum. Very helpful in studying for certification exams.
  • Sun OpenBoot PROM Quick Reference Card – A comprehensive reference card into Sun Sparc OpenBoot (most of us relates this as “ok” Prompt). Popularized by Sun, OpenBoot is also used by Apple and IBM. Mirror download here.
  • Solaris 10 Administration Cheat Sheet by me – I based this on Solaris 10, dividing system administration into basic and advance categories. The layout was based on Jialong He’s Quick Reference.

That’s all of the five useful cheat sheet I’ve found across the net.

Special mention of the link below. It isn’t based on Solaris, but most of the commands is Solaris compatible. Kudos to all of the authors of these guides. Thanks!

HP-UX: Preparing for System Reboot / Shutdown

System administrators will often reboot their boxes because of certain need like patch installation and kernel parameter change. Below is a guide to properly shutdown and reboot the system.

THE PRE-WORK

1. Get important system information:

Common Information needed
# hostname
# date
# model
# uname -a
# uptime
# who -r

2. Gather filesystem information

# showmount -e
shows all exported filesystems
# showmount -a
shows all current filesystems exported
login to those systems and unmount all NFS relating to the system to be rebooted
# bdf > bdf.out
Create a list of all mounted filesystem before reboot.
You will compare this later after the reboot
# bdf | wc -l
Take note of the number of mounted filesystem
# bdf -t nfs
Also take note of its NFS mounts.
You need to verify everything is mounted after the reboot.

3. Stop database and applications

Please coordinate the reboot / shutdown to the applications team. Most important applications and database should be stop before reboot or data corruption might happen.

Example of applications/database verification

# ps -ef | grep oracle

Oracle Database
# ps -ef | grep sap
SAP Applications

4. Backup /stand/vmunix and /stand/system. If these files were corrupted during reboot, boot will fail.

# cp -ip /stand/vmunix /stand/vmunix.backup
# cp -ip /stand/system /stand/system.backup

5. Backup fstab and comment out NFS entries. These will prevent long system hangs during reboot.

# cp -p /etc/fstab /etc/fstab.backup
# vi /etc/fstab

(Comment all NFS entries)If not yet shutdown

6. Execute the shutdown command

# shutdown -r -y 0
This command reboots the server. If you want it to halt shutdown -h -y 0
# shutdown -h -y 0
If hardware change it needs halt

After Booting

# cp -p /etc/fstab.backup /etc/fstab
Return the original fstab
# mount -a
Mount all NFS entries

Verify Filesystem

# showmount -a
# bdf | wc -l
# bdf -t nfs

Compare these to the ones perform before reboot.

Check Logs for errors

# more /var/adm/syslog/syslog.log
# dmesg

Finally, if all is well, ask the application team to start their applications and database.

HP-UX: How to extend root – live!

No outage required , if you have online jfs.
If you do not have online jfs , do all the following in LVM maintenance mode.
Note: this will only work if SWAP is NOT the next lvol after /

a. Login as root.
b. Find out a free disk / un mirror the rootvg and make that disk free.
c. find out the next logical volume after lvol3(assumed lvol3 is root)
d. pvmove that logical volume onto the newly added disk
[ pvmove -n /dev/vg00/lvol4 /dev/dsk/CURRENT /dev/dsk/NEW]
e. now you should be able to increase root filesystem to an additional `size_of_the_lvol4`.
f. pvmove the lvol4 back to root vg ( vg00)

boot,swap and root are the only lvols that needs a contegeous policy. so , it does not matter where lvol4 is.

Example, move lvol4 away from lvol3 , thus creating a contegeous space right after lvol3. If you need more space on “/” you will be able to move lvol5 …6 to the next disk and do the stuff. Do remember to migrate them back to the original disk.

Now, if you have mirrored root vg, then break the mirror before you do this.

Practical Example (actual test)

# bdf |grep vg00
/dev/vg00/lvol3     204800  151616   53184   74% /
/dev/vg00/lvol1     125808   49064   64160   43% /stand
/dev/vg00/lvol7    4194304 2501208 1680472   60% /var
/dev/vg00/lvol6    3145728 1856304 1279456   59% /usr
/dev/vg00/lvol5     524288  160992  361104   31% /tmp
/dev/vg00/lvol4    2097152 1833496  261656   88% /opt
/dev/vg00/lvol8    1048576  622656  422632   60% /home
/dev/vg00/lvol10   2097152 1270980  774595   62% /app

Find a spare disk:

strings /etc/lvmtab |grep c7t0d6
pvcreate -f /dev/rdsk/c7t0d6
vgextend /dev/vg00 /dev/dsk/c7t0d6
lvdisplay -v /dev/vg00/lvol4 |more
lvreduce -m 0 /dev/vg00/lvol4
lvdisplay -v /dev/vg00/lvol4 |more
pvmove -n /dev/vg00/lvol4 /dev/dsk/c0t6d0 /dev/dsk/c7t0d6

lvextend -L 1024 /dev/vg00/lvol3
fsadm -b 1024M /

pvmove -n /dev/vg00/lvol4 /dev/dsk/c7t0d6 /dev/dsk/c0t6d0
vgreduce /dev/vg00 /dev/dsk/c7t0d6

lvextend -m 1 /dev/vg00/lvol4

# bdf |grep vg00
/dev/vg00/lvol3    1048576  151640  890456   15% /
/dev/vg00/lvol1     125808   49064   64160   43% /stand
/dev/vg00/lvol7    4194304 2506048 1675672   60% /var
/dev/vg00/lvol6    3145728 1856304 1279456   59% /usr
/dev/vg00/lvol5     524288  160992  361104   31% /tmp
/dev/vg00/lvol4    2097152 1833552  261600   88% /opt
/dev/vg00/lvol8    1048576  622656  422632   60% /home
/dev/vg00/lvol10   2097152 1270980  774595   62% /app

HP-UX LVM – Resizing Filesystem with Online JFS

A quick guide to extend an LVM with a VXFS Filesystem.

1. Verify OnLineJFS is installed
# swlist -l product | grep -i vxfs
# swlist -l product | grep -i online

Look for OnlineJFS or AdvJournalFS

2. It is a good practice to defrag the filesystem first before extending
# fsadm -d – D -e – E /mountpoint

3. Determine the Logical Volume where the filesystem is mounted.
# bdf /mountpoint
Example:

[root@gmhpux02:/root]
# bdf /var/adm/crash
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lv_crash 5357568 2266637 2897770 44% /var/adm/crash

4. Obtain the current size of the Logical Volume (Mbytes)
# lvdisplay /dev/volumegroup/logicalvolume
Example:

[root@gmhpux02:/root]
# lvdisplay /dev/vg00/lv_crash
— Logical volumes —
LV Name /dev/vg00/lv_crash
VG Name /dev/vg00
LV Permission read/write
LV Status available/syncd
Mirror copies 1
Consistency Recovery MWC
Schedule parallel
LV Size (Mbytes) 5232
Current LE 327
Allocated PE 654
Stripes 0
Stripe Size (Kbytes) 0
Bad block on
Allocation strict
IO Timeout (Seconds) default

5. Our current size is 5232 Mbytes. Let us say that we will extend the filesystem by 100 Mbytes. Get the sum of the current size and the size to be added. This will add to 5332 Mbytes. Take note of this.

6. Adjust the size of the Logical Volume.
# lvextend -L new_size_in_mbytes
Example:
[root@gmhpux02:/root]
# lvextend -L 5332 /dev/vg00/lv_crash
Logical volume “/dev/vg00/lv_crash” has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf

7. Adjust the size of the Filesystem
# fsadm -b new_sizem /mountpoint
Example:
[root@gmhpux02:/root]
# fsadm -b 5332m /dev/vg00/rlv_crash
fsadm: /etc/default/fs is used for determining the file system type
UX:vxfs fsadm: INFO: V-3-23585: /dev/vg00/rlv_crash is currently 524288 sectors – size will be increased

8. Verify new size of the filesystem
# bdf /mountpoint