Featured »

June 18, 2013 – 8:06 pm |

In the past few days my Postfix server has been having occasional problems talking to the mail gateway. They problem would come and go. The Postfix server would timeout trying to connect to the gateway and keep …

Read the full story »
Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Archive by Category

Articles in Commands & Shells

Bash scripting: lists and random things

April 16, 2013 – 12:39 pm |

Imagine you have an HPC cluster with a hundred compute nodes named node001-node100. The two commands below will help you generate a list of node names – either all name on one line or one name per …

Fast IP Range Scanner in Bash

February 22, 2013 – 2:53 pm | 4 Comments

Just a simple script to scan an IP range and do a reverse DNS lookup. This can be useful for building an inventory of systems on your LAN. Just make sure to give your network …

Remounting Active NFS Filesystems

January 23, 2013 – 12:57 pm |

Here’s a scenario: you have an NFS client mounting a filesystem from server1. You need to migrate this data to NFS server2 and remount the filesystem from the client to point to the new server. The problem is that there is a user application on the client system that uses the NFS mount, preventing you from unmounting it.

Uninstall PostgreSQL from Ubuntu

January 4, 2013 – 1:22 pm | 2 Comments

Ok, so this is a very simple one: uninstall PostgreSQL running on Ubuntu. There are a bunch of pieces to the database server and just running “apt-get remove postgresql” will still leave you with with a bunch of leftovers

Making Rsync Faster

November 24, 2012 – 3:13 pm | 9 Comments
Making Rsync Faster

If you Google something along the lines of “make rsync faster”, the most common thing you’ll see is people saying “hey, I have a gigabit network connection and my rsync is crawling along at a hundred kilobytes per second.” Well, the issue here is not the network. Rsync needs time to analyze source and destination, generate checksums and compare timestamps, build a list of stuff to transfer and then, finally, start the copy process, one item at a time. You see the problem, I am sure.

A Faster Way to Delete Many Folders

October 24, 2012 – 11:00 pm | 4 Comments
A Faster Way to Delete Many Folders

This issue is particularly annoying when dealing with expansive directory structures mounted via NFS. Let’s say you have a directory with ten thousand folders and each of them has more subfolders and files. And you …

Simple Shell Random Password Generator

October 2, 2012 – 10:54 am |
Simple Shell Random Password Generator

A very simple script to generate a random secure password of desired length. This can come in handy when setting up multiple user account and/or lacking imagination.

Generate Encrypted Password for /etc/shadow

September 16, 2012 – 12:46 pm | 4 Comments
Generate Encrypted Password for /etc/shadow

Here is a simple way to generate an encrypted password string for use in Linux /etc/shadow, among other things. This is just in case you don’t wish to use the usual tools for changing the password (passwd, chpasswd).

Use wget with Your Rapidshare Account

July 8, 2012 – 10:40 pm | 6 Comments
Use wget with Your Rapidshare Account

If you have a Rapidshare premium account, you can use wget to download files. The process is two-fold: first, you need to use wget with your Rapidshare username and password to obtain and store the Rapidshare cookie; then, you can use wget with the cookie file to download a list of links.

Configure Postfix to Use Gmail for Sending

May 16, 2012 – 12:52 pm | 6 Comments
Configure Postfix to Use Gmail for Sending

Here is a simple script to help you configure Linux postfix to use your Gmail account for sending emails. The script has been tested on OpenSuse 11.4 and 12.1, but should work find on any recent Linux disro. The only requirement is that you have postfix insalled.

Playing With Time in Bash Shell

February 24, 2012 – 11:38 pm | 5 Comments
Playing With Time in Bash Shell

The “date” command in Bash shell offers a remarkable array of features that can be very useful in performing many system administration tasks. As you will see below, it is easy to determine date, time, day of week for any interval of time. This can be very useful for system automation tasks with “cron” and “at”.

A Simple Process Monitoring Script

February 22, 2012 – 11:28 am | 8 Comments
A Simple Process Monitoring Script

Let’s say you are running a data restore. Things are moving along, but network is congested and the backup server is overloaded. You really don’t feel staring at the restore status for the next several hours and just want to be notified when the process completes. The simplest method of monitoring for processes starting or ending on Unix systems is by using “ps” with a “while” loop.

Compress Old Log Files on Linux

January 12, 2012 – 6:06 pm | 6 Comments
Compress Old Log Files on Linux

Most log files located in /var/log are part of the log rotation and will be compressed automatically. However, in many cases various user applications maintain log files outside of /var/log. These logs are not managed …

Testing SSH Connectivity to Multiple Servers

December 27, 2011 – 2:46 am | 8 Comments
Testing SSH Connectivity to Multiple Servers

Imagine a hypothetical scenario: you support hundreds of remote servers and you need to check which server you can access via SSH and which servers are not letting you log in. Doing this manually is a tedious process that many sysadmins choose to skip. The inevitable outcome is inability to quickly access a system when it really counts.

Writing a Linux Startup Script

December 16, 2011 – 2:11 am | 11 Comments
Writing a Linux Startup Script

As basic as the task of creating a startup script may sound, even experienced sysadmins sometimes run into problems with having services start at the right time during the boot process or stop during the shutdown. Two major reasons for this: the procedure is a bit convoluted due to linking. Also, writing startup scripts is not something you have to do very often these days.

Viewing “man” Pages in a Web Browser

September 16, 2011 – 12:43 am | 4 Comments
Viewing “man” Pages in a Web Browser

The Unix “man” pages are an indispensable tool even for the most experienced of sysadmins. Unfortunately, in a terminal window the text may be hard to read and getting a hard copy to take with you down to the datacenter will really test your Unix skills. The following quick script will convert the “man” page of your choice into formatted text and open it in the Web browser.

Autorebooting Servers on Low or High Load

September 14, 2011 – 5:03 pm | 3 Comments
Autorebooting Servers on Low or High Load

Recently I ran into a situation where I needed to reboot several HPC cluster compute nodes. A couple of systems were still running user jobs that I did not want to interrupt. I also didn’t want to sit around and watch those jobs, as there was not way of telling how long they could take to complete. The solution was to write a short script that looks something like this…

Testing RAM in Linux

September 2, 2011 – 11:42 am | 7 Comments
Testing RAM in Linux

A number of good and mostly free tools are available for testing RAM hardware. However, most of these applications are designed to operate in stand-alone mode that requires shutting down the OS. Still, tare a few ways to run memory integrity checks from inside the operating environment. Here we will look at using dd and memtester.

Using Expect with SSH and Su

August 29, 2011 – 10:47 am | 6 Comments
Using Expect with SSH and Su

We have discussed using expect with sudo in an SSH session. Another common way to run commands on remote servers as root is to use the su – root command, where sudo is not configured. The trick to automating su operations using expect is to launch the su command with the spawn ssh command.

Moving Average with Excel and Shell Script

August 11, 2011 – 12:41 pm | 4 Comments
Moving Average with Excel and Shell Script

In this example we will show you how to calculate simple moving average using Excel and a shell script. As more data is added to the file, the shell script and the Excel formula will automatically use the specified number of the latest data points to calculate the moving average.

Configuring Passwordless SSH

July 23, 2011 – 11:02 am | 5 Comments
Configuring Passwordless SSH

Passwordless SSH works by pre-sharing public encryption keys. It is important to understand that setting up passwordless SSH opens your servers to certain security risks. A compromised user account on one server may allow the attacker to gain access to multiple systems on the network. Try to avoid using passwordless access for accounts with elevated privileges.

Automating SSH and Sudo with Expect

July 14, 2011 – 10:20 am | 14 Comments
Automating SSH and Sudo with Expect

Let’s imagine a hypothetical scenario: you have a list of a hundred Linux servers and you need to log into each one of them and remove a local user “roger” and his home directory. Doing this by hand will get tedious and, chances are, you will make a few typos and there will be some collateral damage.