Wednesday, April 30, 2008

perlpragma - how to write a user pragma

A pragma is a module which influences some aspect of the compile time or run time behaviour of Perl, such as strict or warnings . With Perl 5.10 you are no longer limited to the built in pragmata; you can now create user pragmata that modify the behaviour of user functions within a lexical scope.more...

Linux vi and vim editor

This "vi" tutorial is intended for those who wish to master and advance their skills beyond the basic features of the basic editor. It covers buffers, "vi" command line instructions, interfacing with UNIX commands, and ctags. The vim editor is an enhanced version of vi. The improvements are clearly noticed in the handling of tags.

Tuesday, April 29, 2008

wireless sniffer

One of the best ways to make sure information is kept secure is to broadcast it using a published standard, and to try to make sure the signal goes as far as possible. Right? Well, maybe that isn't the best strategy after all. Unfortunately for us, the convenience of wireless access to a network means that a lot of people use a wireless network, and that means that a lot of data is being broadcast in the more..

Perl wlan-ui is a program to connect to wireless networks. It can be run as a GUI which will offer a list of available networks to connect to.nstallation is simple and inelegant. Copy the program file ( to a directory on your path. Next, create a new system configuration file to reflect your system. The system configuration file is different from the options configuration file (@configfile, above). The system configuration file tells the program how to configure the wireless interface, and the options configuration file sets defaults for access points and other things.

Sunday, April 27, 2008

Security of open UNIX platforms

The open UNIX operating systems FreeBSD and Linux Mandrake both have integrated shell security systems. The FreeBSD program is located in /etc/security. The Mandrake Security Package for Linux can be found in /usr/share/msec. These standard tools are similar in functionality, but they limit the file system integrity control to files with SUID and SGID flags. But Mandrake calculates MD5 file checksums differently from FreeBSD.more...

Solaris 9 System Administrator's Evaluation Guide

This guide is designed to help System Administrators evaluate the Solaris 9 Operating Environment (OE).
It includes information about what is new in the Solaris 9 platform, walks through the installation, and a test drive of the environment.
The appendix also includes information about the business advantages of using the Solaris 9 OE as well as an analysis of the Solaris 9 platform compared to the competition.

UML configuration

Before describing the various configuration interfaces, I should point out that it is highly recommended to run defconfig before doing anything else. I describe exactly why later in this section, but, for now, suffice it to say that doing so will give you a UML configuration that is much more likely to boot and run.
There are a variety of kernel configuration interfaces, ranging from the almost completely hands-off oldconfig to the graphical and fairly user-friendly xconfig. Here are the major choices.

Thursday, April 24, 2008

Inversion lists with Perl

Inversion lists are an essential part of any Perl programmer's toolkit, especially for those who deal with ranges and Unicode. In this article, Ted explains inversion lists, illustrated by a Perl implementation that he wrote and put on the CPAN network, and shows how inversion lists can be used to compress normal data in addition to bit strings.

Tuesday, April 22, 2008

A brief history of /proc

Those of you who have used a UNIX system before are probably familiar with the /proc filesystem. This directory provides a view of processes running on the system. Before getting into the gory details of the Solaris implementation (see proc(4) if you're curious), I thought I would go over some of the different variants over the years. You'll have to excuse any inaccuracies presented here; this is a rather quick blog entry that probably doesn't do the subject justice. Hopefully you'll be inspired to go investigate some of this on your own.more...


The crontab command is used to manage cron jobs. The -l option displays the current list of jobs for the user. The following example runs the report mentioned in this chapter's introduction:

[dave@sawnee dave]$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.9889 installed on Fri Oct 15 09:42:06 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
0 20 * * fri /home/dave/

Sunday, April 20, 2008

Linux Apps on x64: One Codebase, Two Platforms, Great Performance

As applications become increasingly data hungry and RAM prices continue to drop, the cross-over point from 32- to 64-bit architectures is approaching quickly. Already Microsoft has announced that several of its server-based applications will be released only on x64 bit platforms in the future. Linux, with its prominent role in on servers, will be at the leading edge of this transition, and so Linux developers should be thinking now about writing new code for the 64-bit platform. Under this scenario, the 32-bit version of the software would be derived from the x64 codebase. This article discusses the salient aspects of writing apps for x64 Linux...

Saturday, April 19, 2008

Perl::Tk app to manipulate pasted text on the fly

Here's a utility I built that is probably the most under-appreciated and widely used custom tool I have. I call it stringilizer. I initially built it to "stringilize" stanza-like SQL statements into nice double-quoted, vbcrlf, line-broken ASP strings, and it has since been used for about everything else you can possibly more..

real-time Linux architectures

It's not that Linux® isn't fast or efficient, but in some cases fast just isn't good enough. What's needed instead is the ability to deterministically meet scheduling deadlines with specific tolerances. Discover the various real-time Linux alternatives and how they achieve real time—from the early architectures that mimic virtualization solutions to the options available today in the standard 2.6 kernel.

Friday, April 18, 2008

Perl : how to identify a partition

How would I go about identifying a partition, or at least a physical drive?
Maybe id'ing a partition would be easier? It seems I could simply put a readonly file at the root of the partition, like / more..

Monitoring Hard Disks with SMART

It's a given that all disks eventually die, and it's easy to see why. The platters in a modern disk drive rotate more than a hundred times per second, maintaining submicron tolerances between the disk heads and the magnetic media that store data. Often they run 24/7 in dusty, overheated environments, thrashing on heavily loaded or poorly managed machines.more...

Wednesday, April 16, 2008

Multi-Boot Disk for Machines With AMD Opteron Processors

This article presents step-by-step procedures for loading the Solaris 10 OS on x86 platforms, and one or two 64-bit Linux operating systems, on machines based on 64-bit AMD Opteron processors. Installations were done on generic Opteron-based workstations and confirmed on a Sun Fire V20z server and Sun Java Workstation W1100z and W2100z workstations.

Network Configuration on the Solaris Platform

You should come away from this document with a firm understanding of how to set up your network interfaces using the command-line interface. Also included in this article are some basic troubleshooting hints. This document does not cover hardware.

Tuesday, April 15, 2008

Perl : Sorting a Hash

This technique offers many variations on the same basic mechanism: you extract the keys, reorder them using the sort function, and then process the entries in the new order. Let's look at some applications. The following code simply uses sort to order the keys alphabetically...

Monday, April 14, 2008

Upgrade Red Hat 9 to 2.6.0-test4 kernel

Firstly, you have to compile modutils, otherwise your 'make modules' will fail with many unresolved symbol errors. You can get modutils from here, or from this local mirror. I used version 0.9.13 and it worked more..

Real time signals on Linux

The GNU libc manual documents the original POSIX specification for signal handling functions. However subsequent POSIX standards expanded this functionality and the enhancements are often referred to as "realtime signals". This implies that these so-called realtime signals have bounded/prioritised delivery times but it is unclear whether this is the case, and in fact a broader range of new functionality is introduced which is independent of real-time qualities.more...

Sunday, April 13, 2008

UNIX TCP/IP Socket Programming

A "socket" is a loose term used to describe "an end point for communication." The traditional Berkley Socket API is a set of C function calls used to support network communication. The Sockets API is not specific to TCP/IP. Therefore, developing TCP/IP network applications requires slightly more overhead of programming and understanding to account for the generic parameters of the library's function calls. Once understood, Socket programming is as easy as reading and writing to disk more...

Friday, April 11, 2008

Replacing sendmail with postfix

What makes Postfix really nice as a replacement for sendmail is the fact that you can seamlessly and transparently replace sendmail using the same files you're already used to, making migration easy. Postfix supports the /var/mail/ filesystem, /etc/aliases, /etc/access, NIS, NetInfo and ~/.forward files, read more..

Perl : Messing with the Class Model

Perl's style of object orientation is often maligned, but its sheer simplicity allows the advanced Perl programmer to extend Perl's behavior in interestingand sometimes startlingways. Because all the details of Perl's OO model happen at runtime and in the openusing an ordinary package variable (@INC) to handle inheritance, for instance, or using the symbol tables for method dispatchwe can fiddle with almost every aspect of it.more...

Thursday, April 10, 2008

Hyper-Threading speeds Linux

This article gives the results of our investigation into the effects of Hyper-Threading (HT) on the Linux SMP kernel. It compares the performance of a Linux SMP kernel that was aware of Hyper-Threading to one that was not. The system under test was a multithreading-enabled, single-CPU Xeon. The benchmarks used in the study covered areas within the kernel that could be affected by Hyper-Threading, such as the scheduler, low-level kernel primitives, the file server, the network, and threaded support.

Wednesday, April 09, 2008

Database Programming with Perl

To connect to a database with the DBI, we need to first construct a string that identifies the database we want to connect to; this is called a data source name, or DSN. Let's assume we're going to be working with a MySQL database called "phonebill." (Simply because that's what I was working with yesterday.) The DSN for this is made up of three parts... more...

Server Limits for Apache Security

In this fourth part of a six-part series on Apache installation and configuration, you will learn how to set server configuration limits, prevent information leaks, and more. This article is excerpted from chapter two of Apache Security, written by Ivan Ristic (O'Reilly; ISBN: 0596007248). Copyright © 2006 O'Reilly Media, Inc. All rights reserved.

Tuesday, April 08, 2008

Build a Linux Home Router

Building your own router out of old spare parts has many advantages over buying a pre-made canned router by say Linksys. The biggest one by far is control over the connection. The other advantages are left up to your imagination; just about anything can be done in this scenario, it's just a matter of needing it.
This guide will show you how to setup Network Address Translation (NAT) on the router (kernel and iptables), add and configure common services (Domain Name System (DNS) via dnsmasq, dhcp via dhcpcd, ADSL via ppp), and conclude with more elaborate and fun things that can be done (port forwarding, traffic shaping, proxies/caching, etc...).

Perl : Printing a Hash

You want to print a hash, but neither print "%hash" nor print %hash does what you want; the first is a literal, while the second just has the keys and values all scrunched together. read more.

Monday, April 07, 2008

Add some spice to your UNIX shell scripts

One of the strongest assets UNIX® has is the ability to make shell scripts to ease users' lives. These scripts can range from simple one-liners to several thousand lines. Many times, shell scripts evolve into menu-based scripts, and the scripter wants to display more to users than simply scrolling text. Other times, a simple line or two of output are displayed to users, and the shell scripter wants to put emphasis on a warning message. Regardless of the complexity, scripters have always needed a way to change their output to bold, underline it, reverse the highlights, and so on. That's where tput comes into play,more...

Sunday, April 06, 2008

Calling Open

It turns out that calling open() can be tricky. This code was provided by Peter Guttmann to handle cases where the filesystem is changing underneath you.
Under Unix we try to defend against writing through links, but this is somewhat difficult since the there's no atomic way to do this, and without resorting to low-level I/O it can't be done at all. What we do is lstat() the file...

Finding text with grep

You can search through multiple files for specific strings of characters and then view the resulting list of matching files on screen.You do this using grep command which stands for "global regular expression print". read more...

Saturday, April 05, 2008

Types of Network Backup Solutions with linux

Broadly speaking, network backups can be performed in one of two ways: The computer that's to be backed up can initiate the backup using another system's tape drive, or the system with the tape drive can initiate the backup of another computer. I refer to the former as a client-initiated backup and the latter as a server-initiated backup. Each option has its advantages and disadvantages. This chapter discusses examples of both types of backup.

Upgrading Linux

Most Linux distributions have upgrade paths with their installation. They are, however, usually only useful for a sub-release upgrade, such as from 7.1 to 7.2 or 7.3. However, I have yet to run into one that will successfully and cleanly upgrade from one release to the next full release -- they all suggest a clean install, including Red Hat and SUSE. When migrating from one distribution to another, regardless of whether you choose install or upgrade, the process simply fails because it is unable to successfully install numerous packages.more...

Friday, April 04, 2008

Using a Sniffer to Diagnose Firewall Problems

Many problems can be isolated by running a packet sniffer on your firewall. Our favorite is tetheral, a part of the ethereal package, because it will put the packets into a more readable form than tcpdump, which is another good option. tetheral is also handy for command line diagnosis work because it works without all the fuss of a GUI and all the "voodoo" of a more lower-level sniffer such as tcpdump.more...

Thursday, April 03, 2008

Linux security : Testing for Open Ports

You want a listing of open network ports on your system.
Probe your ports from a remote system.
To test a specific TCP port (e.g., SSH):
$ telnet ssh
$ nc -v -z ssh.

Wednesday, April 02, 2008

OpenBSD as a domain name server

OpenBSD is certainly a well-suited platform for running a domain name server: first and foremost, the default install always includes the latest (patched) release of Bind, saving us the bother of compiling and installing it; secondly, OpenBSD is renowned for its security, and domain name server security is at the base of the whole network security; lastly, OpenBSD is very stable, reliable, fast and easy-to-administer ...just how a domain name server should be!read more..

Tuesday, April 01, 2008

Linux toolbox : System Information

This is a listing of the best problem determination tools available for Linux. The list is broken down by the categories of Process Information and Debugging, Network, System Information, Files and Object Files, Kernel, and Miscellaneous. Each tool listing includes a short description of the tool, where the tool can be obtained...

Perl's Warn and Die Signals

This is a tutorial on using Perl's warn and die signals. It is based on a post I made some time ago, here, but covers more of the details and raises more of the pitfalls. In this tutorial I attempt to separate the warn and die signals from the OS signals, explain how they are used and what they can be used for, and explore the problems that can come up.