Installing Mercurial on Linux

Update: I’ve updated this post to focus on the steps to take in order to get mercurial working on your system, and some rough guidelines.

To install, use your installation/package manager. In Ubuntu, run:

sudo apt-get install mercurial

Now you need to set permissions. Inside your home directory, ~/, you can set up your “hgrc” (mercurial configuration file) with your username and default email address. Note that you must create and edit this file as the owner of ~/, not as root, because mercurial will only trust files that you created.  So open or create the file ~/.hgrc. Then enter the following lines:


username = My Name <>

with your name and email. Now you should be able to check out and use repositories.

Note that if you get errors about untrusted users (for example, mercurial ignores anything from “untrusted user root”, the only fix may be to edit your systems hgrc file to trust those users. The file is called /etc/mercurial/hgrc and you should add these lines to it:


users = root

Or any other users you wish to trust.

Using Mercurial

I won’t cover how to set up a Mercurial repository, because I didn’t — I just used bitbucket. To start out with a repository located at some url, use cd to navigate to the directory you want to use, then use hg clone to get a copy of a project. For example:

cd ~/my-documents/my-projects/
hg clone

Or wherever it is. Now you’re ready to start developing!  If you create a new file or folder, you must add it to the project:

hg add *

Sending and receiving updates is a two-step process. To finalize all the changes and additions you’ve made, you must commit the changes. To send that final version to the repository, you must push it.

hg commit -m 'Made some changes'
hg push

Conversely, to get the newest version from the repository, you must pull it. To change your working copy to incorporate this new version, you must updateit.

hg pull
hg update

That’s the gist of it.


Seven Reasons I Prefer Linux

We all like rants, right? Especially rants directed mainly against Microsoft (public enemy #1) and/or Apple (public enemy #2)? Of course we do. This is not a list of technical features. It has nothing to do with security or the free software movement. This is just a list of cosmetic, user-friendly features that Linux systems (or at least Ubuntu) get right — and certain big-name OSes get wrong.

1. In-Place Software Updates

With Ubuntu, updating is a piece of cake. There’s a single app, the Update Manager, that pops up with a list of all updates for my system and programs. When I click install, it doesn’t force me to quit any of my applications or (shudder) restart my system. It installs easily and quickly. This is directed at you too, Apple. I have a laptop so I can use it on the go. You think I want to restart my Macbook while I’m trying to take notes or look up directions? There never seems to be a good time to stop everything, quit everything, install, and wait to restart.

And there’s nothing worse than stopping what you’re doing, installing updates, restarting your machine, and immediately seeing this little guy pop up again:

2. Not Having To Babysit: Boot, Shutdowns, Installations

It’s bad enough when you set something to install, click through all the menus, and go take a break, only to come back and find out it’s still waiting for you to confirm that the program can make changes to your computer. What’s worse is when you have to remember to sit and watch your computer screen while it’s booting, in case it decides to try to “recover a drive – press a button to cancel”. (And what does that even mean?) Equally annoying is when you think you’ve shut your computer down, only to find out that it’s “Installing Important Updates (2 of 23)”. On Linux, when you start up the computer, it starts up. When you shut it down, it shuts down. When you hit install, the program is installed.

Also in this category: interruptions. Having some window pop up while you’re trying to watch a movie or edit a file can be anything from annoying (watching a movie, browsing reddit) to disastrous (giving a presentation, accidentally hitting the wrong button as it appears). It’s just a dumb idea, and Linux doesn’t do it.

3. Software is Free and Easy to Install

Ubuntu really shines here. If I need an application, it’s one click to the Ubuntu Software Center, a quick search, and then one more click to download and install. If the program I need is slightly more obscure, I can go to the command line and type “sudo apt-get install software“. Installed and done. Doesn’t ask me “Where do you want to save this file?” Doesn’t make me unzip, run the installer, select a directory, and configure options. Doesn’t make me restart my computer. One step.

4. Doesn’t Ask Me Dumb Questions

This goes along with the “allow this program to make changes to your computer” thing. For example, when I connect to my school’s wireless network, I don’t want to bother classifying it as Home, Public, or Work. In fact, I consider myself a moderately advanced user and I don’t even know the difference, much less care. This passes the level of minor annoyance when Windows recognizes the same network four times in a row as “Wifi 2”, “Wifi 3”, etc and presents me with a popup for each one repeatedly.

Similarly, I already know that my application is a “program you downloaded from the Internet” and yes, I’m “sure that you want to run it”. There’s probably a way to turn off all these idiotic questions and notifications, except…

5. Rational, Consistent Organization

If I want to change a system setting on Linux, I don’t need to have ever done it before. The menus and applications are organized logically (and everything is an application, so system settings are organized cleanly next to everything else).

On Windows, things aren’t so clear. I know I probably have to go into the Control Panel, but beyond that…. For instance, did you know that display settings are under “Hardware and Sound”, but disk partitioning is under “System and Security”? Who’d have guessed?

Meanwhile, folder setup and navigation are obfuscated in Windows, but consistent and logical in Linux. On Windows 7, if I download a pdf from my browser and just hit “save” without looking, it’ll take me 5 minutes of shuffling through folders and hierarchies to have a clue where it was saved. (C:\Windows\Downloaded Program Files? C:\ProgramData? C:\Users\myname\Downloads?) Plus, there are places (like the Control Panel) that can’t even be accessed from Windows Explorer. On Linux, it’s pretty clear where things belong, or at least it’s possible to narrow it down.

And the little things. I’m navigating through Windows Explorer, and I want to get the properties of the current folder. Turns out, that’s in the “Organize” menu. What? And here’s the one that made me decide to write this post: When I found myself googling the phrase “how to eject an external hard drive in windows 7.” No, I could not figure out how to do it on my own. This may be because I’m stupid, but stupid people use computers too; interfaces should be designed to be intuitive. It’s not hard to figure out how to hit the eject button in Ubuntu.

6. Sometimes, Windows is Just … Aaaargh

I don’t even know how to classify some of these. But let’s say I want to create my own wireless network. Here’s what happens to me in Windows 7. Hit the Network icon at the bottom right. Click on “Open Network and Sharing Center.” Click “Set up a new connection or network.” I’m faced with several odd options, but I’m pretty sure I want “Set up a new network (configure a new router or access point)”. Click it, hit next. It tells me to wait up to 90 seconds while it searches for unconfigured devices. Hmmm. Nothing appears. Nevermind, go back. Scroll down. Oh, ok: Click “Set up a wireless ad-hoc (computer-to-computer) network”. Hit next. Type a name, select “No authentication”, and hit next. Done! That’s 6 clicks (not counting where I messed up).

Ubuntu: Click on the little wireless icon. In the dropdown, select Create New Wireless Network. Type a name and hit Create. 2 clicks.

What about setting up sharing of files between computers? In Ubuntu, I right click on a folder and select “Sharing Options”. (It’s also not hard to figure out on a Mac.) On Windows, I try the same thing, but am stopped short — they want me to join a “Homegroup”? What is this, a network system designed by George Bush? “To create or join a homegroup, your computer’s network connection must be set to Home.” Thanks for the information, but I have no idea what you’re talking about. The options it gives me to click on are “What is a network location?”, “Tell me more about homegroups”, “Change advanced sharing settings…”, or “Start the HomeGroup troubleshooter”. None of these things is what I want to do (I want to share my files and folders). Sigh and give up.

7. Hack and Customize … At Your Own Pace

Linux is known, perhaps, for users coding their own scripts — the implication being that you need to be fluent in bash to install a Linux distro. In fact, especially with user-friendly distributions, you don’t need to know a thing about the command line. And anything you do end up needing to learn, you can pick up along the way, one step at a time. “Type ‘make install’ … hmm, I guess I can do that.” “Use ‘ls’ to find out the contents of a directory. Ok, let me try it.”

But once you start learning, you can find more and more useful things to do on the command line. If you want, you can learn to write scripts and so on. (If you don’t care to, you don’t have to.) The more you use it, the more you learn about your computer and how to get more out of it. You feel like you’re in charge of the computer, because you know your way around. In Windows, I always felt like I was poking around a few well-lit paths, while most of the system was dark “computer space” that belonged to the operating system and I had no place being there.


Question: How did Windows get the reputation of being for non-computer-savvy novices while Linux is supposedly for advanced users only? Holy Crap! No wonder people think computers are so complicated — they’ve been using Windows this whole time!

If you’re on Windows, and think that computers are complicated, tedious, and annoying, do yourself a favor and try out Ubuntu. (It’s easy — download Ubuntu to a CD or USB stick, then boot from it. You’ll be able to try out the OS without having to install it.)

Really, Macs score highly in these categories as well. Young, trendy Apple fans might hate me for saying this, but if you know someone older who has trouble with computers, do both of you a favor and get them a Mac. It’s so much simpler, won’t ask them confusing questions, and has great support.

But for general uses (except for specific programs and games that work only on Windows), I’m sticking to Linux from here on out. And I really think the average Windows user would be amazed at how much simpler it is.


After originally publishing this article, I’m just going to keep adding brief bullet points as they occur.

  • Memory footprint on the hard drive. As a general rule, my Ubuntu install takes around 1/10th the hard drive space of Windows to do the same task (better).

Dual-Boot Windows 7 and Linux (Ubuntu)

For today, a quick (but hopefully thorough) walkthrough on how to dual-boot Windows 7 and a Linux distribution. Whether you’re starting from a clean machine or an existing Windows 7 computer, desktop or laptop, these general instructions should work for you. Note that this is just one way to do it. Also, others may recommend some changes or tweaks to this approach. But it should be useful if you’d like an example of how to set up a dual-boot system. (Disclaimer: I’m not responsible for anything at all, ever. Try this at your own risk. BACK UP YOUR DATA FIRST!)

I’ve done this on a home-built, clean desktop, and on a Lenovo x220 laptop where I kept the existing Windows 7 install. So I will draw on these as examples. Both times, I installed Ubuntu, which is commonly known as a user-friendly distribution of Linux that is good for first-timers. These instructions, however, should work in general.

What you’ll need: A computer, a way to back up your data, some disks/USB drives for installation. You’ll also need to be willing to Google some things if you haven’t done them before — in the interests of brevity, I won’t explain how to click through each menu or every step in detail. If you’re stuck on a part, leave a comment and I’ll try to explain; there are also lots of resources out there on the web! Finally, expect to do a little troubleshooting after installation to get Windows and Linux to work together with your Data partition, etc. It may take a bit of setup work, but should be worth it!

Before we head out onto the field, here’s the general game plan. We’re going to create three main partitions: one with our Windows 7 installation, programs, etc; one with our Linux installation, applications, etc; and one for all of our data. The two operating systems will both be able to access the data partition, so they can both read and write to the same folders and files.

Ready? Let’s go.

Step 1: Back Up Your Data/Computer

If you have any data stored on your computer, you need to back it up first. You should hopefully already have an external hard drive or some other backup method; if not, get one!

You’ll also want a way to reinstall Windows 7 if it’s pre-installed. (You may not end up using it, if you are able to simply “shrink” the Windows 7 install, but you will want it down the road if your computer crashes.) My laptop, for example, had an option of creating backup disks which could be used to return it to its factory state if something went wrong. I used this feature to create a backup on a 16 GB USB drive.

Step 2: Get Install Disks/USB

If you already have Windows 7 installed, you may be able to shrink the install to fit its partition without needing to reinstall Windows. If you want to reinstall Windows or have not yet installed it, you’ll need a Windows install CD or some other bootable device, like a USB drive, that allows you to install Windows 7.

You’ll also need a bootable CD or USB drive for your Linux distribution (I created mine using Ideally, it would come with the application GParted, which we will use to partition our hard drive. If not, you’ll need a bootable drive that does. (Worst-case scenario: create a bootable Ubuntu CD, use it in Step 3 to use GParted, then get rid of it and use your favorite Linux distro when it’s time to install.)

Step 3: Partition

Now we’re going to partition the hard drive. First, let’s figure out how many gigs each partition will need. Remember, all of our data (documents, music, everything) will go in the Data partition. But programs and applications will go in the partitions of the respective hard drives. Modern video games, for example, take up a lot of space.

  • Windows partition. Windows 7 alone is over 20 GB, so 30 GB is probably a bare minimum. I recommend at least 40 GB, possibly much more if you expect to install large programs.
  • Linux partition. The memory used varies by distribution but is very likely under 5 gigs. Add in the programs you’re running and 10 GB is probably a bare minimum, but I’ll recommend at least 20. If you have a large hard drive, it probably can’t hurt to leave extra space on these.
  • Data partition. This will be all the space that you have left.

Now, it’s time to actually make the partitions. First, a quick primer on partitions. Partitions are ways to divide up your hard drive. You can split a hard drive into partitions of two types: primary partitions and extended partitions. A primary partition is a chunk of the hard drive, plain and simple. And extended partition is also a chunk of the hard drive space, but an extended partition must itself be partitioned up into one or more separate chunks. These sub-chunks are called logical partitions.

You may only have up to four total primary/extended partitions on your hard drive. However, you can subdivide an extended partition into a number of logical partitions, enabling you to sidestep this limit.

Now, insert your Linux boot media (CD or USB drive) that has GParted on it. Shut down the computer. We will need to boot from the media. To do so, you may have to go into your BIOS menu and change the boot order. For my laptop, I was able to press F12 on startup, giving me an option of which device I wanted to boot from.

Once it’s booted up, find and run the program GParted. (Note: GParted asks you to select sizes in terms of megabytes, but here we’ll mainly be talking in terms of gigabytes. So be aware of the conversion!)

If You Already Have Windows Installed

Your disk will have a small partition at the very beginning (created by Windows for booting and/or system recovery; we don’t have to worry about it), then the rest of the drive is your Windows installation. (You may also have another partition at the end; my laptop, for instance, has a ~10GB partition at the end of the hard drive containing system recovery tools. If so, leave that one alone as well.)

The large Windows install is the partition we want to shrink. (It is a primary partition.) Click on it and select “Shrink Partition.” Hopefully, you will be able to shrink it to the size you want. If not, you may have too much data or it may be too fragmented. You can try defragmenting the drive and coming back to this step, or you can format this partition, erasing Windows. If you end up formatting the partition, follow the instructions for not having Windows installed. If you did shrink the Windows install successfully, you can skip to the section “Create Linux and Data Partitions”.

If You Don’t Already Have Windows Installed

It’s always nice to start from a clean slate. If there are any partitions on your hard drive, use GParted to delete them. Then create a primary partition at the beginning of the drive for Windows 7. Make it the size you decided on above and format it as ntfs. Then move on to the next step.

Create Linux and Data Partitions

Now, we’ll take the remaining space (located after our Windows partition) and allocate it as one big extended partition; then, we’ll divide it up into logical partitions for Linux and for our data.

In GParted, select the space after the Windows partition and choose to create an extended partition. Now we’re ready to create logical partitions within that big extended partition.

First, we’ll create what’s called the “swap”. Basically, this is space on the hard drive that Linux uses as extra RAM if your RAM is used up. If you don’t know about swap space, I recommend making your swap partition the same size as your RAM (if you have 4 GB of RAM, you can make the swap partition 4 GB). To create it, select the extended partition and create a new logical partition of the appropriate size. Format this partition as “swap” or “linux-swap”.

After that (but still within our extended partition), we’ll create a logical partition to hold our Linux operating system. Do so in the area after the swap space, within the extended partition. Format this as ext4, which is a standard format for Linux.

Use the remaining space in the extended partition to create a logical partition for Data. We’ll format this as ntfs, so that Windows and Linux can both read/write to it. Once that’s done, we’re done creating partitions and ready to install!

Step 4: Install Windows (if not already installed)

If you don’t have Windows installed, we need to install Windows first. Boot from the Windows CD (or USB drive if you have it on that disk image) and do a fresh install. Make sure to install it onto the partition you created specifically for Windows.

Step 5: Install Linux Distro

To install Linux, boot from your Linux installation media. You’ll want to do an advanced install (in Ubuntu, select the “Manually specify partitions” option). You will choose which partitions to use for installation. There are two partitions to worry about in this step. Set your swap area as “swap”. (Duh.) Set your Linux area (located right after your swap) as /. This is where the Linux install will go. For mount point, choose the entire device (probably called “/dev/sda”).

Now you should be able to go ahead with the installation!

Interlude: Working Machine

You should now have a fully functioning dual-boot system! When you start up the computer, your Linux boot manager screen should come up, allowing you to manually select which operating system to boot, or selecting Linux after a few seconds of inactivity. You can boot each OS to make sure they were installed correctly. Then, let’s finish the job with Step 6.

Step 6: Configure Each OS to use Data Partition

We’ll start with Linux, since it can be a bit trickier. What we want is for Linux to automatically mount the Data partition upon startup, and we want to be able to read and write the partition. In Ubuntu, I was able to successfully do so by following instructions from I will list the steps below; note that your mileage may vary on other versions of Linux.

First, you need to know the name of the Data partition. For example, mine was called /dev/sda7. You can figure it out with GParted, or by opening a Terminal and running “sudo fdisk -l”.

Now, we’ll make a folder to be the mount point for the partition. (“Mounting” the partition just means loading it up so the system can access the partition.) When the partition is mounted, it will appear in this folder. For this step, I created a folder named “Data” in the /media folder, since /media is where drives are usually mounted. To do this from the Terminal, you can run “sudo mkdir /media/Data”.

Now we need to change how the drive is loaded on startup. The file that controls this is called fstab and is located in the /etc folder. First, you should create a backup copy of fstab in case you mess something up. You can do that on the command line by running “sudo cp /etc/fstab /etc/fstab-backup.bak”. This copies fstab into a file named fstab-backup.bak.

To edit fstab, we can open it up in Gedit (a text editor): “sudo gedit /etc/fstab”.

There will be one or two lines describing how to load up your Data partition. For example, if it is called /dev/sda7, you might have a line that looks like:

/dev/sda7  auto nouser,atime,noauto,rw,nodev,noexec,nosuid 0 0

Comment it out by placing a # at the beginning of the line (if there are two, comment both out):

#/dev/sda7  auto nouser,atime,noauto,rw,nodev,noexec,nosuid 0 0

Now, we will add a line that mounts the partition to our chosen folder with read/write permissions. Add the line:

/dev/sda7 /media/Data ntfs-3g quiet,defaults,rw 0 0

where /dev/sda7 is the name of your Data partition and /media/Data is the folder where you’d like it to mount.

Now, reboot your system and boot back into Linux. The Data partition should be mounted and you should be able to read and write to it. To test it out, you can navigate to /media/Data (or wherever your mount point is) and create some folders. I personally put the following folders in my Data space: Documents, Media, Other, Temp, and Trash.

Last thing on Linux. On a normal Linux install, your own personal files are stored in “/home/username/”, where username is, well, your user name. To make things easier, we can make links (shortcuts) from inside this folder to our Data. I created a link to each of the above folders: Documents, Media, Other, Temp, and Trash.

Now, reboot into Windows. Windows should automatically mount the Data partition as a drive (on my system, it is D:\). You should be able to open it and see any folders and files you created on Linux. To finish things off, I recommend making similar shortcuts on Windows: In your C:\Users\username folder, delete the “Documents”-style folders and replace them with shortcuts pointing to D:\Documents and so on. You can also drag these folders into your Favorites and Library bars in Windows Explorer (on the left side) for easy access.


I hope these instructions were clear and worked well. If not, let me know!

Set up Lisp on your Linux or Mac – Easily!

Note: This post is now 1.5 years old. It uses OS X 10.4, and so may be out of date :(

Common Lisp for Common Folk

Many people in the CS community might associate Lisp with a certain snobbishness or air of superiority.

This has nothing to do with the supposed “power” or “versatility” of the language, nor does it relate to “parse trees”, “macros”, and “code=data”.  No, the actual reason that Lisp is placed so high above the rest of us is that you have to be a Lisp-hacker just to figure out how to install Lisp on your computer.

So: Here are the simple steps required to install and use Common Lisp, spelled out for those of us who aren’t already Lisp-fluent. Continue reading