This post is part 5 of 39 in the series Taming the Terminal

In this instalment it’s time to make a start on one of the most important Unix/Linux concepts, file permissions. This can get quite confusing, but it’s impossible to over-state the importance of understanding how to read and set permissions on files and folders. To keep things manageable, I’m splitting understanding and altering permissions into two separate instalments.

Linux and Unix (and hence OS X) all share a common file permissions system, but while they share the same common core, they do each add their own more advanced permissions systems on top of that common core. In this first instalment we’re only going to look at the common core, so everything in this instalment applies equally to Linux, Unix, and OS X. In future instalments we’ll take a brief look at the extra file information and permissions OS X associates with files, but we won’t be looking at the Linux side of things, where more granular permissions are provides through kernel extensions like SELinux.

Read more

Tagged with:

I regularly find myself navigating to a folder in the Finder and then wanting to quickly get a Terminal window in the same location. In the past I would open a Terminal window, type cd and a space, then drag and drop the folder in question from the Finder into the Terminal and hit enter. Thanks to OS X’s great drag-and-drop support that works, and while it is easier than typing out the whole path (even with tab-complete), it’s still quite cumbersome.

Today inspiration hit me – the open command should let me open a folder with the Terminal, so I tested it, and it does. Armed with this simple command line solution I opened up Automator and threw together a simple OS X service that takes a folder as input. The service has only one action, a Run Shell Script action with the shell set to bash, the input passed as arguments, and the following content:

for f in "$@"
do
	/usr/bin/open "$f" -a /Applications/Utilities/Terminal.app/
done

Screenshot of Service
Click to Enlarge

It will only take seconds to re-create this service yourself, but for convenience, I’ve zipped up my copy of the service and am attaching it to this post. Install it by unzipping and adding to either ~/Library/Services/ (for just yourself) or /Library/Services/ (for all users).

Download

Once the service is installed it will show up in the Services menu in the Finder when ever you have one or more folders selected:

Terminal Here Service In Action
Click to Enlarge

You can also get to the service by right-clicking on any folder in the Finder:

Terminal Here Service In Action - Right Click
Click to Enlarge

Finally – if you keep the optional Path Bar shown in the Finder you can also right-click on a Folder there to access the service (including the folder you are in):

Terminal Here Service in Action - Path Bar
Click to Enlarge

ISS Passing over TaghadoeIreland is actually quite far north, so our summer nights never get fully dark. You watch the sun set, but the glow on the horizon doesn’t go away, it slowly moves from the west through the north to the east where the sun rises again. This takes away a lot of astronomical opportunities, but, when one door closes, another opens. Because the sun never gets far below the horizon during the summer in higher northern latitudes, the part of space where satellites orbit remains in sunlight the whole night long, which means summer is satellite observing time! (The same is true in the southern hemisphere for far southern latitudes during their summer.)

There are lots of ‘ordinary’ satellites which can be seen pass over each night – they look like stars that move slowly but purposefully across the sky – taking a few minutes to cross from one side of the sky to the other. These can be fun to watch, and you can photograph them with a bit of effort, but, the stars of the show are the International Space Station (ISS), which blazes across the sky shining brighter than any star, and the network of Iridium communication satellites which ‘flare’ regularly. Any satellite can ‘flare’, when the sun glints off a solar panel or communication dish, but those flares are not predictable or dependable. Iridium flares are different, because the Iridium Satellites have massive dishes pointing earthwards at all times, and as they pass over-head, the dish will come into alignment with the sun, and what starts off looking like a regular dim satellite will suddenly brighten for a few seconds and then dim again. The flare is effectively a cone that sweeps the earth, if you are in the very middle of the cone, the flare will be spectacularly bright, down to magnitude -8. For context, the magnitude scale is inverse, so the lower the number the brighter the object. The brightest stars are about magnitude 0, the brightest planets about magnitude -4, and the Moon about magnitude -11, so -8 is getting close to the brightness of the Moon!

Read more

Tagged with:

This post is part 4 of 39 in the series Taming the Terminal

In the previous segment we discussed the concept of a file system in detail. We described how filesystems contain folders which contain files or folders, and we described the different ways in which Windows and Linux/Unix/OS X combine all the filesystems on our computers into a single name-space, within which every file has a unique ‘path’ (F:\myFolder\myFile.txt -v- /Volumes/myThumbDrive/myFolder/myFile.txt). In this instalment we’ll look at how to navigate around the Unix/Linux/OS X filesystem in a Bash command shell.

Read more

Tagged with:

I spent quite some time this afternoon finding a reliable way of converting Unix Time Stamps (UTS) to the ISO 8601 format used in SQL databases like MySQL and PostgreSQL that does not get confused by timezones. In the end the final result is, as is so often the case with Perl, very short and simple, but since the Googles failed to find the answer for me today, I thought it would be worth sharing in case it’s of use to others in the future.

use DateTime;

# Function to convert Unix Time Stamp to ISO 8601 Date
# Arguments:
# 1) The Unix Time Stamp to convert
sub uts_to_iso8601{
    my $uts = shift;
    my $date = DateTime->from_epoch(epoch => $uts, time_zone => 'UTC');
    return $date->ymd().q{ }.$date->hms().'z';
}

The algorithm is very simple, use DateTime‘s from_epoch function to a DateTime object in the UTC timezone (AKA Zulu). Then assemble the output as YYYY-MM-DD HH:MM:SS, and append a z for Zulu. MySQL and PostgreSQL can now use the string to populate Date or Timestamp columns.

As an example, the Unix Time Stamp 1369410796 converts to 2013-05-24 15:53:16z.

Tagged with:

Tim VerpoortenThis is not going to be an easy post to write, and I really hope I do it justice.

The Apple/Mac community lost one of it’s finest podcasters today. Tim Verpoorten wasn’t the first Apple/Mac podcaster, but he was one of the very earliest generation. I think it would be fair to call him a father figure to many of us who followed. I know he was one of the podcasters who inspired me to pick up the microphone myself, and I doubt I’m alone in that.

Tim had been unwell for some time, and hung up his microphone to concentrate on his health a while ago, but we all hoped it would just be a temporary hiatus. I don’t think any of us in the community wanted to believe we’d heard the last of Tim’s distinctive and friendly voice.

Every good Apple/Mac podcast brings something unique to the table, and Tim’s Mac Review Cast brought fantastic reviews week after week after week for years and years. Tim had a knack for finding great apps, particularly free ones, and he was able to find and review them at a truly impressive rate. Most people can mange either quantity or quality, but Tim could do both at the same time. Although he reviewed many many apps, you could always tell when an app really appealed to him. Those apps were almost never large apps with lots of features, but small apps that did just one thing, but did it really well. It’s fair to say Tim had a bit of a thing for menubar apps.

Because I learned about so many great apps on the Mac Review Cast, I regularly look up at my menu bar, or into my dock, and think of Tim. One app in particular that I’ll always associate with him is the light-weight Mac-like text editor Smultron. I’d almost given up on finding an editor like this for the Mac, when I heard Tim review Smultron, and gave it a go. It was love at first sight, and that cute red strawberry icon will always bring back fond memories of Tim.

Tim was one of the founders of the Mac Round Table Podcast (MRT), and it was through that podcast that I was fortunate enough to get to ‘work’ (play more like) with Tim. One of the great things about the MRT is how different all the contributors are, and how that opens up some great conversations. We often agreed on things, but when it comes to temperament, I think myself and Tim were polar opposites – I’m know for being the cranky Irishman (sorta) who’s prone to impassioned (and hopefully entertaining) rants, while Tim was always as cool as a cucumber – I can’t remember him ever getting flapped, and I can’t remember him ever having a bad word to say about anyone. I think it’s much easier to go on a rant than it is to remain calm and collected, and I greatly admired Tim’s coolness.

I never met Tim in the real world, yet I feel I’ve lost a friend. The Mac community has certainly lost one of it’s finest ambassadors, but my thoughts are with the Verpoorten family tonight – their loss is so much greater than ours.

The photo that accompanies this post is a crop from this image by Allison Sheridan.

Tagged with:

This post is part 3 of 39 in the series Taming the Terminal

This is the third instalment of an on-going series. These blog posts are only part of the series, they are actually the side-show, being effectively just my show notes for discussions with Allison Sheridan on my bi-weekly Chit Chat Across the Pond segment on her show, the NosillaCast Mac Podcast. This instalment will be featured in NosillaCast episode 418 (scheduled for release late on Sunday the 12th of May 2013).

In the first installment we started with the 40,000ft view, looking at what command shells are, and why they’re still relevant in today’s GUI-dominated world. In the second instalment we looked at OS X’s Terminal.app, the anatomy of the Bash command prompt, and the anatomy of a Unix/Linux command. This time we’ll be looking at the anatomy of file systems in general, and the Unix/Linux file system in particular, and how it differs from the Windows/DOS file system many of us grew up using.

Read more

Tagged with:

RPSI No.186Exactly two weeks ago today (on the 21st of April 2013) the Railway Preservation Society of Ireland (RPSI) ran two steam specials from Dublin to Maynooth and back which they named Royal Canal Shuttles. The name was inspired by the fact that the section of the Sligo line between Dublin and Maynooth runs along the banks of the Royal Canal for almost its entire length.

The trains consisted of the RPSI Cravens coaches, and were worked by the RPSI’s 0-6-0 steam loco No.186. The trains were a little more special because No.186’s boiler certificate will expire later this year, so this could well have been the last time she’ll be on this line for a decade or more. Once her certificate expires she’ll have to be fully overhauled, and given that the RPSI is a volunteer group, that will take quite some time. No.186 has proven herself to be a remarkably reliable engine over the last few years, and I’ll certainly miss seeing her around.

The weather forecast for the day was awful, but thankfully it turned out to be a little too pessimistic.

Read more

Tagged with:

This post is part 2 of 39 in the series Taming the Terminal

This is the second instalment of an on-going series. In the first instalment I tried to give you a sort of 40,000ft view of command shells – some context, some history, a very general description of what command shells do, and a little bit on why they are still very useful in the modern GUI age. The most important points to remember from last time are that command shells execute commands, that there are lots of different command shells on lots of different OSes, but that we will be focusing on Bash on Linux/Unix in general, and Bash on OS X in particular. The vast majority of topics I plan to discuss in these segments will be applicable on any system that runs Bash, but, the screen shots I use will be from OS X, and some of the cooler stuff will be OS X only. This segment, like all the others will be used as part of my bi-weekly Chit Chat Across The Pond (CCATP) segment with Allison Sheridan on the NosillaCast Mac Podcast.

Last time I focused on the shell, and avoided getting in any way specific about the actual commands that we will be executing within the Bash shell. I thought it was very important to make as clear a distinction between command shells and commands as possible, so I split the two concepts into two separate segments. Having focused on command shells last time, this instalment will focus on the anatomy of a command, but will start with a quick intro to the Terminal app in OS X first.

Read more

Tagged with:

This post is part 1 of 39 in the series Taming the Terminal

I have no idea whether or not this idea is going to work out, but on this week’s Chit Chat Across the Pond segment on the NosillaCast Mac Podcast (to be released Sunday evening PST) I’m going to try start what will hopefully be an on-going series of short un-intimidating segments to gently introduce Mac users to the power contained within the OS X Terminal app. I’m on with Allison every second week, and I’ll have other topics to talk about, so the most frequent the instalments in this series could be would be bi-weekly, but I think they’ll turn out to be closer to monthly on average. While the focus will be on OS X, the majority of the content will be equally applicable to any other Unix or Linux operating system.

In the last CCATP we did a very detailed segment on email security, and despite the fact that with the benefit of hind-sight I realise it was too much to do at once and should have been split into two segments, it received the strongest listener response of anything of any of my many contributions to the NosillaCast in the last 5 or more years. I hope I’m right in interpreting that as evidence that there are a lot of NosillaCast listeners who want to get a little more technical, and get their hands dirty with some good old-fashioned nerdery!

Read more

Tagged with:

« more recent postsolder posts »