Saturday 7 July 2007

Mac on SBS - The Command Line - FreeBSD/Darwin Style

Having some experience with FreeBSD and OpenBSD, albeit a limited amount, just came to a huge payoff.

Howz that?

The command line shell for OS X is bash. Bash is one of the UNIX shells of choice for many *NIX users that run anything from Apache Web servers, QMail or Sendmail e-mail servers, to Windows replacement desktops. It provides full Unix command line functionality and all that entails. And, that is a lot!

Also, OS X Darwin incorporates FreeBSD services along with a host of other powerful features. So, hopefully this means that I will be on somewhat familiar ground! :D

To access bash, open Finder (the face looking icon on the dashboard) and click on Applications. Scroll down to Utilities and you will find the Terminal.app.

To add the Terminal application to the dashboard, click and hold on it in the Finder list and drag it down to the position you want and release it there. A "shortcut" will be placed there. I am not sure what the official Mac name for the icon is.

A quick way about finding something in the Finder is to click up in the top right corner in the search field:


If you type Terminal there, the Terminal.app will come up right away. From there, one can click and drag the icon to the dashboard for subsequent quick access.

I think I can see where Microsoft got their inspiration for the Desktop Search system that is installable on Windows XP and comes native to Windows Vista based on this feature.

In Windows, the "shell" is the Windows Command Line Interpreter. We get to it in 2000 Pro, XP Pro/Home, or Vista by:
  • Start-->Run-->CMD [Enter].
From there we have somewhere in the neighbourhood of 40 commands to work around with.

Microsoft: Windows Command-line reference A-Z.

While we can get quite proficient in the Windows Command Line Interpreter, utilizing a *NIX shell is another thing altogether.

The *NIX command structure is elegant simplicity at its finest. One can create a tapestry of commands that will complete an extremely complex series of tasks with the ability to script those tapestries ad infinitum.

*NIX scripting and management can be seen as an artform. And believe me, there are some pretty amazing *NIX artists out there.

I do believe that Microsoft has "seen the light" so to speak when it comes to the power of the *NIX command structure. Enter the Windows PowerShell. For those of us who manage networks, it is a whole new challenge to embrace or fear depending on your predisposition to the command line! ;)

Microsoft Windows PowerShell Site.

Back to OS X: while in the bash shell, there is a huge help manual (Man pages). It can be accessed by typing
  • man command [Enter]
This will bring up the following about the command:
  • NAME - A description of what the command will do
  • SYNOPSIS - The various switches that can be applied to the command
  • DESCRIPTION - A deeper description of the command's abilities, defaults, and more
  • OPTIONS - Explanation of the use of the command's switches and the switches themselves.
    • Keep in mind that there can be sub-switches to the switches and so on!
My first contact with the Man pages a number of years back and their indepth explanations and examples for the various commands blew me away. At that time, it was clear that Microsoft had a long way to go with their Windows Help files as they were completely anemic in comparison to the *BSD Man pages and now OS X Man pages.

Microsoft has come a long way with the Help files and tutorials available for their desktop products. The server products Help can be pretty tough to decipher at times though. Just try publishing a DNS server through ISA 2004/6 when reading the Help on the subject! That is where knowledge and experience of the product, as well as research via the Internet come in very handy.

Microsoft, it shouldn't have to be that way!

Some relevant links:This aspect of the Mac is definitely exciting and I am looking forward to brushing up on my *NIX skills! :D

Oh, and BTW, to exit out of the bash shell:
  • exit [Enter]
A [Process Completed] will appear after the logout process has completed. One can close the Terminal window then.

The reason for the "*NIX" as opposed to typing UNIX: Linux and UNIX fall under the same OS umbrella to some degree. Both strains offer their own particular command line structures and shell capabilities with some shells like bash ported to run on pretty much any *NIX.

Philip Elder
MPECS Inc.
Microsoft Small Business Specialists

*All Mac on SBS posts are posted on our in-house iMac via the Safari Web browser.

No comments: