Friday, September 30, 2016

UID range in hpux

UID is user identification number in kernel. UID distribution on HPUX system is as below : 0 : root user 1 to 100 : System accounts ... thumbnail 1 summary

UID is user identification number in kernel.

UID distribution on HPUX system is as below :


  • 0 : root user
  • 1 to 100 : System accounts
  • 101 to 60,000 : Normal users
  • Above 60,000 also you can create user but he/she wont be able to access any of system resources.



HPUX boot process

Its not fully detailed boot process. Its very short form of things happens during boot. To make it understand and remember (for interviews) ... thumbnail 1 summary
Its not fully detailed boot process. Its very short form of things happens during boot. To make it understand and remember (for interviews) easily!

1) PDC (processor dependent code) gets executed

  • Checks CPU
  • Checks stable storage for boot path
  • Loads ISL utilities from leaf area of boot disk
  • Here you can halt boot using ESC key and can run PO, SEA commands.

2) ISL (Initial system loader) gets loaded

  • Read AUTO file default kernel
  • Load and runs HPUX from LIF area
  • Here you can halt boot process and boot system into single user mode. U can provide diff options to SSL i.e. kernal vmunix. Like hpux –is, hpux –lq, hpux –lm

3) HPUX loads (Secondary system loader)

  • Uses options and path names from ISL to load kernel
  • And by default loads vmunix

4) After kernel vmunix gets loaded –

  • Swapper daemon starts with PID 0
  • Kernel runs /sbin/pre_init_rc
  • Kernel calls /sbin/init
  • /sbin/init reads /etc/inittab and calls –


  1. /sbin/ioinit – to scan hardware and build kernel io tree
  2. /sbin/bcheckrc – to check FS listed in /etc/fstab
  3. /sbin/rc – to start additional services like lp, cron, cde
  4. /usr/sbin/getty – to start n show login prompt to user.

Thursday, September 29, 2016

Run levels in HPUX at a glance

Current run level in HPUX can be identified using below command : # who -r    .       run-level 3  Jan 19 21:14    3    0    S The out... thumbnail 1 summary
Current run level in HPUX can be identified using below command :


# who -r
   .       run-level 3  Jan 19 21:14    3    0    S


The output fields are :
1. A dot (.) indicates that the terminal has seen activity in the last minute and is therefore          ``current''.
2. Current run level
3. Timestamp
4. Current state of init
5. The number of times that state has been previously entered
6. The previous state

List of run levels in HPUX

0 indicates shutdown state
S indicates single user mode booted to local console only with root FC (RO) mounted
s indicates same as S only current terminal acts as system console.
1 indicates single user mode with local FS (RW) mounted
2 indicates multi user state with CDE launched
3 indicates same as 2 but with NFS
4 indicates GUI (here VUE started instead of CDE)
5,6 indicates reserved state and not yet defined in kernel code.



Wednesday, September 28, 2016

How to restart NFS in HPUX

Requirement : To restart NFS server in HPUX How to do it : Please make a note that all exported NFS mount points will be unavailable t... thumbnail 1 summary
Requirement :

To restart NFS server in HPUX

How to do it :

Please make a note that all exported NFS mount points will be unavailable to all clients during this restart.

Image source : freeimages.com

Stop NFS

# /sbin/init.d/nfs.server stop
# /sbin/init.d/nfs.client stop
# /sbin/init.d/nfs.core stop

Start NFS

# /sbin/init.d/nfs.core start
# /sbin/init.d/nfs.client start
# /sbin/init.d/nfs.server start

Make sure you follow the sequence while stopping and starting as mentioned above.

Tuesday, September 27, 2016

bdf command formatted output in hpux

Requirement : bdf command output normally looks scattered especially when VG names are long. It will be difficult to grep out proper patt... thumbnail 1 summary
Requirement :

bdf command output normally looks scattered especially when VG names are long. It will be difficult to grep out proper pattern out of such output. Also, its not convenient to share this output over email/document when extra lines breaks exists.
In such scenarios, we need to have proper formatted output of bdf. Also sometimes we require output with all its column left aligned.


Solution :

To remove line breaks from bdf output and get single row per entry output

See below normal bdf output. Note that last 2 mount points has two line entry since filesystem column has long entry.


# bdf

Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3    2097152  737416 1349304   35% /
/dev/vg00/lvol1    1048576  206160  835928   20% /stand
/dev/vg00/lvol8    8388608 5475640 2902568   65% /var
/dev/vg00/lvol7    8388608 4655256 3713000   56% /usr
/dev/vg00/lvol4    2097152 1052368 1036888   50% /tmp
/dev/vg00/lvol6    8388608 6675168 1700112   80% /opt
/dev/vg00/lvol5     524288   49360  471256    9% /home
testserver01:/data
                   50574008 4541896 43463104    9% /data
/dev/vgdata/lvol1
                   918421504 591931608 306084338   66% /datastore


Now with inline awk we format the output to have one entry per row. Check below command output.


# bdf | awk '{if (NF==1) {line=$0;getline;sub(" *"," ");print line$0} else {print}}'

Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3    2097152  737408 1349312   35% /
/dev/vg00/lvol1    1048576  206160  835928   20% /stand
/dev/vg00/lvol8    8388608 5475640 2902568   65% /var
/dev/vg00/lvol7    8388608 4655256 3713000   56% /usr
/dev/vg00/lvol4    2097152 1052368 1036880   50% /tmp
/dev/vg00/lvol6    8388608 6675168 1700112   80% /opt
/dev/vg00/lvol5     524288   49360  471256    9% /home
testserver01:/data 50574008 4541896 43463104    9% /data
/dev/vgdata/lvol1 918421504 591931608 306084338   66% /datastore


To get left aligned bdf output

In above output, columns are not aligned properly. We can even do that with below argument.


# bdf | awk '/\//{printf("%-30s%-10s%-10s%-10s%-5s%-10s\n",$1,$2,$3,$4,$5,$6)}'

/dev/vg00/lvol3               2097152   737408    1349312   35%  /
/dev/vg00/lvol1               1048576   206160    835928    20%  /stand
/dev/vg00/lvol8               8388608   5472792   2905392   65%  /var
/dev/vg00/lvol7               8388608   4655256   3713000   56%  /usr
/dev/vg00/lvol4               2097152   1052368   1036888   50%  /tmp
/dev/vg00/lvol6               8388608   6675168   1700112   80%  /opt
/dev/vg00/lvol5               524288    49360     471256    9%   /home


Please make a note that this awk wont remove any line breaks from output. So one can combine (with pipe |) both awk to get left aligned output with line breaks removed.

Left aligned output with line breaks removed!


# bdf | awk '{if (NF==1) {line=$0;getline;sub(" *"," ");print line$0} else {print}}' |awk '/\//{printf("%-30s%-10s%-10s%-10s%-5s%-10s\n",$1,$2,$3,$4,$5,$6)}'
/dev/vg00/lvol3               2097152   737408    1349312   35%  /
/dev/vg00/lvol1               1048576   206160    835928    20%  /stand
/dev/vg00/lvol8               8388608   5481008   2897240   65%  /var
/dev/vg00/lvol7               8388608   4655256   3713000   56%  /usr
/dev/vg00/lvol4               2097152   1052368   1036888   50%  /tmp
/dev/vg00/lvol6               8388608   6675168   1700112   80%  /opt
/dev/vg00/lvol5               524288    49360     471256    9%   /home
testserver01:/data            50574008  4541896   43463104  9%   /data
/dev/vgdata/lvol1             918421504 591931608 306084338 66%  /datastore

 



Monday, September 26, 2016

How to change sender's email id in EMS HPUX

Requirement : Normally in Event monitoring system on HPUX send an emails with sender id as root@ hostnam e. Many organizations email serve... thumbnail 1 summary
Requirement :

Normally in Event monitoring system on HPUX send an emails with sender id as root@hostname. Many organizations email servers dont allow such email address in sender field. We need generic email id in sender field when EMS shoots an alert email something like notification@xyz.com

Workaround :

There is no provision to change this email id anywhere in HPUX or EMS configurations. You can use below workaround which works perfectly without any issues.

Step 1 :
Make sure you have valid email address (like notification@xyz.com) for your logged in account which works. Send a test email from server to verify using below command


# echo test | sendmail -v receiver_id@xyz.com


Image source : freeimages.com

Step 2 :
Setup crontab for above logged in account (for which email tested) which will execute EMS log scanner script every 30 minutes. As per your convenience you can even schedule it to run every 10 mins or even lower.


00,30 * * * * /scripts/ems_monitor.sh



Step 3:
Script code is as below.


# Script to scan EMS log file and email alert if any
# Author : Shrikant Lavhate
#! /bin/bash
if [ -f "/logs/event_monitor.log" ]
then
:
else
cp -p /var/opt/resmon/log/event.log /logs/event_monitor.log
fi
diff /logs/event_monitor.log /var/opt/resmon/log/event.log > /logs/logfile_difference
if [ -s "/logs/logfile_difference" ]
then
cat /logs/logfile_difference | grep  '^>'|cut -c 2-  | mailx -s "EMS monitor alert from `hostname`" receiver_id@xyz.com
fi
cp -p /var/opt/resmon/log/event.log /logs/event_monitor.log


Step 4:
Now you can test the script by generating test events in EMS. Generate test event with send_test_event command. You will receive test events from admin@hostname email id which is normal. Now run above script and you will receive same email with sender id as notification@xyz.com !!


Friday, September 23, 2016

How to generate CSR file for SSL request on Linux

CSR is Certificate Signing Request file. It will be generated on server on which the SSL certificate will be used. This file contains detai... thumbnail 1 summary
CSR is Certificate Signing Request file. It will be generated on server on which the SSL certificate will be used. This file contains details about organization and URL in encrypted format. Whenever you approach any vendor for getting SSL certificate for your webserver, you have to submit this CSR file to them. Based on information in this CSR file your certificate will be generated. 

Steps :

1. Login to server on which certificate will be used.

Image source : freeimages
2. Run below command to generate 2048 bit key file with name myfile.key. This key file will be used for generation of CSR. This command will ask you for a password which will be assigned within key file. Use password of your choice. This password you need to supply while generating CSR.


# openssl genrsa -des3 -out myfile.key 2048


3. Now genrate CSR file using the key file we generated in above step.


# openssl req -new -key myfile.key -out myfile.csr -sha256


Note that sha256 will generate CSR with SHA2 algorithm which is preferred normally. If -sha256 argument is not given, CSR will be generated with SHA1 which is outdated and normally not preferred.

4. Command will ask you key file password along with below information.



Country Name (2 letter code) [GB]:
State or Province Name (full name) [Berkshire]:
Locality Name (eg, city) [Newbury]:
Organization Name (eg, company) [My Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:
Please enter the following 'extra' attributes to be sent with your certificate request
A challenge password []:
An optional company name []:


5. Once you get CSR file, you cat check its using cat. Its bunch of encrypted code which you can even decode and check information within on this link. If there is any typo in data you can regenerate CSR before submitting to vendor.


Wednesday, September 21, 2016

How to remove password expiry in linux

Requirement : To set never expire attribute on account password. Some applications/users are required to have same password for longer dur... thumbnail 1 summary
Requirement :

To set never expire attribute on account password. Some applications/users are required to have same password for longer duration. This requires them to exit from system wide password expiry policy. So that those accounts can run lifetime without need of changing their passwords.

Image source : freeimages


How to do it :

Check account's current policy.


# chage -l testuser

Last password change                                    : Sep 01, 2016
Password expires                                        : Oct 04, 2016
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 33
Number of days of warning before password expires       : 7


Here second line shows when password is expiring post which user will be prompted to set new password. Set password to never expire with below command


# chage -M -1 testuser


Verify changes


# chage -l testuser

Last password change                                    : Sep 01, 2016
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 33
Number of days of warning before password expires       : 7


Get list of desired LUN id from powermt output

Requirement : You have a list of disk names from OS end and you need to get their respective LUN ids from powermt output. This ... thumbnail 1 summary
Requirement :

You have a list of disk names from OS end and you need to get their respective LUN ids from powermt output.

This requires manual work of searching each disk name in powermt output and then copying its respective LUN id. Typically these two lines you are interested in output.

Pseudo name=emcpoweraa
Symmetrix ID=000549754319
Logical device ID=03C4
If you have list of disks to search its a tedious task.

Image source : freeimages


Solution :

Get ouput of powermt in a file


# powermt display dev=all > powermt.old


Get all disk names in one file e.g. test.txt
Run a for loop which will get LUN id of each disk described in file.


# for i in `cat test`
do
cat powermt.old |grep -A 2 $i|grep Logical|awk '{print $3}'|cut -d= -f2
done


You will be presented with the list of LUN ids for respective disks in the test.txt file!

Vice versa: Get disk names by giving LUN ids in text.txt file.


# for i in `cat test`
do 
cat powermt.old |grep -B 2 $i|grep Pseudo|awk '{print $2}'|cut -d= -f2
done