Site Feed

Wednesday, December 16, 2009

nagios-config-build Released

I wrote some shell scripts to generate Nagios configuration files, and I finally decided to publish them on Freshmeat. The initial version is crude, and has some hard-coded information, but it is still better than trying to edit the .cfg files by hand.

Here is a brief description

nagios-config-build is a group of shell scripts that generate Nagios configuration files from a list of hostnames. It automatically resolves IP addresses from DNS, and provides a quick way to manage a large number of hosts without having to set up a complicated system.

Nagios is more than just a server monitoring tool. From the Nagios website: "Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes." download:

Freshmeat project:

Please feel free to use this blog post for comments, or questions.

Monday, December 7, 2009

How to Record and Play in Vim

Have you ever been in the middle of editing something in vim, and noticed "recording" on the lower left of the screen? If you were in a hurry, you probably just continued typing, and thought, maybe I'll use that feature some day, but as long as it lets me continue I won't worry about it. Well it's really quite simple to use once you know the sequence.

Here is a high level overview on how to use the macro recording feature of vim.

High Level Steps to Record and Play a Macro in Vim

1. Press q to Start recording, followed by a lower case character to name the macro.
2. Perform any typical editing, actions inside Vim editor, which will be recorded.
3. Stop recording by pressing q.
4. Play the recorded macro by pressing @ followed by the macro name.
5. To repeat a macro multiple times, press : n @ macro name, where n is a number.

For more details, check out a complete tutorial at Vim Macro Tutorial: How To Record and Play

Wednesday, December 2, 2009

Bash Shell, X, & Firefox Shortcuts

As I was writing a script, I noticed that I pressed Shift-PageUp without even thinking about it. Then I realized that there are a lot of shortcuts we take for granted as Sysadmins. I thought it would be helpful to share some of them.

This is not a comprehensive list, but a few shortcuts I find myself using all the time.

Bash Shell shortcuts

  • Shift-PageUp / PageDown See more of the screen

  • Ctrl-a, Ctrl-e Move to beginning / end of line

  • up & down arrows See bash history

  • !! / !$ Execute the previous command / parameter

  • !n Execute the nth command in history

  • Ctrl-D Logout, or exit

  • Ctrl-u, Ctrl-h, Ctrl-b Delete previous char, or entire line

  • Alt-F1 to Alt-F7 Switch to another console

  • —see also: using-bash-history, and all bash posts

X shortcuts

  • Ctrl-Alt-Backspace Force X to reset

  • Alt-tab Switch to a different application

  • gnome-terminal:

    • Ctrl-Shift-t Open a new tab

    • Ctrl-PageUp / PageDown Switch between terms

    • (Ctrl)-Alt-F1 to F7 Switch to another console (Ctrl while in X)

Firefox shortcuts

  • Ctrl-Click / Shift-ClickOpen link in new tab / window

  • Ctrl-PageDown Goto next tab

  • Ctrl-t New tab

  • Alt-Home Goto home page

  • Esc Stop flash animations from playing

  • Ctrl-Shift-t Re-open a Recently Closed tab

There is a nice shortcut list at, organized by key bindings

Bash Alias

An alias is a built-in way of modifying the way a command works, or it is used as a shortcut for another command. For example, you may find that you often type "ls -l", or "ls -ltr", and think it would be nice if you could type less characters. You can create an alias, so that all you would have to type is "ll", instead of "ls -l."

To add an alias to your .bashrc file:

$ vi ~/.bashrc

Insert these lines:

alias ls='ls --color=tty'

alias ll='ls -l'

In order for the new alias to take effect, you can open a new console, login again, or simply source your .bashrc file. You also have the option of running bash again to open a new shell, or just running the alias command. What do I mean by source the file? You can either run a script, or have the shell read the variables in a script without actually running it. This is called sourcing a file, and is accomplished by typing either "source", or "." followed by the file to source, e.g.

$ source ~/.bashrc


$ . ~/.bashrc

Sometimes the word source is easier to read than a dot, but either method will work fine.

Note that you don't need to be root to access your home directory. "~/" is a shortcut for wherever your home directory happens to be (e.g. /mountpoint/home/me, or /home/users/someone). Also, the dot "." is used for hidden files, so if you do

$ ls ~/

it won't show up, but if you do

$ ls -a ~/

it will.

There are some common aliases you may have by default. To view your current aliases, type alias by itself, or "alias -p":

$ alias -p
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias vi='vim'

Other Uses

"What else can this be used for?", you ask. Anything you use often enough -- usually something smaller than a script, but too long to type frequently. How about changing to a common directory? Of course, to go home, type:

$ cd

To go to the previous directory, type:

$ cd -

Maybe you would like something like "sales" to take you to /home/dept/sales.

alias sales='cd /home/dept/sales'


What happens if you make a mistake, or you use your account on a host that has a shell that does not support your alias? For example, you log into a sun box, and the ls alias is not valid. The quick fix is to simply run "unalias ls."

So, go have some fun with aliases. Here are a few ideas to try:

alias h='hostname'
alias myprogram='/usr/local/bin/myprogram'
alias taillog='tail -f /var/log/messages'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

Tuesday, September 22, 2009

Reset a Frozen SSH Session

I mentioned previously that you can reset a shell by typing "reset."

There is another problem that can cause a shell or xterm to freeze. If you ssh to a remote host, and then logout, sometimes the session will freeze. In that case, all you need to do is type "Enter", "~", "." (Enter, Tilde, Dot with no spaces) to get the console back. That's the Enter key, immediately followed by tilde "~", and then a period "."


Also, a convenient way to exit a shell, xterm, or remote ssh terminal is to use Ctrl-D rather than taking the time to type the word "exit."

Wednesday, September 9, 2009

Script to Unlock Firefox

I wrote a script to unlock Firefox on a linux machine. The symptom is when firefox is not running, but it won't let you start because it thinks it's still running. If you have already run "pkill -9 –f firefox", then all you have to do is delete the lock files -- .parentlock, and lock.

This is user specific, so you'll have to find your own home directory under ~/.mozilla/firefox/. Mine is dz4bq7je.scottm on this host.

$ cat ~/bin/
rm ~/.mozilla/firefox/dz4bq7je.scottm/.parentlock
rm ~/.mozilla/firefox/dz4bq7je.scottm/lock
$ ll ~/.mozilla/firefox/
total 12
drwx------ 9 scottm users 4096 Sep 9 11:25 dz4bq7je.scottm
-rw------- 1 scottm users 1264 Jun 23 2008 pluginreg.dat
-rw-r--r-- 1 scottm users 162 Nov 15 2005 profiles.ini

The advantage of this simple script is that you don't have to go looking for directories and files, or remember where firefox puts them. Just remember when it's locked, look for your unlock script.

Thursday, August 13, 2009

How to use BCC in Yahoo Mail Classic

Here is a quick example of how to use BCC in Yahoo Mail Classic.

The idea is similar in many different email programs.

Easy Two Step Process

There are two simple steps to help your recipients avoid getting flooded with spam.

1.) Enable the Bcc feature

2.) Use "Bcc:" instead of "To:" whenever sending mail to multiple recipients.

Screen Shots

Step 1.) Find and Enable the Bcc feature

Step 2.) Use Bcc:

That's all there is to it! You'll be saving your friends from tons of unwanted emails by keeping their email addresses private.

For more details on why BCC is important, please see this article:

Thursday, July 30, 2009

RHCE Flash Cards

I came up with some flashcards based on commonly used redhat linux commands. Here is my working draft.


These notes should be helpful to anyone working on Redhat Enterprise Linux (RHEL), or preparing for the RHCE exam.

My RHCE Study Guide was hugely popular, but unfortunately it had some potential copyright issues. This group of flashcards has also been released as a quick study guide, or cheat sheet, and contains much of the same original study guide material, but with all proprietary information removed. This 3-page guide is listed as RHCE Flash Cards (condensed version)

How These Slides Were Created

These slides were produced using Impress.
  1. Created Slides
  2. Saved as html
  3. Copied contents of html between body tags to .page files.
    • Used a bash shell script with sed, and awk to get the files to appear properly for webgen. See script here—html2page.html
  4. Ran webgen on the directory to generate .html
Also .pdf files were saved from Writer, which not only is free software, but also allows writing of .pdf files -- also for free. Isn't open source software great?

Let us know what you think.

If you notice any errors, omissions, or potential copyright issues, please comment below, or contact us.