Friday, July 31, 2009

Fix QoS in Untangle 6.2

The latest version of Untangle, version 6.2, has a bug in QoS that prevents it from retaining changes made to the upload and download speeds of the external network connection. This is a debilitating bug because it will limit your connection to 1.5Mb/s in each direction if you use QoS. Luckily, there is a fix for the bug that has worked great for me so far. Run this command:
# curl | dash
This will download and run a script, which will in turn download an archive, extract it, install its contents to their correct locations, and finally restart the necessary daemon. Its quick, easy, official, and it works.

Send mail from the terminal in Untangle

Untangle routers are already configured to send out emails for use with the Reports module. However, Untangle is still a Linux machine. It happens to be based on Debian. If you want to send out email messages for you own purposes, you can do so from the command line. The syntax looks like this:
$ echo "This is my message" | mail -s "Subject"
This would send an email to that has a subject of "Subject" and a body of "This is my message". Specifying a subject is optional.

Convert .cdr to .iso in OS X

Macs have a lot of build in features, including images of disks with the bundled Disk Utility application. Unfortunately, the format that Macs create disk images in for CDs and DVDs has a .cdr file extension. The most common file formats for CDs and DVDs is .iso and sometimes .img is used. The .cdr images that Macs create are burnable images, but if you want to create an image to a more common format, here is how you do it:
$ hdiutil makehybrid -iso -joliet -o [filename].iso [filename].cdr
This method does require that you first create the .cdr image.

Untangle for a Linux router

Looking for an awesome solution for a home or small business router that packs lots of features? Check out Untangle. I have been using it at work and its great. The install process is super easy and all of the configuration is done through a wonderful web interface. There are also a bunch of modules you can download from the web interface that do things like block spam, viruses, questionable web content, or do things like generate daily reports of bandwidth usage. There are some for pay modules too that do more things.

For the record, no one is paying me in anyway to spout praises for Untangle.

Wednesday, July 29, 2009

Install sSMTP in CentOS

In my last post I wrote about how to send email from the Linux command line using sSMTP and how to install it in Ubuntu. sSMTP is included in the repositories for a lot of distributions, but not for CentOS. Luckily, its easy to grab and install it from a Fedora repository. First, become root, then run these commands:
# rpm -Uvh
# yum -y install ssmtp
That's it, now sSMTP is installed and ready to configure just like I detailed in this post.

Wednesday, July 22, 2009

Send email from a Linux shell

Most of us only send email to other people and use either a desktop client or some form of webmail. For those who are so inclined, sending an email from the command line in Linux is also relatively easy. First, you will need to install ssmtp. In Ubuntu, run this command:
sudo aptitude install ssmtp
If you are using a different distribution it may exist in your repositories already or you may have to add a new one. You will need to make some changes to the default config file. Make a backup of the original file in case you want to revert back to it:
sudo cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig
When I set this up, I created a Gmail account so that I could keep track of the emails sent conveniently if I want. To set it up to use a Gmail account, edit the config file so that these lines are present:
root=[your address]
AuthUser=[your address]
Now any message you send will come from [your address] and you can see what messages have been sent by logging into that Gmail account. This is the easiest way I have found to send a message:
echo -e "Subject: [some subject]\n\n[the body goes here]\n[second line of body]\n" | ssmtp [address to send to]
So, for example, to send a message with a subject of "This weekend" and a body of "Want to get dinner friday? Call me." to, you would type this:
echo -e "Subject: This weekend\n\nWant to get dinner friday? Call me.\n" | ssmtp
The -e flag on echo tells it to look for backslash escape characters. This means that everywhere there is a "\n" it will become a new line. Also, notice that there is an extra line between the subject and the body.

So why is this useful? This is useful to send yourself notifications from the system. For example, you might have a cron script that runs every so often and you want a notification whenever it finishes successfully. Another example I saw during my research was to add a line to "/root/.bashrc". That will send out a message whenever someone logs in as root to the system.

You can also have it send text messages to your phone. To do so, just send an email to the corresponding address for the service provider:

Tuesday, July 14, 2009

Manually set screen resolution in Linux

With most modern Linux distributions, graphics support is pretty good. That being said, I recently configured a Linux workstation running Ubuntu 9.04 that has an old graphics card and a crappy graphics driver. I was unable to get desktop effects to work and had to set my desired screen resolution manually. This is not as difficult as it may sound. First, make a backup of the configuration file:
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.orig
Now, open the file. Find the section called "Screen". It should look something like this:
Section "Screen"
Identifier "Default Screen"
Monitor "Standard skjerm"
Device "Configured Video Device"
DefaultDepth 24
You need to add a subsection which contains the desired screen resolution. It should look something like this when you're done:
Section "Screen"
Identifier "Default Screen"
Monitor "Standard skjerm"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Modes "1280x1024"
Make sure you specify the resolution you actually want where is says "1280x1024". You will need to restart X in order for the changes to take effect. You can restart it by logging out and back in.

Friday, July 3, 2009

Set a static IP in CentOS/RHEL

A few weeks ago I wrote about how to set a static IP address in Ubuntu and now I am posting about how to do it in CentOS/RHEL. Unlike in Ubuntu, in CentOS, there is a separate config file for each network adapter. These files are located in "/etc/sysconfig/network-scripts/". So, for example, the config file for interface "eth0" is located at "/etc/sysconfig/network-scripts/ifcfg-eth0". If the adapter is configured to use DHCP, the contents of the file should look something like this:
# [Name of manufacturer and model of network adapter]
To convert this over to using a static IP address instead, you will need to make some changes and add a bunch of information so that it looks more like this:
# [Name of manufacturer and model of network adapter]
This assumes you are setting the interface to use an IP address of and a default gateway of In order for the changes to take effect you will need to restart the networking daemon. This is accomplished by running either of the following commands as root:
/etc/init.d/network restart
service network restart
When the interface comes back online it will use the newly configured settings.

Customize the Dock location in OS X

In Mac OS X, the Dock is by default located at the bottom of the screen. It is anchored to the center and will expand evenly to the left and right as applications are opened and will shrink back toward the center as they are closed. Under the Dock preference pane is System Preferences the Dock's location can be changed so that it is attached to either the left or right side of the screen. The Dock's location can, however, be customized even further by pinning it to one of the corners of the screen.

Run this command at the Terminal to see the current pinning location:
defaults read pinning
The default value for this is "middle". The other options are "start" and "end". "Start" will pin the Dock to the left corner of the screen if it is located at the bottom or to the top corner if the Dock is located on either side. "End" will pin the Dock to the right corner of the screen if it is located at the bottom or to the bottom corner if the Dock is located on either side. To change the pinning location, run this command:
defaults write pinning [value]
For the changes to take effect you will need to restart the Dock:
killall Dock
The Dock will restart on its own and when it does it will have moved according to your newly specified location.

Wednesday, July 1, 2009

Script SSH commands

Anyone who has ever done Linux or Unix scripting has probably run across the problem of sending commands to a remote host inside a script. Well it turns out the trick to accomplishing this is to append the commands as a string at the end of the SSH connection command, like this:
ssh [user]@[server] "[command]"
For example, if you wanted to connect to a server at with the username "james" and list the contents of that user's home directory, you would use this syntax:
ssh james@ "ls ~/"
You can also chain multiple commands together. For example, if you wanted to list the contents of the home directory and print the contents all all files with the ".txt" extension, it would look like this:
ssh james@ "ls ~/ ; cat *.txt"
This can also be used to execute scripts on the server. For example, if you wanted to send a script to the server and then run it, you would enter these commands:
scp james@
ssh james@ "chmod +x ~/ ; ~/"

Disable GUI in CentOS/RHEL

The default installation of CentOS includes the GNOME GUI desktop environment. During installation you can choose to not install this, but lets just say that you wanted to install the GUI along with the rest of the system. Now you have a CentOS server configured the way you want it and the GUI really doesn't need to be running most of the time. A GUI uses system resources that could be going somewhere else and also makes the system more vulnerable to attack since there are more processes running.

If you want to prevent the GUI from loading but want the rest of the system to load as usual, you need to make a change to "/etc/inittab". Make a backup copy of the file first:
cp /etc/inittab /etc/inittab.orig
Now assume superuser priviledges and open "/etc/inittab". Locate the line that looks like this:
This is the line that defines the default runlevel. Runlevel 5 is multiuser mode with the GUI. Change this to read:
The only change is the the 5 is now a 3. This corresponds to multiuser mode without the GUI. Now just restart and the system will boot to runlevel 3 instead of 5. To check the current runlevel, run this command:
Once you have done this and you decide you want to use the GUI, log in and run this command to start it:
This, however, will only last until you reboot next. After that the GUI will not load. To set the machine so that the GUI does load automatically, just restore your backup or "/etc/inittab" or edit the line you changed earlier and change the number back to a 5.