Site Feed

Saturday, April 28, 2007

How to Change the Root Password to Get Into a Linux Box

This procedure assumes you have console access, and are authorized to make changes to accounts on the machine, including root.

If you own the machine, you can boot into single user mode, and change the password, or create an account.

If using grub (you should see a blue bootup screen), press "a", "space", "1", "enter"
a 1
That will boot to single user mode.

Then you can change the root password

Then reboot Ctrl-Alt-Del

You should create user accounts other than root. Use the useradd command.
useradd someone
passwd someone

Friday, April 27, 2007

RHCE Study Notes - SMTP

Study notes for any exam are difficult enough to find, but RHCE material seems even more scarce. This article tells how to prepare for one of the objectives, which is configuration of an SMTP server.

RHCE Study Notes
I wrote up some study notes as I was preparing for the RCHE exam. Here are some quick notes based on the official RedHat objectives, labs, and possible questions I thought might be reasonable requests.

SMTP Related Questions
install sendmail, sendmail-cf, sendmail-doc (optional)

Q: Configure mail server to accept internet email
A: modify /etc/mail/
1) cd /etc/mail
2) vi /etc/mail/
search for 127.0, put dnl at the front of the line
3) make
or m4 >
service sendmail restart
Q: Mail alias
A: modify /etc/aliases, run newaliases
Q: Receive mail for
A: modify sendmail mc as above, and add domain to /etc/mail/local-host-names
mail -v root
mailq, mailq -Ac
sendmail -q
tail -f /var/log/maillog

Configure Sendmail as a Server for Other Clients

A little more detail...

    as root, or sudo
  1. backup your /etc/mail/ and files
  2. vi /etc/mail/

  3. Search for a line with 127, and comment the line by placing "dnl #" at the beginning
    Change this line
    DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')
    to this
    dnl # DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl
  4. m4 /etc/mail/ > /etc/mail/

  5. /sbin/service sendmail restart

  6. /sbin/chkconfig sendmail on

mail -v root
mailq, mailq -Ac
sendmail -q
tail -f /var/log/maillog

For more details, see the Red Hat Reference Guide

And LinuxSelfHelp

How to Run a Bash Command on All Items in a List

For Linux / Unix
Follow as instructed

For Windows
Download cygwin from
For instructions, see this article:

Two Easy Steps for One-Liners

e.g., you have a list of servers, and would like to do something, such as ping each one, or check their IP address. Here is a quick two-step process, with a one-line shell script that can be run from the command line.

1) Create a Text file, with one hostname per line
2) Run a for loop on the file

$ cat servers.txt

$ for host in `cat servers.txt`;do host $host;done has address has address has address

If you want different output, you can use awk, but that's another topic.

Notice a few things about this one line script.
1) Each command is separated by a semicolon ";"
2) The back ticks around a command and parameter causes the results to be returned
3) The variable host is assigned in the first part, and called just before done

Note: if you want to use ping, try "ping -c 1 $host", or it will never finish.

Use Cygwin to Run Linux on Windows

Yes, not only can you run Linux from a CD --, but you can also install it in Windows, and run it as a Windows
program. You get a standard linux bash shell, and even X, with a little

What Is Cygwin? (from

  • Cygwin is a Linux-like environment for Windows. It consists of two
    parts: A DLL (cygwin1.dll) which acts as a Linux API emulation layer
    providing substantial Linux API functionality.

  • A collection of tools which provide Linux look and feel.
The Cygwin DLL currently works with all recent, commercially released

x86 32 bit and 64 bit versions of Windows, with the exception of Windows CE.

Note that the official support for Windows 95, Windows 98, and Windows Me will be discontinued with the next major version (1.7.0) of Cygwin.

What Isn't Cygwin?
  • Cygwin is not a way to run native linux apps on Windows. You have to
    rebuild your application from source if you want it to run on Windows.

  • Cygwin is not a way to magically make native Windows apps aware of
    UNIX (r) functionality, like signals, ptys, etc. Again, you need to
    build your apps from source if you want to take advantage of Cygwin

Where to Get Cygwin

How to Install Cygwin
1) Download the installer
2) Run the installer
3) Select some mirrors near you
4) Select applications to install, or just leave the default
5) Finish
6) Run cygwin (double-click on the icon)
7) Enjoy!

Support for Cygwin
RedHat -- for Cygwin licensing or commercial support
Cygwin FAQ --
Cygwin Users Guide --

Wednesday, April 25, 2007

Which Certifications are Important?

Not as popular as it once was.

One of the most popular has been the MCSE.

It is always good to have some network knowledge.

One of the most challenging exams in the industry. All hands-on lab

Not very difficult, but shows some knowledge of hardware, and is a
prerequsite for HP exams

HP Acredited Platform Specialist. Requires CNE, or MCSE and A+ as
prerequsites, but is a fairly easy exam that deals mainly with hardware.

Other Specialties
Oracle, Citrix, etc.

There is plenty of demand for MCSE's, but experience counts as well.
RHCE is another important one, as is the CCNA. Other certs are useful,
but more so in smaller companies, or as a consultant. You will need
more experience to get into a big company, but jobs tend to be more
specialized. You would either be a server admin, network admin, or dba,
whereas in a smaller company you might be all three.

Another important thing to help get interviews is a college degree. You
can use some of your certifications for college credit.

How to Get Started with Linux

Have you always wanted to find out more about linux, but were not sure where to start? Here is a little information on where to find, and how to run and / or install a linux distribution.

What is Linux?

Linux is the kernel, or core part of an operating system that is free from any software licenses. Free to download, and install on as many machines as you like.

Here's an explanation from

The GNU Operating System - Free as in Freedom
What is the GNU project?

The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system. Variants of the GNU operating system, which use the kernel called Linux, are now widely used; though these systems are often referred to as "Linux", they are more accurately called GNU/Linux systems.

GNU is a recursive acronym for "GNU's Not Unix"; it is pronounced guh-noo, approximately like canoe.

Trying Linux

First, you may not have known that you don't have to install linux to try it out. Just look for a live cd distro, download the .iso file, burn it to a DVD, or CD, and then boot from the DVD. When you are finished playing around, just pop the DVD out, reboot, and your old OS will come up as before. Of course the computer will run slower from DVD, but it is a good way to get a feel for which distro you like. Some of the more popular live distros are ubuntu, and knoppix (click on the flag for English, or whatever language you prefer). Once you've had a taste, you may want to install it by itself, or as a dual-boot configuration. There are some good howtos, but some of them are outdated. These look pretty good.

Finding a Linux Distribution

If you want to work as a sysadmin, you really should learn RedHat linux --, but you don't have to pay for it unless you want support. You can start by downloading Fedora Core -- Another popular business distro is SUSE which is now owned by Novell --

Live CD List

Top Ten Distributions

Choosing a desktop Linux distro

If you have trouble downloading, you can always buy CDs or DVDs for a very small fee.

Finding More Linux Information

RedHat has some very good documentation on their website -- For example, The Red Hat Enterprise Linux 4 - System Administration Guide is available in HTML and PDF formats:

Another good source of information is the Linux Documentation Project --

If you want more interactive help try or a local Linux User Group, known as a LUG, such as KPLUG -- Kernel Panic Linux User Group You can sign up for the mailing list of most LUGs. Some have more traffic than others. This particular LUG happens to have a linux-newbie list for beginners, and they are quite friendly, and very good at answering questions.

And don't forget the ever important google search, using --

Tuesday, April 24, 2007

How to Start a Blog

...and maybe make some money.
An article I posted on discusses how to get more traffic to your site.

Now let's concentrate on how to set up a blog. With blogger, you don't have to know any html, but if you do, it helps.

Getting Started
First go to and create a blog. If you already have a gmail account, you have completed the first step. It is really simple, and they walk you through it. Think of a name, and what you would like to write about.

O.K., so you have a blog, now what?
There is a book title that should help you keep on topic -- "No One Cares What You Had for Lunch" Then start posting. You can set up your blog to receive email, so posting is very easy. Just send an email to the address you set up under settings / email.

Making money
Well, keep posting something useful, but If you want to make money, don't waste any time. Get an adsense account, and start placing some ads on your site.

Go to the AdSense Setup tab, and select the ads you would like to display. Then just copy and paste the code into your site (use the Template tab in blogger).

For more tips, see some articles on --
--, or do a google search on "monetize blog." Here is another link:

Checking Traffic
It is also a good idea to check on your traffic. That can be done easiy by getting a google analytics account. Just copy and paste the code into your site.

For more information about blogs, check out this page.

Tuesday, April 17, 2007

Search Engine Optimization

Sure this blog is more about systems and programming than it is about marketing, but if you're building a website or blog, you probably have at least some interest in SEO (Search Engine Optimization). Basically, that means having other quality sites link back to your site, which is what makes it appear higher in search engines such as google

Here are some things to check out:

Try a google search on seo, if you want to learn more.

And don't forget about the excellent webmaster tools at google.
and specifically, How can I improve my site's ranking? --

Thursday, April 12, 2007

Using bash and sed to Modify a Text File

This shell script demonstrates how to write to a text file, and then modify the contents.
# by ScottM, 04/12/2007
# demonstrates writing text to a file, and then using sed to modify it.


# add some content to the file (note: file will be overwritten)
echo "apple" > $TESTFILE

# modify the content
sed -e "s/apple/& $FRUIT/g" -i $TESTFILE

# sed uses the "s" option, which uses regular expressions to search and replace text
# "s/apple/" means search for any lines that contain the characters "apple"
# "& " means use the results of whatever was found
# "/& $FRUIT/g"  -- replace "apple" with "apple banana",
# the g is for global, or all lines containing the pattern

# output:
# $ cat test.txt
# apple banana
# $
Sed One Liner

This is really only a one line script, commonly referred to as a on-liner, so we don't really need a bash script, as long as we understand the regular expressions we are trying to use.

From the command line, we can insert a word:

$ sed -e 's/apple/& pear/g' test.txt
apple pear banana

Notice how the ampersand "&" character prints the text that was found.  Note that we left out the -i, so we can test the output before modifying the original.
Look at the difference here.  The word "pear" is either inserted or appended:

$ sed -e 's/\(apple\)/& pear/g' test.txt
apple pear banana

$ sed -e 's/\(apple.*\)/& pear/g' test.txt
apple banana pear

The parenthesis contain the search parameter that is printed by ampersand, but when we include ".*", we get apple followed by all characters up to the end of the line, and then we add a space and out new text:  " pear".

If we want to replace the entire line with the search string, plus some added text we could use the "^" to indicate start of line and $ to indicate end of line. In this case it would use whatever matches the search pattern, and ignore whatever else is on the line.

sed -e 's/^\(apple\).*$/\1 pear/g' test.txt
apple pear

So what happened to banana? We did a search for apple, and surrounded it with parenthesis. Then we asked to print \1 which is the first set of parenthesis (in this case the only set). That effectively erased everything else on the line except whatever matches apple.

Notice how you can print multiple search groups:

$ sed -e 's/^\(apple\)\(.*\)$/\1 pear \1\2/g' test.txt
apple pear apple banana

Exercise to try: -- Where this might be useful is when replacing a URL in an html file. Search for href="something", and replace it with href="something-else"

Exercise 2 Try adding other words that match apple (e.g. apples, apple-pie,), and see what happens.

For more Regular Expression examples see our regex articles.

Wednesday, April 11, 2007

HowTo Install Multi Gnome Terminal using Yum

Multi Gnome Terminal Install

Note: This procedure is for non-standard, unsupported software. The dag repository is outside of Redhat's control, but has some very useful software.

Since multi-gnome-terminal has several dependencies, it is easier to install using yum.

First, Install Yum

* Install yum from your distribution
$ rpm -Uvh
* Modify /etc/yum.conf
Standard yum.conf for rhel-3-U6 (change as required):


name=Red Hat Enterprise Linux 3 Update 6 i386 AS

* Then, add the dag repository to /etc/yum.conf

name=Dag RPM Repository for Red Hat Enterprise Linux

Now, Install and Configure multi-gnome-terminal

1. Install multi-gnome-terminal
1. yum install multi-gnome-terminal
2. Add launcher to task bar
1. Name: multi-gnome-terminal
2. Command: /usr/bin/multi-gnome-terminal
3. Icon:
3. Launch multi-gnome-terminal
1. multi-gnome-terminal &
2. or click on launcher icon
4. Configure Console Colors
1. On the "Settings" menu, select "Tab Preferences"
2. Select the "Colors" tab
3. On the Forground/background color drop-down, select "black on white"
4. Select the "Image" tab
5. Check "Shaded Background", and make it less than -50%, so it is almost white
6. Select a background pixmap, if desired
5. Configure keybindings
1. On the "Settings" menu, select "Keybindings"
2. Under the Action Dropdown box, select
1. "Shell->New Tab"
2. Press the keys, "Ctrl-Shift-t"
3. Click on the add button
4. Click on the clear button under the Keybinding label
5. "Shell->HSplit"
6. Press the keys, "Ctrl-Shift-h"
7. Click on the add button
8. Click on the clear button under the Keybinding label
9. "Go Right"
10. Press the keys, "Ctrl-Page Down"
11. Click on the add button
12. Click on the clear button under the Keybinding label
13. "Go Left"
14. Press the keys, "Ctrl-Page Up"
15. Click on the add button
16. Click on the clear button under the Keybinding label
17. "All bonded"
18. Press the keys, "Ctrl-Alt-b"
19. Click on the add button
20. Click on the clear button under the Keybinding label
21. "All unbonded"
22. Press the keys, "Ctrl-Alt-u"
23. Click on the add button
24. Click on the clear button under the Keybinding label
3. Click on the OK button

Why so much configuration?

It is really optional, but the steps listed make the program function like a normal gnome-termial window, so the appearance and keystrokes will be similar. Of course, you are welcome to configure it however you want.

Monday, April 2, 2007

Using nmap to Generate Host Lists

An easy way to get a list of hosts from a single domain that you are a part of, is to query DNS

host -l

But that is not always practical. Sometimes you have machines that are in different domains, but they all are part of a network you manage. Rather than trying write a script that pings hosts and reports the output, just use nmap for a very fast scan.

To scan all hosts in a list of subnets

1) Create a subnets.dat file with one subnet on each line:

$ cat subnets.dat

2) Run nmap with the subnets.dat file as input

$ nmap -sP -R -iL subnets.dat
Reading target specifications from FILE: subnets.dat

Starting nmap V. 3.00 ( )
Host ( appears to be down.
Host ( appears to be up.
Host ( appears to be down.
Host ( appears to be up.
Host ( appears to be up.

Notice how names are resolved for existing hosts, but only an IP is returned, if there is no DNS record (e.g.

3) Write a script to report on the output you want
e.g. for a list of all hosts that respond to ping

$ cat

# clean up old file
[ -f hosts_scanned.dat ] && rm hosts_scanned.dat
echo "nmap -sP -R -iL subnets.dat | grep "to be up" | awk '{print \$2}' "
echo ""

# write all hosts to file, but print only hosts that appear to be up.
nmap -sP -R -iL subnets.dat -oN $OUTFILE | grep "to be up" | awk '{print $2}'

Of course this output can always be redirected to a file, if desired. The output file "hosts_scanned.dat" will contain any host nmap found in DNS, and whether it was up or down.

Sample output after grep and awk:

Notice that I use awk to print the second field. That's because some entries might have an IP address, but not a DNS entry. So the second field is whatever comes after Host, which is either an IP address, or a hostname. In this case, I want to find any IP's without hostnames, so I can fix DNS, but you may want to just keep the ip in the list,so you can ssh to it later.

To get rid of the parenthesis, I redirected the output to hosts_up.dat, and piped the output to grep and awk to illustrate:

cat hosts_up.dat | grep \( | awk -F[\(\)] '{print $2}

More detail on these commands will be posted on