kdmurray.blog

Personal Weblog of Keith Murray

kdmurray.blog - Personal Weblog of Keith Murray

The Winding Road of Procrastination

I sat down tonight to do some more learning about Ruby. I thought that I’d spend an hour or so and build something trivial, but useful. Well 90 minutes later and I have had an enjoyable evening, but I have yet to write a single line of Ruby code.

It started out with a Ruby tutorial which had a header on the first line with the standard directive pointing to the executable for the Ruby interpreter. That led me to realize I wasn’t 100% sure where that executable was on a Mac. I remembered that there was some kind of command to find these exectuables so off I went to Google. My search results led mt to a Perl primer describing the use of the which command.

Having used the which command on my Mac and finding that it gave me exactly what I was looking for, the next logical step would be to continue with the tutorial. Unfortunately, that’s not how my brain works. The next logical step for me was to put together a short blog post on the which command so that I would have a reference for myself at some future date.

Writing the blog post sent me to my terminal to test out the which command on my Ubuntu and CentOS machines to make sure it was a cross-platform as I thought. Research for the blog post also sent me to some documentation for which that I wanted to link in my article.

After posting the article I realized that the Markdown-to-HTML engine on my blog had converted the #!/usr/bin/ruby line in my blog post to a header because of the hash mark. This sent me in search of Markdown documentation which I found on the Markdown syntax page on Daring Fireball. I of course had to take a moment and peruse the DF site while I was there and found a reference to a recent episode of his podcast The Talk Show being sponsored by The Magazine.

Remembering that I had just subscribed to The Magazine earlier in the evening I picked up my iPhone to peruse the article titles and found that one was an update about The Magazine itself. Reading through that short update from Marco and that he had received tons of submissions for new article pitches reminded me that I had an article of my own to pitch. I fired up my email client and sent the pitch email off.

Remembering that I hadn’t yet fixed my typo I jumped back to my blog to correct the error. Glancing at my browser sidebar I looked at all the open tabs, then up at the clock and realized it had been over an hour since I had intended to write some Ruby code. Thinking back over the activities of the past hour I realized that an article about procrastination might have made an even better pitch. So I wrote this up and am going to send that in right now.

Ubuntu School – which: Finding Ruby

I’ve been getting my feet wet with Ruby the past couple of days and decided to post this as much for my own recollection as anything else. When you’re creating a .rb script file the first line (as with nearly all *nix script files) contains a reference to the executable which should be used to execute the script.


#!/usr/bin/ruby

But what if you don’t know precisely where that file lives? The which command will find it for you. Which is a command which provides you the fully qualified path to shell commands, and this includes script hosts like ruby.


callisto:~ kdmurray$ which ruby
/usr/bin/ruby

This also works for Perl, Python and any number of other executables. Ever wonder where the pwd command lives? or nano? or which itself? Go explore! This command works on most *nix operating systems including most Linux OSes and Mac OS X.

Ubuntu School – What Groups Do I Belong To?

This is a quick one.
If you need to figure out what groups your user account belongs to you can simply use the groups command from the command line:


kdmurray@titan:~$ groups
kdmurray adm cdrom sudo dip plugdev sambashare lpadmin debian-transmission smbmedia smbbackups ccnet

You can also use this command to find out what groups any other users belong to. This is particularly useful when setting up new services or new network shares and you need to confirm which groups the user belongs to.


kdmurray@titan:~$ groups ccnet
ccnet : users ccnet

Try to find yourself a use for the groups command this week!

Ubuntu School – Force Ubuntu Server Upgrade

This may be a bit late for anyone who was experiencing the issue at the time, but here’s how I forced my Ubuntu 11.10 server to upgrade to 12.04 LTS right after 12.04 was released. The normal upgrade process doesn’t work because Ubuntu servers don’t like to upgrade to an LTS release until its first point upgrade.

To upgrade from Ubuntu 11.10 on a server system to Ubuntu 12.04 LTS:

1- install the update-manager-core package if it is not already installed:

sudo apt-get install update-manager-core

2- Edit the release upgrades file

sudo nano /etc/update-manager/release-upgrades and set Prompt=normal;

3- Launch the upgrade tool with the command

sudo do-release-upgrade -d

4- follow the on-screen instructions to complete the upgrade. May take 1hr+ depending on bandwidth, machine specs, installed pkgs

The guts of these instructions were taken from The Unixmen who have a much more detailed tutorial with screenshots on their blog.

Better Dropbox Control with Symlinks

One of the things that’s always made me crazy about the way Dropbox behaves on the Mac is the way that it restricts the location of the Dropbox folder. While recent iterations have allowed you to move the folder to a new location, it must still be called “Dropbox” which is annoying because it prevents you from using your entire home folder as your Dropbox keeping all those files in one place. (I know there are a ton of reasons not to do this — not the least of which is the Library folder — but humour me…)

What I had wanted was an easy way to keep portions of my main user folder in Dropbox without compromising the familiar folder layout that we all know and love. The solution came in the form of Symlinks.

Symbolic links are essentially shortcuts to other locations on your computer, or network. In many cases they navigate like folders creating a sort of worm-hole to the other folder location. So what I did was create linked folders from places on my computer to places within my Dropbox folder. The Dropbox client picked up these changes and dutifully synchronized the contents of the linked directories up to my Dropbox account just as if the files were actually in the Dropbox folder.

These commands will create a directory called Miscellaneous in my Documents directory and then link it to Dropbox using the name Misc-Callisto. All other Dropbox clients will see this as a directory called Misc-Callisto and any changes to documents in that cloud folder will be reflected in my ~/Documents/Miscellaneous directory.


mkdir ~/Documents/Miscellaneous
ln -s ~/Documents/Miscellaneous ~/Dropbox/Misc-Callisto

It is also possible to do this synchronization in two directions. If I have my ~/Dropbox/Misc-Callisto directory in my Dropbox, I can create a linked folder to an alternate location on another machine. This is a bit more complicated and can result in lost data if you don’t follow the steps carefully.

  1. Sync up your Dropbox folder
  2. Stop the Dropbox client
  3. Move the directory Misc-Callisto to wherever you want the files to live on your new client.
  4. Rename the directory to whatever you want to call it, in this case ~/Documents/Callisto-Backup/Miscellaneous
  5. Link the folder back to Dropbox using the same name, in this case Misc-Callisto
  6. Restart the Dropbox client

The ln command in step 5 is:


ln -s ~/Documents/Callisto-Backup/Miscellaneous ~/Dropbox/Misc-Callisto

Any changes reflected in either of the local folders will appear in the local folder on the other machine thanks to the wonders of Dropbox and symbolic links.

Note: On recent versions of Windows you can perform the same symlinking behaviour from the command prompt using the mklink command. The following code blocks are the Windows equivalents for the two ln commands above:


mkdir ~DocumentsMiscellaneous
mklink ~DropboxMisc-Callisto ~DocumentsMiscellaneous


mklink ~DropboxMisc-Callisto ~DocumentsCallisto-BackupMiscellaneous

Now go forth and link-up your file system for maximum synchronization!

Going Linux – A Case for Tolerance

This past week I was listening to an episode of one of my favourite Linux podcasts the Going Linux show hosted by Larry Bushey, Tom Chaudoir and Bill Smith. The three of them put together a great show advocating the many fantastic uses of Linux and promoting the idea of Linux as a primary desktop OS, a valid alternative to Microsoft’s Windows and Apple’s Mac OS X. Their show tackles individual technical topics and the hosts also provide answers to listener questions (both on the show and by email) to help new and experienced Linux users alike get the most out of their systems.

One of the elements that provides a unique personality to the show is their sometimes irreverent take on some of the more commercial software offerings. Treating Windows with the Voldemort-like monicker of “W”, and often referencing the relative security track records of Windows and Linux over the past decade help the guys make their point that Linux really is a valid competitor. Unfortunately this pro-Linux stance has started to shift toward an anti-Commercial (particularly anti-Microsoft) stance over the past several months. The pokes and ribbing about Microsoft in general and Windows specifically have started to degenerate into un-focused Windows-bashing and statements which are in many cases either poorly researched or outright false.

Now I realize that I can’t possibly expect three full-time Linux users to have a complete grasp of the current state of Windows — that’s simply not realistic. What I would like to see is a return to a more pro-Linux feel instead of relying on the playground bullying tactics of putting others down to make oneself feel better. And I know this isn’t the kind of thing that the Going Linux hosts are deliberately trying to do because Larry himself pointed out on an episode of the Knightcast late last year that one of the biggest hurdles Linux faces is members of its community trying to use “juvenile tactics” to promote the OS which are reminiscent of “a dirty politics campaign fought by [children]“.

Linux truly has come a long way in the past decade and is no longer simply the domain of tech nerds and computer enthusiasts. It is a valid option for those who can’t or don’t wish to pay for a commercial OS. The Linux community through avenues like the Ubuntu Forums and podcasts like Going Linux and the Knightcast have provided untold numbers of people with tips, tricks and solutions for people trying or moving to Linux. If you’re at all interested in Linux or open-source software you need to listen to both of these shows.

Here’s hoping that we can continue to raise the level of discourse in talking about all of our technical topics, and that all of our computing platforms continue to evolve and push each other to be better for the end users. If we can do that, then everybody wins.

Bad Decisions

As someone who considers himself a technology enthusiast I take pride in my ability to know how best to apply technological solutions to everyday problems. Part of knowing howa to do this is the ability to know what the options are and when to choose which option. Few decisions in technology demonstrate this abundance of options better than the selection process for a new computer.

I have had a MacBook as my primary computer for the past 6 years. In that time, my first Mac has helped me to accomplish a number of goals. It has been my main machine for all of my technological pursuits. Pretty much Avery blog post and podcast episode I’ve produced was conceived of, written recorded and released on that machine. I has travelled with me own dozens of trips and has supported my rather amateurish attempts at being an amateur photographer.

A trend that has persisted for the past decade or so is that the advances in personal computing technology have continued at a faster rate than the increased computing demands of most of the population. 15 years ago it made a lot of sense to spend ore money to get a higher-end computer in hopes that the system woould last you more than a couple of years. Fast-forward to today where most computer users need little more from their system than a means of getting to the Internet, and we see that most mid-to-low range computers could easily serve their users for 4-5 years.

With that philosophy in mind earlier this year I decided to make the leap from a mid-range laptop to a tablet as my main mobile computing platform. Many wolf the tasks at I like to undertake on a mobile device we well within the capabilities of most tablets, and I figured that the light weight and small form factor would make the device much easier to carry around with me. I’ve had the iPad for about three months now. I have tried to incorporate it as a working device, rather than just a content consumption device. I have successfully written a number of blog posts on the device and sent a few emails. But thre are limitations as to how the iPad can be used as a content-creation platform, and the majority of those limitations are a result of the device’s form factor.

Trying to write anythingr fo any length on the iPad is challenging with the on-screen keyboard. The touch screen is very responsive and I can write on it far better than I can write on the iPhone, but there are still 4-5x the number of typos in my work which take time to correct. Autocorrect is both a help and a hindrance when writing on the iOS devices. If you allow it to do its job you can have a number of your mistakes fixed, but if you hit the spacebar instead of the intended letter key you will most likely create a typo that will need to be fixed manually. Writing with a physical keyboard hooked up either via Bluetooth or the Dock. On rector provides better a curry when typing, but requires the user to place the iPad and the keyboard on a flat surface like a desk or a table, greatly reducing the mobility of the device.

After the first month, it became clear that I wasn’t going to be able to replace the laptop n my life with an iPad. It simply didn’t fit my way of working. I was a bit annoyed with myself for not having thought things through and for not hanging figured it out ahead of time, but I soon realized that the iPad had other virtues and it hadnt been a waste. It has been a fantastic content consumption device and has allowed our whole family an alternate avenue to enjoy. Intent that we love when we may not be particularly interested in what someone else has put on the big TV.

So I stepped back and took a look at the options for laptops. The machine that I’ve been using is getting to be a bit slow, and for some of what I want to use it for the two GB memory limit is a bit, well, limiting. my first instinct was to pick p the new MacBook Pro. That’s the model which most closely replaces the old MacBook I won’t get into the reasons behind why I’m sticking to a Mac since they aren’t really material to my point. Based on a number of factors I outlined in a previous post my ad choice of replacement laptop was the MacBook Air. It was plenty powerful for the types of things I typically use the computer for and it was small and light which was a nice change from the rather weighty MacBook White.

It’s Great But…

I was thrilled when the unit arrived and wanted to get it set up as soon as possible. That’s when I discovered my first error. I hadn’t realized that the mini DisplayPort connector on the new machine was something different than the connector on the existing Mac (which I realized later was mini-DVI). I would need an adapter to attach the New computer to my monitor. Looking at the two side-by-side it’s pretty clear that they’re nothing alike.

So I began migrating data over to it the first night. That’s when I realized that I had made my second error. I knew that the new machine’s 128GB solid-state drive would be significantly more cramped than the current 320 GB drive I was using. But I failed to actually check how much data I would want to store on the machine. As it turned out, my Aperture library was larger than the entire SSD drive in the new machine. I bought an external hard drive and was willing to live with the compromise because I did 99% of my photo work at my desk anyway, so I woldn’t need to transport the drive anywhere.

A week or so later I was to have a Skype chat with Dave and Knightwise. I had planned to use the new machine and that’s when I realized that I wouldn’t be ble to record on the new machine — it had no line-in jack. To use my existing podcasting gear I would need to buy a new USB sound device, or a USB mixer. This proved a rather frustrating discovery for me. It was the third time in a week that I had realized that the MacBook Air purchase was not sufficiently thought out. And it was maddening as this is specifically the kind of thing that I talk with people about when they are asking for advice on new systems: what will you use it for?

The Solution

The obvious answer to this is simple: do your homework. I could have realized two of these problems if I would have put a bit more time into looking at the options and precisely how I intended to use the machine. Looking into things more closely the MacBook Pro was clearly a better choice for how I use my computers.

  1. I have a machine that does most of what I need it to do on a day to day basis. Some expiring hardware and lack of ability to run the last two versions of OS X have precipitated the move to a new machine.
  2. I’m a podcaster. I need a line-in port to be able to do that without investing in more podcasting gear. While the lack of that port in and of itself likely wouldn’t push me to one machine or the other, it’s certainly a contributing factor.
  3. External drives are great — and they’re a pain in the ass. Needing to attach an external drive to your computer with any kind of frequency is a good indicator that you don’t have enough on-board storage. I needed an external drive on day 1 with the new MacBook Air.
  4. Expandability breeds longer life. Almost every computer I’ve owned has lasted me longer than 5 years. In many cases hardware upgrades have helped prolong the useful life of these devices. Having the ability to have the memory and hard drive upgraded is something I typically need.

I’m still doing some additional reading and research to make sure I don’t make another bad decision when I bring in a replacement model, but it certainly seems as though I should have ordered the 13″ MacBook Pro to begin with as it fits far more closely with how I do my day-to-day computing.

Maintenance Nerd

There are things that are common to the human experience, things that everyone enjoys. The warmth of friends and family, the simplicity of a home-cooked meal and the smell of a warm and fragrant tropical breeze. Then there are those things that make us different. The one-man’s-trash-is-another-man’s-treasure principle applies not only to worldly goods, but to endeavours as well.

In my family, I’m the cook. Partly because it helps to divide some of the domestic labour, but mainly because I’m the one who actually enjoys cooking. I’ll invest time in breaking down a chicken carcass at 10pm on a Tuesday to make stock for the next day’s soup. I’ll go to the trouble of de-seeding all of the canned whole tomatoes in my pasta sauce just to make it a bit less bitter. In short, cooking is a job I find fun. Where is this going, you may ask? System maintenance. That’s where.

One of the things I’ve discovered about myself over the past decade or so is that I really like the feel of a newly minted OS installation. It doesn’t matter what platform, or whether there’s a GUI or not. There’s just something satisfying about knowing that the computer is in pristine condition. If I count all of the machines at home and at work that I’ve done OS installs on in the past 10 years the number of times I’ve installed an operating system is well into the triple digits. Hell for Windows alone I’m sure the number is over 100.

And it’s not just OS installs. All kinds of maintenance, setup, configuration and manipulation tasks are things I find interesting. To me a good backup script is like a great scotch — in the hands of a true enthusiast it’s well made and can continue to improve with age if it’s properly cared for. I like to look after my file systems like some people look after their lawns — meticulous care and attention that everything is in its place and that there aren’t any bad seeds around to foul things up.

This can, of course, pose challenges as well. I like the feel of a clean system so much that it can take me days to “dirty-up” a new system enough to make it usable. I’ve had my new MacBook air for three days, and this the first non-setup task I’ve undertaken — and there are still more things to be done before everything will be “just-so”. Having the deisre to keep a really clean system can cause me to feel the need to practise everything and refuse to make changes which may not be reversible — even if the changes are unlikely to be detrimental. In retrospect perhaps that’s why I have had so much experience performing system installs, it’s a great way to clean a system.

Now if you’ll excuse me, it’s time to wipe my old MacBook… it’s about to have a new life as a HTPC.

Home Server Build part 5 – DNS Basics (Ubuntu School)

Once the server has been configured one major “infrastructure” task remains – setting up DNS. This is where those clever names you thought up back in the “prerequisites” stage come into play. Strictly speaking DNS isn’t required for everything else to work properly, but it’s one of those things that makes the overall solution that much more elegant. When you’re connecting to various components in your network it’s so much nicer to refer to them by name rather than simply by IP address.

A key piece of information you’ll want to keep close at hand is the Webmin BIND module documentation. This provides an easy-to-understand guide to managing DNS using BIND and Webmin. It was key to me being able to complete this tutorial.

Create the Domain’s Master Record

For the purposes of this tutorial I’m only going to cover the basics of setting up a DNS server and staging it with a domain (master zone) and setting up named entries (A records) for the devices on your network. DNS can do much more than these basic tasks, but for a personal home server, this is where you’ll get most of the benefits of DNS.

  1. Log in to your Webmin server and open up the BIND server administration page
  2. Click on Create a new Master Zone
  3. Enter the name of your domain in the Domain Name / Network field (I’ll be using Lord of the Rings examples for this, so my domain will be lotr)
  4. Set the Master Server field to the full name of the DNS server – gandalf.lotr
  5. Set the Email Address field to be that of the server’s administrator (you!)
  6. Take the remaining defaults and click on Create

Configure router to use DNS

This step varies from router to router, but the basic principles are the same in most cases. The devices on your network get most of their configuration information from the router using the DHCP protocol. This includes the device’s IP address and the DNS server information. Because router models vary so much, I’m going to provide some high-level guidance on what to configure. You may need to consult your router’s documentation for more details.

Set the DNS Server

  1. Log into your router’s admin screen, often the URL for this is either http://192.168.1.1/ or http://192.168.0.254/
  2. Look for a setting for Network configuration or LAN configuration, this is typically where the DNS server info exists — it may be under an advanced tab
  3. Make note of the DNS server address(es) that are on the configuration screen
  4. If there is only one DNS server slot, enter the IP address of your DNS server — do not use the name
  5. If there is a second (or third) DNS server slot, enter the DNS servers that were on this screen initially in the same order they were in previously
    1. NOTE: this would also be a good opportunity to bring in a 3rd-party DNS service like Google or OpenDNS if you want to
  6. Save the settings

Reserve IP Addresses

Another very handy feature of routers these days is that they can reserve an IP address for a specific machine. This has the effect of consistently providing the same IP address to each device despite the use of the DHCP protocol which typically assigns the next-available address to devices as they connect to the network. This is particularly important for our DNS scenario as it allows us to reliably map names to addresses when we configure the devices in DNS. Without this reservation process you would need to assign static IP addresses to each machine on your network — something which is quite often more trouble than it’s worth.

  1. In the router’s admin screen under Network or LAN look for a heading called DHCP Reservation or IP Reservation
  2. Often this is displayed as a table of the devices connected to your router
  3. Find the devices you want to create names for and reserve each of them
  4. Make note of the IP addresses for each device
  5. Save the settings

NOTE: If you don’t see a particular device that you want to set up a name for in DNS, you can usually add it manually if you have the device’s MAC address.

Note 2: If you have devices with more than one connection to the network (ie ethernet + wifi) each of those connections will show up separately. You will need to reserve different IPs (and provide different DNS names) for each interface.

Set up DNS entries for home LAN devices

Time to set up the remaining names for the rest of the devices on your network

  1. Log in to your Webmin server and open up the BIND server administration page
  2. Click on the icon for the domain (zone) you want to edit: lotr
  3. Click on Address
  4. Enter the name of the device you want to add, with an extra period at the end – frodo.lotr.
  5. In the Address field, enter the IP Address you made note of for that device
  6. Leave everything else set to its default setting
  7. Click Create
  8. On the next screen click on Apply Changes
  9. Repeat for the rest of your devices: aragorn.lotr, legolas.lotr, gimli.lotr

Home Server Build part 4 – Remote Access (Ubuntu School)

Now that the basic server is set up and ready to go it’s time to get started with the good stuff. The first thing on the priority list is making sure we know how to control the server. Being able to control and administer the server remotely is the key to being able to run the server as a headless machine. The key technology of this remote access strategy is SSH.

SSH – Secure SHell

SSH is a key technology common in all POSIX operating systems. The program provides command-line terminal access to the remote system over an encrypted connection. SSH has effectively served as a replacement for telnet which provides remote terminal services, but is not encrypted.

It is also possible to route traffic from your computer through to the remote computer using the SSH connection. These is known as SSH tunelling. One example of this is using an encrypted SSH connection to serve as a conduit for unsecured traffic like web browsing. Most of the time this isn’t a major concern, but if you want to be sure that your browsing session is protected in a public location (ie unsecured WiFi) (or need to otherwise thwart a threat like FireSheep you can route all your web-browsing traffic through to your server and keep it protected from anyone on the public WiFi.

Once connected you will have the same access to the machine that you would typically have by using the local command line. You log in over SSH with the same user ID and password you created during the server setup process. Here is a quick example of what the connection process looks like


ssh kdmurray@192.168.2.11
kdmurray@192.168.2.11's password:

Once that’s over with you’ll get some welcome text that will look something like this…


Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

Download and install Webmin

Details originally sourced from the Debian install instructions on the Webmin site.

These are the steps required to install Webmin using APT. There are a number of other methods mentioned on the Webmin site, but APT has the added advantages of automatic dependency resolution and easy-to-use upgrades. Of course you’re already familiar with some of what APT can do from reading my Ubuntu School posts.

Edit the APT sources list

sudo nano /etc/apt/sources.list

Add the following lines to reference the Webmin sources

Sources for Webmin, current as of 2012-06-10

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

Once the configuration is complete you’ll need to register the developer’s public key with APT so that the files can be verified. This is required because the source is not one of the built-in Ubuntu update sources.


wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
rm jcameron-key.asc

Once the key has been added to the system, and the temporary file removed you’re finally ready to install Webmin.


sudo apt-get update
sudo apt-get install webmin

Because we haven’t set up DNS yet (that’s coming in the next section) you will need to access your Webmin interface using the IP address of your server. The default address for your Webmin installation is https://192.168.2.11:10000. Most browsers will throw up a warning message when you first log in because the SSL certificate being used was self-signed. This is, however expected, so you can add an exception for this server and carry on through to the Webmin interface.