Posts

Showing posts from December, 2009

nagios-config-build Released

Image
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." Systemnotes.org download: http://www.systemnotes.org/download/shell/nagios-config-build.html Freshmeat project: http://freshmeat.net/projects/nagios-config-build Please feel free to use thi...

How to Record and Play in Vim

Image
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 thegeekstuff.com: Vim Macro Tutorial: How To Record and Play

Bash Shell, X, & Firefox Shortcuts

Image
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 , ...

Bash Alias

Image
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 th...