Lojic Technologies

Posts Tagged ‘linux

Sticking With Linux For Server Deployments

leave a comment »

I recently considered switching my server deployments from Linux to FreeBSD. I need to move a number of sites off a dedicated server to either a different dedicated server (less money), or to a vps (much less money). Since I have to go through some pain with switching, I figured now was a good time to try and decide whether I should stick with Linux (Debian/Ubuntu) or move to FreeBSD.

After spending too many hours researching and experimenting (multiple installations of FreeBSD & lots of software built/installed), I’ve decided to stick with Linux for hosting web applications. Here are some advantages for each OS from my perspective.

FreeBSD Advantages

  • A slight performance advantage currently from my research, but this is debatable
  • My primary desktop is Mac OSX which is based on FreeBSD, so I would be able to leverage sysadmin knowledge between my development machine and my hosted machines. This is the same advantage I had when my main development machine was Ubuntu and I hosted apps on Ubuntu. However, OSX doesn’t require much Unix sysadmin knowledge, so this isn’t nearly as important as the analog below.
  • I like the idea of building packages from source, and the ports system does this very nicely.
  • The organization of the OS seems superior to me. The ports system, startup scripts, file locations, etc.
  • Paul Graham’s server OS of choice (at least for news.ycombinator.com), so I expect Arc will continue to be well supported on it (that is if Arc continues itself)
  • Yahoo & other large sites use it.

Linux Advantages

  • Ubuntu is a much better desktop OS, and I’ve decided to use it on my non-Mac home computers, so I can leverage sysadmin knowledge between my home machines and hosted machines. The desktop installation for Ubuntu 8.04 is unbelievably nice. If I ever become dissatisfied with OSX as my primary desktop, I’ll switch back to Ubuntu in a heartbeat. I just loaded Ubuntu 8.04 on my old 900 MHz AMD w/ 384 MB RAM, and it’s quite responsive.
  • I’ve accumulated more sysadmin knowledge for Linux than for FreeBSD, and supporting two operating systems (OSX / Linux) is more appealing than supporting three.
  • Better virtualization support
  • Linux threading seems to perform better (although FreeBSD has caught up a little)
  • Companies such as slicehost.com support Linux, but not FreeBSD (due to virtualization issues), so this limits my options with FreeBSD
  • Auto power management works out of the box – shutdown the OS and the computer powers down
  • The binary package system is much faster for installations. If I need to get another web server up and running quickly, I can do it much easier with Debian/Ubuntu than with FreeBSD.
  • Google & other large sites use it

The two operating systems seem quite close to me, and it’s possible I’ll make a different decision a year or two down the road, but for now, the cost of switching from Linux to FreeBSD is higher than any expected benefit – particularly since my code rests upon Apache, Mongrel, Ruby, Rails, etc.

I have an emotional bias toward BSD since I started out on SunOS (as far as Unix is concerned), and it seems to have a richer history; however, Debian/Ubuntu seems to be the most practical choice for me at this time.

Even though I ended up sticking with my current server platform, I do feel better about having performed my due diligence rather than continuing with a default, and I have some really great notes for setting up a FreeBSD system should I need to do so in the future 🙂

Written by Brian Adkins

September 8, 2008 at 12:18 am

Posted in software

Tagged with , ,

Ubuntu Linux 8.04 – Wake on LAN

with 3 comments

Now that I’ve switched to a Macbook Pro with OSX Leopard as my primary desktop, I’ve located my Ubuntu machine in another part of the house to be accessible to my children. Not wanting to walk to the room where it’s located just to flip the power switch, I researched how to get “wake on LAN” working, so I could power it up remotely.

1. Enable the appropriate setting in your BIOS. Mine had something to do with wake on PCI device.

2. Install ethtool if you don’t already have it.

sudo apt-get install ethtool
cd /etc/init.d
sudo vim wakeonlanconfig

Add the following lines to that file:

ethtool -s eth0 wol g

Install the script:

sudo update-rc.d -f wakeonlanconfig defaults

Run the script:

sudo /etc/init.d/wakeonlanconfig

3. Keep the network interface alive after shut down.

sudo vim /etc/init.d/halt

Change the following line:

halt -d -f -i $poweroff $hddown

to the following line (i.e. remove the -i)

halt -d -f $poweroff $hddown

4. Get the MAC address

ifconfig | grep HW

5. Send the magic packet via the following Ruby program:

require 'socket'
mac_addr = "x21x53x39xB3x90x42"
s = UDPSocket.new
s.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1)
s.send("xff"*6 + mac_addr*16, Socket::SO_BROADCAST, '', 7)

Written by Brian Adkins

September 3, 2008 at 12:23 am

cmd line history meme

with 2 comments

Aaron tagged me

brian@airstream:~$ history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' |
  sort -rn | head

182 cd
141 ls
55 vim
52 ssh
44 timeclock.rb
29 ruby
28 irb
26 fr
26 cat
24 rake
  1. I’ve made a definite switch to emacs, but vim is still handy for the quick view of a file, and I start emacs in the morning via an icon, and it stays up all day – otherwise, it would be way up on the list.
  2. timeclock.rb is a handly little script to parse/format an emacs timelog file – incredibly nice way to track time on various tasks.
  3. fr is an alias for: find . -regextype posix-extended -regex ”’.*.r(b|html)”’ | xargs grep

Tag. You’re it 🙂

Written by Brian Adkins

April 19, 2008 at 12:41 pm

Posted in communication

Tagged with

Nice Fonts for GNU Emacs on Ubuntu Linux

with 6 comments

UPDATE 12/24/08: This article is now out of date. I just installed Ubuntu 8.10, and getting Emacs with nice fonts is now much easier:

  1. Install the emacs-snapshot-gtk package
  2. Edit ~/.Xresources to have
    Emacs.font: Bitstream Vera Sans Mono-10
  3. xrdb -merge ~/.Xresources

Before discussing how to get nice fonts for emacs, it might be reasonable to ask, “why emacs?” I haven’t fully answered that question myself, but had I not been able to get nice, readable fonts on emacs, I probably wouldn’t continue researching it. For the info on getting nice fonts to work, scroll down to “Nice Fonts” below.

After many years of using large IDEs to develop software, I switched to vim about a year and a half ago when I began developing with Ruby on Rails. Although the learning curve for vim was a bit steep, I quickly got to the point of being more productive with vim than I was with my previous IDE, and I’m continually learning features of vim that save me time and effort.

Ok, if vim is so great, why am I considering emacs? In a word, Lisp. Emacs, has great Lisp support. For the little bit of Lisp dabbling I’ve been doing, vim has been fine, but from what I’ve seen demonstrated with emacs and slime, I think it’s worth researching. Another important factor is that emacs is scripted with elisp, a dialect of Lisp. I’ve never taken the time to read up on vim scripting, but scripting emacs with elisp seems easy. Type in some elisp code into the scratch buffer, evaluate it, and it’s integrated immediately into emacs. I haven’t written any vim scripts in a year and a half, but within a few hours of researching emacs, I had implemented several elisp scripts (from source obtained online).

Here’s one to simulate the % command in vim which moves the cursor to the matching paren:

(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert %."
  (interactive "p")
  (cond ((looking-at "s(") (forward-list 1) (backward-char 1))
	((looking-at "s)") (forward-char 1) (backward-list 1))
        (t (self-insert-command (or arg 1)))))

(global-set-key "%" 'match-paren)

Here’s one to simulate the vim o and O commands which open a new line either below or above the cursor and position the cursor properly indented, so you can start typing immediately. I use this quite often in vim:

(defun bja-open-line-below ()
  (open-line 1)
  (next-line 1)

(global-set-key [?C-o] 'bja-open-line-below)

(defun bja-open-line-above ()
  (open-line 1)

(global-set-key [?M-o] 'bja-open-line-above)

After my brief exposure to emacs, I think vim is more concise. In other words, it appears that vim can accomplish a given task with fewer keystrokes than emacs. I’m curious to see how hard it is to extend emacs to have some of the niceties I’m used to with vim. Maybe I can have the best of both worlds – the conciseness of vim and the extensibility and Lisp support of emacs. Lennart Borgman passed on a link to vimpulse.el, so I’ll take a look at it soon.

I swapped my caps-lock with my left control key a long time ago, so the emacs chording isn’t quite as much of a problem, but I still wonder if vim might be easier on the hands/wrists since it requires very little chording.

I know some famous lispers use vi(m) for Lisp development, so I don’t think emacs is a must-have. Also, if I end up using a commercial Lisp such as Lispworks or Allegro, I may consider returning to an IDE for lisp development. So, at this stage, I’m still very much a vim user who is researching emacs.

UPDATE:Well, sometime between the original post and now I became a die-hard GNU Emacs user, so I figured I’d update the post 🙂

Nice Fonts

But enough of that, how do you get nice fonts on emacs? I had heard that the new version of emacs (22) provided anti-aliased fonts, but apparently I was mistaken. I spent hours Googling and rebuilding emacs to no avail – quite a frustrating experience. Then I posted a question on the gnu.emacs.help usenet group and received a helpful reply in a few minutes which did the trick. Here’s the thread.

Here’s what I did:

cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co emacs
cd emacs
./configure --enable-font-backend --with-gif=no
make bootstrap
sudo make install

After that, I was able to use the ‘Bitstream Vera Sans Mono-10’ font, and it looks great!

emacs -r -fn "Bitstream Vera Sans Mono-10"

The -r flag is for reverse video. I much prefer a black background. After making emacs from the cvs sources, it reports its version as

After editing my ~/.Xresources file to have the following line:

Emacs.font: Bitstream Vera Sans Mono-10

And running the command:

xrdb -merge ~/.Xresources

Emacs automatically uses that font at startup.

During my hours of Googling, I had seen the page with the correct information here. But in my haste, I read the statement, “Note: Since the emacs-unicode-2 branch which had the xft support is merged into trunk, the current page is obsolete.“, and somehow got the impression that the entire page was obsolete, but apparently that is not the case.*

Fortunately, the helpful folks on gnu.emacs.help set me straight – thanks guys!

*UPDATE: I edited the wiki page referenced above, so the “obsolete” notice is further down the page.

Written by Brian Adkins

February 7, 2008 at 11:13 am

Posted in software

Tagged with , , ,

Bug Labs

leave a comment »

This is one of the coolest ideas I’ve seen in a while. Bug Labs is developing some technology that should be very interesting to any geek. Another great find by Robert Scoble. The video quality isn’t high because they were recorded on his cell phone, but I’m glad he had a video capable cell phone with him when he bumped into Peter.

Part One
Part Two
Part Three


Written by Brian Adkins

December 1, 2007 at 1:16 pm

Posted in technology, video

Tagged with ,

VMWare Workstation on Ubuntu 7.04

with 9 comments

After upgrading my Ubuntu installation from 6.10 to 7.04, vmware workstation stopped working. I downloaded the latest VMWare 5.5.4 with no improvement. Then I found this article which fixed the problem in a few seconds!

Just in case the article goes away, I’ll post the instructions here as well:

From the vmware-distrib directory, do the following:

# cd lib/modules/source/
# cp vmmon.tar vmmon.tar.bck
# tar -xvf vmmon.tar
# vim vmmon-only/include/compat_kernel.h

Change the line with:

static inline _syscall1(int, compat_exit, int, exit_code);


/* static inline _syscall1(int, compat_exit, int, exit_code); */

Tar the directory to vmmon.tar:

# chmod 755 vmmon.tar
# tar -cvf vmmon.tar vmmon-only

Finally, go back to vmware distrib directory:

# cd ../../../


# sudo ./vmware-install.pl

The error messages that indicate the problem for which this fix should work are as follows:

Using 2.6.x kernel build system.
make: Entering directory `/tmp/vmware-config1/vmmon-only'
make -C /usr/src/linux-headers-2.6.20-15-386/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.20-15-386'
CC [M] /tmp/vmware-config1/vmmon-only/linux/driver.o
In file included from /tmp/vmware-config1/vmmon-only/linux/driver.c:80:
/tmp/vmware-config1/vmmon-only/./include/compat_kernel.h:21: error: expected declaration specifiers or ‘...’ before ‘compat_exit’
/tmp/vmware-config1/vmmon-only/./include/compat_kernel.h:21: error: expected declaration specifiers or ‘...’ before ‘exit_code’
/tmp/vmware-config1/vmmon-only/./include/compat_kernel.h:21: warning: type defaults to ‘int’ in declaration of ‘_syscall1’
make[2]: *** [/tmp/vmware-config1/vmmon-only/linux/driver.o] Error 1
make[1]: *** [_module_/tmp/vmware-config1/vmmon-only] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.20-15-386'
make: *** [vmmon.ko] Error 2
make: Leaving directory `/tmp/vmware-config1/vmmon-only'
Unable to build the vmmon module.

For more information on how to troubleshoot module-related problems, please
visit our Web site at "http://www.vmware.com/download/modules/modules.html" and

Execution aborted.

Written by Brian Adkins

May 25, 2007 at 3:52 pm

Posted in software

Tagged with , ,

Etch is here

leave a comment »

Wow, debian.org has finally released version 4.0 (“etch”). debian is an awesome linux distribution for servers, but 3.1 has some rather old packages. In particular, I need Apache 2.2 for mod_proxy_balancer, so I installed Ubuntu 6.10 server on my last server to get more recent packages. I expect to use debian 4.0 for future server installs.

I found out about this from distrowatch.com and there’s a blurb on slashdot.org about it.

Written by Brian Adkins

April 8, 2007 at 11:36 pm

Posted in software

Tagged with , ,