HP-UX: How Do I configure routing or add route?

Posted on in Categories Howto, HP-UX, Sys admin, Tips, UNIX last updated October 24, 2007

You can use route command to configure routing. Syntax is as follows:
route add net {network-address} netmask {subnet} {router-address}

Let us assume your router address is and network ID is, then you can type route command as follows:
# route add net netmask


To add a default route:
# route add default

Verify that (display) routing table is updated (display routing table):
# netstat -nr

Test it i.e. try to ping or send nslookup request:
# ping mycorp.com

To flush all routing entries use command [quite handy to clean your gordian knot ;)] :
# route -f

However if I reboot HPUX box then above routing entries gets removed. To pick up your setting upon each reboot your need to configure Routes in HPUX networking configuration file – /etc/rc.config.d/netconf. To add default router/gateway
# vi /etc/rc.config.d/netconf

Add or modify following entries


Reboot HP-UX system/server to take effect
# shutdown -ry 0

HP-UX Booting from a system recovery Tape

Posted on in Categories Backup, HP-UX, UNIX last updated November 1, 2007

Recently one of our HP-UX servers went down and it needed recovery. Since I’m new to HP UX one of our senior UNIX admin pointed me that they have a system recovery tape. After going through our internal docs and other resources, I was able to recover system :)

Here is what I did…

First I had put recovery tape into the tape driver

As soon as system started (auto boot) I had to interrupt the autoboot sequence (press ESC key) and load tape into driver
Next I had type ‘search ipl‘ command so that it will search for my recovery tape driver
> search ipl

It will give output of different devices such as Random access media, look for Sequential Access Media (and its path number or hw path).
Here is what I typed to boot from tape (in my system

> boot 8/16/5.0
> boot p2

Replace 8/16/5.0 or p2 with your actual tape drive h/w path. Once booting started, it will automatically restore it.

It took almost an hour to recover but it did the job. This tape made my system bootable. Next task was to restore all data from full and incremental backup and install needed additional software. I had typed following command on HP-UX box to restore all files and directory:

# frecover –f /dev/rmt/0m –rv

This emergency came around 5pm evening last Friday. I was just closing for that day and I was about to go home. I had spent 4 hours to restore box and other stuff.

Well good news it that my diwali holidays starts from coming Friday and it will lasted until November 7, 2005 :). I really need a break guys :D.

Running Commands on a Remote Linux / UNIX Host

Posted on in Categories CentOS, Debian Linux, FreeBSD, Gentoo Linux, Howto, HP-UX, Linux, Monitoring, Networking, OpenBSD, OS X, RedHat/Fedora Linux, Security, Shell scripting, Solaris, Tips, Ubuntu Linux, UNIX last updated January 29, 2008

You would like to execute a command on a remote Linux/FreeBSD/Solaris/UNIX host and have the result displayed locally. Once result obtained it can be used by local script or program. A few examples:
=> File system and disk information

=> Get user information

=> Find out all running process

=> Find out if particular service is running or not etc

You can use rsh or ssh for this purpose. However, for security reason you should always use the ssh and NOT rsh. Please note that remote system must run the OpenSSH server.

Syntax for running command on a remote host:
ssh [USER-NAME]@[REMOTE-HOST] [command or script]


  • ssh: ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.
  • USER-NAME: Remote host user name.
  • REMOTE-HOST: Remote host ip-address or host name, such as fbsd.cyberciti.biz.
  • command or script: Command or shell script is executed on the remote host instead of a login shell.


(A) Get disk information from a server called www1.cyberciti.biz:
$ ssh [email protected] df -h

(B) List what ports are open on remote host
$ ssh [email protected] netstat -vatn

(C) Reboot remote host:
$ ssh [email protected] reboot

(D) Restart mysql server (please note enclosed multiple command line arguments using a single or double quotes)
$ ssh [email protected] '/etc/init.d/mysql restart'

(E) Get memory information and store result/output to local file /tmp/memory.status:
$ ssh [email protected] 'free -m' > /tmp/memory.status

(G) You can also run multiple command or use the pipes, following command displays memory in format of “available memory = used + free memory” :
$ ssh [email protected] free -m | grep "Mem:" | awk '{ print "Total memory (used+free): " $3 " + " $4 " = " $2 }'

See how to configure ssh for password less login using public key based authentication.

=> Related: shell script to get uptime, disk usage, cpu usage, RAM usage,system load,etc. from multiple Linux servers and output the information on a single server in a html format.