Tag Archives: unix

How to Debug a Shell Script

shell script

One of the most common questions asked by a new sysadmin or UNIX user is: How to debug a shell script?

Netstat Tips and Tricks

unix linux

The netstat command prints information about the UNIX and Linux networking subsystem such as the network connections, routing tables, masquerade connections, multicast memberships plus many more.

In this article, let’s review some of the netstat tips and tricks.

Unix / Linux: How to Print Shared Library Dependencies

unix linux

Almost all programs on UNIX and/or Linux use shared libraries. Only some programs, like the root shell, /sbin/sh, on old versions of Solaris, used to be statically linked. It is no longer the case for the current Solaris releases. It was mainly due to historical reasons when disks used to be small in size (usually 128MB or less in size) and the shared libraries in /usr/lib were mounted from a second disk or NFS server. If you boot a server into single-user mode, it may not mount partitions other than the root partition, thereby breaking any dynamically linked program.

How to Sleep in Shell Script

shell script

Sometimes you will need to pause execution for a specific period within a shell script. To do that, you will need to use the sleep command to delay for a specified amount of time in seconds, minutes, hours or days.

Shell Script to Get Last Character of a String

shell script

There are a couple of ways to extract the last character of a string within a shell script. The easiest way is if you are working on bash shell – as bash will get the job done without the help of any external utilities.

How to Execute Shell Script on Logout

Sometimes I need to run a cleanup script automatically once I logout from a Linux or UNIX system. I normally use the script to cleanup my own temporary files.

How to Catch Ctrl-C in Shell Script

There are times when you do not want users to stop a running shell script abruptly by sending the Ctrl-C key combination. There is no way to prevent users from doing that, but there is a way to catch or trap Ctrl-C key combinations in a shell script.

Find Number of Hops Using Ping

In the computer networking field, traceroute is a diagnostic tool for displaying the hops and the round-trip time for each hop. Ping, on the other hand, computes round-trip times only from the destination point. But if you are just interested in finding out the number of hops to a destination and not the round-trip times, ping is an alternative utility to traceroute.