Usha Guduri

Unix in Simple English: whatis-whereis-locate-which

Each application/program over time, as it evolves (hopefully for the better!), is released in several versions. Ever wondered which version is being used or where/what all the versions installed are? Its quite easy with just using simple english in unix!

Lets start with a quick snippet on what an executable is with ‘whatis’. It searches for whole words within the whatis database that contains short descriptions of system commands.

$ whatis ruby
irb(1), erb(1), ri(1), rdoc(1), testrb(1) - Ruby helper programs
ruby(1)                  - Interpreted object-oriented scripting language

Now ‘whereis’ does the job of indicating where the specified executable is.

Extended File Attributes

The other day, a simple

ushaguduri@work:Wed Feb 20 15:40:17 -> ls -al
-rw-r--r--@ 1 ushaguduri  staff   899B Feb 20 15:26 test_file

got me digging deeper into the underlying File System. Notice the @ after the file permissions? That’s a way to associate metadata with a file. Its not used by the file system for any useful purpose - just to store additional information, say like the source of the file, author etc.

Bringing up the manual for the ls command describes the @ as an available option too:

 -@      Display extended attribute keys and sizes in long (-l) output.

Git Branches - Local

Once you clone a Git repository, you are highly unlikely to work on the master unless you are a Maverick! The immediate thing you will look out for is branching - whether it is to add new features or even fix your bugs before pushing them live (Do you do ‘Test Driven Development’, by the way? :-D ). And Git is a great tool in this realm because branches are really really cheap - both in terms of memory and time (when switching between branches)

You start off with knowing the current branch you are working on with

$ git branch

Mac UI Tweaks

Its easy to think that Mac UI is not customizable but behold-it is!

However, these options are not available via the System Preferences but you can change them from the Terminal. Note the inconsistencies in the boolean values: YES/NO, true/false, 1/0…I’d have expected better from Apple!

Some of the more often looked for settings are shown below. But I’ve started working on a small utility called maclets that is a compilation of settings I find myself frequently using. Once sourced it can be used as:

$ toggle <service> <on/off>

Getting into the Git Land-via SVN

All the cool kids use git these days but shifting gears for your way-way-back-then-started repo into git is an intimidating task, let alone scaring the entire team while everyone is busy getting their stuff done.

But you still want to learn git? there is no better way to that than using it every single day-isnt that how you became a pro at svn in the first place? so here comes git-svn to the rescue.

Its a real simple tool that goes bi-directional between git and svn and is so well done that sometimes its just prepending git in front of svn commands!

To start a git repo from svn is as easy as

PDSH - Parallel Distributed SHell

Unless your application is a serving such a small traffic or is in the Beta stage, you are probably working with a load-balanced set of servers - web/application/database - you name it. And when there is an issue, the task of looking at the logs on each of the servers is a nightmare!

One option is to run a remote command via ssh like:

$ ssh user@host “date”

CNAME Vs. A Record

This is one of a nuances of the Domain Name System (read nuisances as well, if you dont quite understand it and end up mixing the two, running with pants on fire that the website is not working!)

Called the Canonical Name, it is similar to saying Jane Smith and Mrs.Smith are the same person. Almost all the websites have a single default CNAME for www. If you see sites where works but fails, it most likely is because of this missing CNAME which looks as simple as:


SSH Access to the Hosting server

This section depends more on what style you are comfortable with: point-and-click or the get-dirty-with-the-command-line. I belong to the 2nd class and feel so lost without access to the bare bone shell (which I immediately customize with aliases/shell functions/shortcuts etc). This can be a discussion in its own right.

So anyway, once you have acquired hosting space, the seller gives you an IP address of a physical machine where you can ‘setup your html files’. Depending on the seller(HostGator), you may have to ‘Enable SSH Access’ to open the ssh port.

Then you can type

$ ssh -p 1234 username@123.456.78.9

from the shell and voila! you are at the all too familiar bash prompt on the hosting server!

Domain Registration Vs. Web Hosting

Any substantial group/idea/person has to have a website these days to prove their legitimacy even in the cyberspace.

Now where does that start? With signing up for a easy to recognize name that is associated with the entity at a Domain Registrar - one who makes sure that you own that name and no one else can get that name, like GoDaddy, 1and1, Network Solutions etc. And you pay for their services-anywhere from $10 to $100+ a year. (Prepare to shell out in the thousands if you want a name real bad, that is already taken). At this point, you only have the name to your credit, with a generic message showing at most but no where close to what you want it to actually be like, when you visit the site via a web browser.

SVN Delete - an oops moment!

And how many times did you accidentally delete files from svn repo - be it because you were copying and instead moved, typo’d and deleted 1 file instead of another or for whatever reason?!

Easiest to do: simply copying the file from elsewhere and svn add

Better way to do: restore the files, including the svn history.