Categories
Technology

The Ten Basic Commands of Unix

Copy found at Wayback Machine Archive.

Once upon a time Unix used to be for geeks only — the platform of choice for godlike SysAdmins and obsessed hackers who muttered strange phrases and giggled over inside jokes, as they swigged gallon after gallon of Mountain Dew. Unix neophytes were faced with a blank screen and an uncompromising command line along with dire warnings about what not to do … or else. Extending the basic computer, adding in such esoteric devices as printers or modems, required recompilation of the kernel, ominous sounding words intimidating enough to send all but the most brave, or foolish, running for the safety of Windows.

Then a strange thing happened: Unix started to get friendlier. First, commercial versions of Linux such as Red Hat came along with easier installation instructions, integrated device support, and lovely graphical desktops (not to mention a host of fun and free games). Open source Unix developers started drinking microbrews and fancy cocktails instead of caffeine and realized that they had to make their software easier to install and well documented in addition to being powerful and freely available. Alternatives to powerhouse commercial applications, such as Openoffice’s challenge to Microsoft’s Office, minimized the cost of switching to desktop Unix platforms. Finally, that bastion of the Hide the Moving Parts Club, Apple, broke all tradition and built a lovely and sophisticated operating system, Mac OS X, on top of a Unix platform.

Today’s Unix: slicker, safer, smaller, better…but push aside the fancy graphics and built-in functionality and simple installation, and you’re still going to be faced, at one time or another, with a simple command line and dire warnings about what not to do. Before you contemplate drinking the Code Red kool-aid, take a deep breath, relax, and familiarize yourself with the Ten Basic Commands of Uinux.

First Command: List the Contents

You have a brand new Unix site to host your weblog. You’re given shell access, which means that you can actually log into the operating system directly, rather than access the site contents through a browser or via FTP. You’ll access the site through SSH, or Secure Shell, because you’ve been told that its more secure. To do so, you’ll install an SSH application recommended by your friends, or use one provided by your hosting service. Up to this point, you’re in familiar territory — start an application and provide your username and password. Simple.

However, once you log on to the operating system, you’re faced with a cryptic bit of writing on the left side of the screen, such as “host%” or some variation thereof, with the cursor located just to the right, waiting to reflect whatever you type. At this point, your mouse, which has been your friend and companion, sits idle, useless, because you’re now in the Unix command line interface, and you haven’t the foggiest what to do next.

Your direction at this point depends on what you hope to accomplish, but chances are, you’re going to be interested in knowing what’s installed in the space you’ve just been given. To do this, you use the Unix List directory contents command, ‘ls’ as it’s abbreviated, to list the contents of the current directory. You can issue the command by typing the letters ‘ls’ followed by pressing the Enter key:

host% ls

What results is a listing of all the files and directories located directly in your current location, which is likely to be the topmost directory of your space on the machine. Depending on the host and what you have installed, this listing could include a directory for all CGI applications, cgi-bin. If your site is web-enabled, it could also include web pages, such as an index.html or index.php file, depending on what you’re using for web pages. If you have a email box attached to your account, you might also see a directory labeled “mail”, or another labeled “mbox”.

This one simple command is highly useful, but there are parameters you can pass to the list command to see more detailed information. For instance, you can see the owner, permissions, and size of files by passing the -l parameter to the command:

host% ls -l

The results you’ll get back can vary slightly based on version of Unix, but the following from my forpoets directory is comparable to what you’ll see:

drwxr-xr-x 3 shelleyp shelleyp 4096 Jul 20 18:09 flavours
-rw-r–r– 1 shelleyp shelleyp 5255 Aug 16 16:28 forpoets.css
-rw-r–r– 1 shelleyp shelleyp 6064 Aug 10 15:14 index.php
-rw-r–r– 1 shelleyp shelleyp 1319 Aug 10 15:00 index.rdf
-rw-r–r– 1 shelleyp shelleyp 789 Aug 10 15:00 index.xml
drwxr-xr-x 10 shelleyp shelleyp 4096 Sep 25 16:21 internet
-rw-r–r– 1 shelleyp shelleyp 27638 Jul 23 00:06 jaggedrocksml.jpg
drwxr-xr-x 9 shelleyp shelleyp 4096 Sep 25 16:23 linux

In this output, the first set of parameters is the permissions for the files and directories, the owner and group associated with each is ‘shelleyp’, the size is listed after the group name, as well as the date, and so on. If the permission character begins with the character ‘d’, this means the object is another directory. Easy.

Of course, at this point you might be saying to yourself that I find Unix easy because I’m aware of what the commands are and what all the different parameters mean and do, as well as how to read the results. I’m a geek. I’ve visited the caffeine fountains and drunk deep; I’ve wondered the halls and muttered arcane curses and behold, there is light but not smoke from the tiny little boxes. But how can you, the creative master behind the sagas recorded on the web pages and the color captured in the images and the sounds recorded in the song files, learn these mystical secrets without having to apprentice yourself to the SysAdmin?

That leads us to the second command, whereby you, the seeker, find the Alexandrian Library embedded within the heart of most Unix installations.

Second Command: Seek Knowledge

Cryptic as Unix is, there is an amazing amount of documentation installed within the operating system, accessible if you use the right magic word. Originally, this word used to be man for manual pages; more recently the command has been replaced by info, though most Unix systems provide support for both.

Want to discover what all the parameters are for the list command? Type in the world man, followed by the command name:

host% man ls

What returns is a wealth of information such as more detailed information about the command itself, as well as a listing of optional parameters, and how each impacts on the behavior of the Unix command. Additionally, documentation for some commands may actually contain examples of how to use the command.

Nice, but what if you don’t know what a command is in the first place? After all, Unix is a rich environment; we can assume that one does more than just list directory contents.

To provide a more introductory approach to Unix, the info command, and the associated Info documents for the Unix system provide detailed information about specific commands, and can be used in a manner similar to man:

host% info ls

What follows is less cryptic information about the command, written more in the nature of true user documentation rather than arising from the ‘less is more’ school of annotation. Still, you have to know about the command first to use the system. Or do you?

If you type ‘info’ without a command, you’ll be introduced into the Info system top level node, which provides a listing of commands and utilities and a brief description of each. Pressing the space bar allows you to scroll through this list until you find a utility or built-in Unix command that seems to provide what you need. At this point, you can usually type ‘m’ to enter menu item mode, and then type the command name to get more detailed information. For instance, if I’m looking for a way to list directory contents, scrolling through Info on my server the first command that seems to match what I want is ‘dir’ not ‘ls’. By typing ‘m’ while still in Info, and then ‘dir’, I find out that ‘dir’ is a shortcut, an alias for a specific use of ‘ls’ that provides certain parameters by default:

`dir’ (also installed as `d’) is equivalent to `ls -C -b’; that is,
by default files are listed in columns, sorted vertically, and special
characters are represented by backslash escape sequences.

Suddenly, Unix doesn’t seem as cryptic or as mysterious as you once originally thought. Still, it helps to know some basic commands before diving into it headfirst, and we’ll continue with our basic Commands of Unix by exploring how to traverse directories, next.

Third Command: Move About

Unix systems, as with most operating systems including Windows, are based on a hierarchy of directories following from some topmost directory basically represented by an empty slash ‘/’. However, unlike a Window-like environment where you click the directory name to open it and continue your exploration, in a command line environment you have to traverse the directories via command. The command you use is the Unix ‘Change directory’ command, or ‘cd’.

For instance, if you have a directory called cgi-bin located in your current directory, you can change to this directory by using the following:

host% cd cgi-bin

Typing the ‘ls’ command displays the contents of the cgi-bin directory, if any.

To return to the directory you started from you can use the ‘..’ value, which tells the cd command to move up one directory:

host% cd..

You can chain your movement requests to move up several directories with one command by using the slash character between the ‘..’ values. The following moves up two levels in the directory hierarchy:

host% cd ../..

Additionally, you can move down many levels by typing the names of directories you want to traverse, again separated by the slash:

host% cd shelleyp/forpoets/cgi-bin

Of course, you have to be directly in the directory path of a target directory to be able to use these shortcuts; and you have to know where you’re at relative to the target directory. However, what if you want to access a directory directly without messing with relative locations? Let’s say you’re in the full directory path of ‘home/username/forpoets/cgi-bin’ (assuming your home environment is /home/username) and you want to move to ‘home/username/web/weblog/logs’? The key to directly accessing a directory no matter where you are is to specify the complete directory path, including the beginning slash:

host% cd /home/shelleyp/forpoets/cgi-bin

Once you’ve discovered the power of directory traversal, you’ll go crazy, winging your way among directories, yours and others, exploring your environment, and generally snooping about. At some point, you’ll get lost and wonder where you are. You’re at X. Now, what is X.

Fourth Command: Find yourself

In Unix, to paraphrase Buckaroo Bonzai, no matter where you go, there you are. To find your location within the Unix filesystem of your machine, just type in the Unix Print Working Directory command, ‘pwd’:

host% pwd

Your current directory location will be revealed, and then you can continue your search for truth, and that damn graphic you need for your new page but you placed somewhere and can’t remember where now.

Of course, to traverse to a directory in order to place a graphic in it, the location of which you’ll then promptly forget, you have to create the directory, first.

Fifth Command: Grow your Space

Directories are wondrous things, a way of managing your resources in such a way that you can easily find one JPEG file without having to search through 1000 different items. With this simple hierarchical, labeled system, you can put your images in a directory labeled ‘image’, or put your weblog pages in a directory labeled ‘weblog’, and add an ‘archives’ directory underneath that for archive pages.

You can go mad, insane, with the impulse to organize — organizing your pages by topic, and then by month, and then by date, and then…well, the limits of your creativity will most likely be exhausted before the system’s ability to support your passionate embrace of your own self geekness.

Making a new directory is quite simple using the Make Directory command, ‘mkdir’. At the command line, you specify the command followed by the name of the directory:

host% mkdir image

When next you list the contents of the current directory, you’ll now see the new directory, ready for you to traverse and fill with all your bits of wisdom and art. Of course, there is a caveat. This is Unix — there is always a caveat.

Before you can create a directory or even move a file to an existing directory you have to either own the directory, and/or have permissions to write to the directory. It wouldn’t be feasible, in fact it would be downright rude, if you could create a directory in someone else’s space, or worse, in the core operating system directories.

We’re assuming for the nonce that you’re the owner of your domain, as far as your eye can see (as allowed by the operating system) and that you can create things as needed. But what if you want to magnanimously change the permissions of files or directories to allow others to run applications, access pages, or create their own directories?

Sixth Command: Grant Devine Rights

Earlier when playing around with the ‘ls’ command, we looked at more detailed output from the command that showed a set of permissions for the directory contents. The output looked similar to:

-rw-r–r– 1 shelleyp shelleyp 789 Aug 10 15:00 index.xml
drwxr-xr-x 10 shelleyp shelleyp 4096 Sep 25 16:21 internet

In the leftmost portion of the output, following the first character, which specifies whether the object is a directory or not, the remaining values specify the permissions for each object listed by owner of the object (the first set of triple characters), the group the owner belongs to (the second set of triples), and basically the world. Each triple permission states whether the person accessing the object has read access, write access, or can execute (run) the object — or all three.

In the first line, I as owner had read and write access to the file, but not execute because the file was not an executable. Any member of the group I belong to (the same name as my user name in this example, though on most systems, this is usually a different name), would have read access to the file, only. The same applies to the world, not surprising since this is a web accessible XML file. For the second line, the primary difference is that all three entities — myself, group, and the world — have executable permission for object, in this case a directory.

What if you want to change this, though? In particular, for weblog use, you’ll most likely need to change permissions for directories to allow weblogging tools to work properly. To change permissions for a file or a directory, you’ll use the Change Mode command, ‘chmod’.

There are actually two ways you can use the chmod command. One uses an octal value to specify the permission for owner, group, and world. For instance, to change a directory to all all permissions for the owner, but only execution permission for a group and the world, you would use:

host% chmod 755 somefile

The first value sets the permissions for the owner. In this case, the value of ‘7’ states that the owner has read, write, and execute permission for the object, somefile

-rwxr-xr-x 1 shelleyp shelleyp 122 Sep 27 17:48 somefile

If I wanted to grant read and write permission, but not execute, to owner, group, and world, I would use ‘chmod 666 somefile’. To grant all permissions to owner, read and write to group, and read only to world, I would use ‘chmod 764 somefile’.

To recap the numbers used in these examples:

4 – read only
5 – read and execute only
6 – read and write only
7 – read, write, and execute

The first number is for the owner, the second for the group, the final for the world.

An approach that’s a bit more explicit and a little less mystical than working with octal values, is to use a version of chmod that associates permission with a specific group or member, without having to provide permissions for all three entities. In this case, the use of the plus sign (‘+’) sets a permission, the use of the subtraction sign (‘-‘) removes it. The groups are identified by ‘u’ for user (owner), ‘g’ for group, and ‘o’ for others. To apply a permission to all three, use ‘a’, which is what’s assumed when no entity is specified.

This sounds suspiciously similar to that simple to put together table you bought at the cheap furniture place, but all’s clear when you see an example. To change a file’s permission to read, write, and execute for an owner, read and execute for group, and execute for the world, use the following:

chmod u+rwx,g+rx,o+x somefile

In this example, the owner’s permissions are set first, followed by the permissions for the group and then ‘others’, or the rest of the world.

To remove permission, such as removing write capability for owner, use the following:

host% chmod u-w somefile

Though a bit more complex and less abbreviated than using the octal values, the latter method for chmod is actually more precise and controlled and should be the method you use generally.

(Of course, there’s a lot more to permissions and chmod than explained in this essay, but we’ll leave this for a future Linux for Poets writing.)

Once you’ve created your lovely new directory, and made sure the permissions are set accordingly, the next thing you’ll want to do is fill it up.

Seventh Command: Be fruitful, copy

One way you’ll add content to your directories is to create new files, or to FTP files from another server. However, if you’re in the midst of reorganizing your directories, you’ll most likely be copying files from an existing directory to a new one. The command to copy files is, as you’ve probably guessed by now, Copy, or ‘cp’.

To copy a file from a current directory to another, use the following:

host% cp somefile /home/shelleyp/forpoets

With this the source file, somefile, is copied to the new destination, in this case the directory at /home/shelleyp/forpoets. Instead of copying the file to another location, you can copy it in the same directory, but use a different name:

host% cp somefile newfile

Now you have two files where before there was one, both with identical content.

You can copy directories as well as files by using optional parameters such as -a, -r, or -R. For the most part, and for most uses, you’ll use -R when you copy a directory. The -R option instructs the operating system to recursively enter the directory, and each directory in that directory and so on copying contents, and to preserve the nature of certain special files such as symbolic links and device files (though for the most part you shouldn’t have these types of files in your space unless you’ve come over to the geek side of the force):

host% cp -R olddir newdir

The -a option instructs the operating system to copy the files and directories as near as possible to the state of the existing objects, and the -r option is recursive but can fail and hang with special files.

(Before using any of the optional flags with copy, it’s a good idea to use the previously mentioned ‘info’ command to see exactly what each flag does, and does not do.)

When you’re reorganizing your site, copying is a safe approach to take but eventually you might want to commit to your new structure and that’s when you make your move. Literally.

Eighth Command: Be Conservative, Commit

Instead of copying files or directories, you can move them using the Unix Move command, abbreviated as ‘mv’.

To move a file to a new location, use the command as follows:

host% mv filename /home/shelleyp/forpoets

Just as with copy, the first parameter in this example is the source object, the second the new destination or new object name — you can rename a file or directory by using ‘mv’ command with a new name rather than a destination. You can also move a directory but unlike ‘cp’, you don’t have to specify a an optional parameter, or flag, to instruct the command to move all the contents:

host% mv olddir newdirlocation

Up to this point, you’ve created, and you’ve copied, and you’ve moved and over time you’re going to find your space becoming cluttered, like Aunt Minnie’s old Victorian house filled with dusty lace doilies and oddities like Avon bottles, forming canyons of brightly colored glass for the 20, or so, cats wondering about.

It’s then that you realize: somethings got to go.

Ninth Command: Behold, the Destroyer

There is a rite of passage for those who seek to enter geekhood. It’s not being able to sit at a keyboard and counter the efforts of someone trying to crack your system; it’s not being able to create a new user or manage multiple devices. The rite of passage for geek candidates is the following:

host% rm *

Most geeks, at one time or another, have unintentionally typed this simple, innocuous phrase in a location that will cause them some discomfort. It’s through this experience that the geek receives a demonstration of the greatest risk to most Unix systems…ourselves.

The simple ‘rm’, is the Unix Remove command and is used to remove a file or directory from the filesystem. It’s essential to keep a directory free of no longer wanted files or directories, and without it, eventually you’ll use up all your space and not be able to add new and more exciting material. However, it is also the command that most people use incorrectly at some point, much to their consternation.

To remove a specific file, type ‘rm’ with the filename following:

host% rm filename

To remove an entire directory, use the following, the -r flag signaling to recursively traverse the directories removing the contents in each:

host% rm -r directoryname

When removing an entire directory, you’ll be prompted for each item to remove, and this prompt can be suppressed using the -f option, as in:

host% rm -rf directoryname

So far, the use of remove is fairly innocuous, as long as you’re sure you want to remove the file or directory contents. It’s when remove is combined with Unix wildcards that warning signs of ‘Ware, there be dragons here should be entering your thoughts.

For instance, to remove all JPEG files from a directory, instead of removing each individually, you can use a wildcard:

host% rm *.jpg

This command will remove any file in a directory that has a .jpg extension. Any file. Simple enough, and as long as that’s your intent, no harm.

However, it’s a known axiom that people work on their web sites in the dead of night, when they’re exhausted or have had one too many microbrews. Our minds are befuddled and confused and tired and not very alert. We’re impatient and want to just finish so we can go to bed. So we enter the following to remove all JPEG files from a directory:

host% rm * .jpg

A simple little space, the result of a slight twitch of the thumb, and not seen because we’re tired — but the result is every file in that directory is removed, not just the JPEG files. And the only way to recover is to access your backups, or seek the nearest Unix geek and ask them to please, pretty please, help you recover files you accidentally removed.

And they’ll look at you with a knowing eye and say, “You used rm with a wildcard, didn’t you?”

Which leads us to our last Command, and the most important…

Tenth Command: Do Nothing

You can’t hurt anything if you don’t touch it. If you’re unsure of what a command will do, read more about it first, don’t type it and hope for the best. If you’re tired and you’re removing files, wait until you’re more rested. If something isn’t broken, don’t fix it. If your site is running beautifully, don’t tweak it. If you’re trying something new, back your files up first.

Unless you’re a SysAdmin and need to maintain a system, in which case you don’t need this advice anyway, you can’t hurt yourself in Unix unless you do something, so if all else fails, Do Nothing.

The easiest mistake to recover from in Unix is the one that’s not made.

Categories
Technology

Today’s Unix: New all over again

Originally published at O’Reilly onlamp.com, recovered from the Wayback Machine.

It used to be that Unix was for the geeks, while the rest of the world used less command-intensive, and usually less powerful, operating systems such as Windows or the Mac OS. Even with the advent of native GUIs such as the X Window system, Unix was not for the uninitiated. If you didn’t understand that pwd returned the name of the working directory, ls listed the contents of a directory, and that you accessed help with man, then you needed to carefully remove your hands from the keyboard and back away slowly, trying not to touch anything as you moved.

Well, the times they are a-changing. Today’s Unix is sexier, friendlier, and is moving in completely different neighborhoods than yesterday’s Unix. Gone is the tough, geeks-only image, wrapped in discussions of kernels and cron jobs, communication interspersed with esoteric terms such as awkseddaemons, and pipes. In its place is a kinder, gentler, more easily accessible Unix, wearing new clothes in soft undertones of unintimidating blue.

Still, the basic core of the old Unix remains, forming a hybrid of its older, powerful functionality that’s been integrated with modern conveniences. In many ways, today’s Unix, with its blend of old and new technologies, open source support, and bright shiny new interfaces, reminds me of that old wedding attire rhyme, “something old, something new, something borrowed, and something blue.”

Something Old

There is a commonality to all popular flavors of Unix — Solaris, Linux, FreeBSD, the new Mac OS X Darwin, and so on. Mac OS X may have a very unique user interface, but if you bring up a terminal (access the Finder menu, select Go, then Applications, then Utilities), you’ll be able to enter Unix commands exactly the same as you would in command line mode in OpenBSD or HP-UX. In addition, the overall boss of the system is still root, though how root is managed can change, dramatically, from Unix box to Unix box, and among individual installations.

Each flavor of Unix is based on the same principles of shell access and kernel system control, and each comes with a minimum functionality that allows you to communicate with the operating system. For instance, you can with assurance go into any Unix box and type vi at the command line, and the vi editor will open. Being a longtime vi fan (successfully resisting any urge to move over to emacs over the years) it’s good to see my old friend regardless of whether I’m accessing vi on my FreeBSD server, a Solaris box at work, the Linux dual boot on my Dell laptop, or within the Terminal window of my Titanium Powerbook.

Additionally, no matter your version of Unix, you’ll interact with the operating system through a shell; multiple users can share system resources because the operating system supports preemptive multitasking (the ability to run tasks seemingly simultaneously without clashes over resources); you can work with files, directories, and resources with common commands such as cdlsmkdirgrepfind, and so on; you’ll have access to a wide variety of open source and freely-available utilities such as the previously mentioned vi; the smarts of the system is the kernel; and root is still the superuser that can take everything down in one command.

However, after having just reassured you that there is little difference between old and new versions of Unix, I’ll now contradict myself and tell you that today’s Unix isn’t exactly the same as the old Unix, as this old dog has learned some new tricks.

Something New

One of the biggest differences I’ve found with the newer forms of Unix, or even more modern versions of old classics, is how much easier it is to do things. For instance, one of the most complicated and nontrivial tasks within the Unix world used to be, at least for me, installing software.

Not that long ago, after downloading and uncompressing the software you wanted, you’d most likely find that the package contained source code, which you’d then have to compile and install. Unfortunately, it seemed as if no two Unix installations were ever alike, so you’d have to work with the source code’s Makefile (basically an instruction file for architecting the build); tweaking it, changing the libraries, the locations, the flags used, and so on, in order to get a successful build and install. The POSIX Unix standards effort helped with some of this, but for the most part, you just had to work the build and installation through, and unless you were really lucky, the process could take a frustrating amount of time.

(Really, it was no wonder Unix people became so clever working with basic Unix functionality — no one wanted to go through the hassles of installing new utilities and tools.)

Today, spending hours and days tweaking Makefiles is virtually a thing of the past — most flavors of Unix now come with tools that not only tweak the Makefile for you, but can download the software and build and install it, all in one command.

If you’re a Linux user, you use RPM to manage your software; if you’re a Debian user, you’ll use dpkg. FreeBSD users utilitize the ports to access and install software. Even the Mac OS X has a version of ports called Fink. In addition, all Unix users can use three new utilities — autoconfautomake, and libtool — to literally analyze your environment and generate a Makefile that’s customized to your machine.

Software installation isn’t the only area of improvement to today’s Unix. Getting a software package, or anything over the Internet, is easier with new tools and utilities, such as GNU’s wget utility, which can download a file through either the HTTP or FTP protocols. Though I’ll always remain true to vi, the more modern vim has lured users away from vi‘s simple (but elegant) functionality, not to mention users of that other editor, emacs. For scripting, you have access to some shiny new scripting/programming languages such as Python and Ruby, in addition to that favorite, Perl. And very few people use the old C shell any more — most use the more modern bash (Bourne Again Shell), or newer variants.

No matter what new toy or tool you use, much of this simplified and friendlier Unix environment is due to the operating system’s implicit partnership with the open source community. In fact, this partnership is the main reason that Unix is such a thriving, vibrant operating system thirty years after its introduction.

Something Borrowed

Though Unix has received support from major corporations such as HP and Sun, it’s still the open source developers who spent time creating utilities and tools, as well as working on more portable versions of Unix that kept what was a cryptic and difficult operating system around long enough for it to mature into the powerful, elegant, and user-friendly OS we have today. Unix owes a huge debt to the open source community for providing applications such as those mentioned in the last section.

Need a database for your FreeBSD box? You can download and use MySql for no charge as long as your use is personal. Interested in serving up Web pages? Download and install the number one Web server, Apache. Once Apache is installed, you can develop with Java using Tomcat, or you can use an embedded scripting approach with PHP — again, downloadable, open source, free software. It’s true that many of these products also work on other operating systems, such as Windows. But the concepts behind each began with Unix.

One can literally fill books just trying to list all of the software that’s freely available, or available for a small price, and most of it is open source and runs on the majority of Unix platforms.

(If you have a spare day or two, you can access Source Forge and browse through all of the open source projects it manages. In addition, access FreeBSD software at the FreeBSD Web site; Mac OS X downloads at www.apple.com/downloads/macosx/; more on Linux at www.linux.org/; and general Unix utilities and tools at the GNU site.

In the last decade, we’ve also seen a blend of traditional open source effort and corporate management, with releases of Linux such as Red Hat or Mandrake, and Apple’s Mac OS X, with its proprietary interface built on an open source Unix known as Darwin. It’s this combination of open source effort and corporate support and stability that’s taking Unix to the desktop and laptop machines of the world; a move that’s taking our old friend out of the basement and giving it new purpose.

Something Blue

One of the first things I tried when I received my new Powerbook was to access the Terminal application and attempt to log in as root using the well-known su -l command. It was then that I discovered that Mac OS X was more than a smart GUI layered on to a Unix kernel — the integration between the two is much more extensive.

If you’ve accessed the Terminal in Mac OS X, then you’re most likely aware that the root user is not enabled by default. To enable root, you must access the Netinfo Manager application (from the Finder menu, access Go, then Applications, then Utilities), clicking on the Security menu and then choosing “Authenticate” to authenticate that you’re the computer’s administrator. Once authenticated, you can then enable or disable the root user.

Having to manually enable root is just one of the many twists to the integration of Unix (Darwin) with Apple’s sophisticated user interface, known as Aqua. The reason for the disabled root is security — if the traditional superuser is disabled, it’s much more difficult to crack into the Mac OS X kernel functionality and wreak havoc on the system. Since most Mac users will never access the command line, or will ever need true root access, a decision was made to disable it by default.

You’ll bump into another twistie when you attempt to compile downloaded software, even downloaded software that makes use of the automated configuration tools. Chances are you’ll run into an error similar to the following:

configure: error: installation or configuration
 problem: C compiler cannot create executables

This less-than-helpful message occurs because you have to specifically install developer tools that come on a separate disk from the Apple Mac OS X installation disk.

In spite of the differences you might encounter working through the Aqua user interface, one common connection between this new environment and more traditional Unix flavors is your ability to use X Window (X11)-based software within the Mac OS X environment, even though the two could be considered competitive GUIs.

I wrote this article using OpenOffice, an open source office application that’s freely available for Linux, Solaris, and Windows. Recently, the OpenOffice organization released a beta version of the application for Mac OS X. Rather than attempt to port OpenOffice directly into Aqua, the organization took an interim step and ported the source to Darwin with a X Window user interface. The next step once the first port is successfully tested will be to port to Apple’s Quartz graphical interface, and finally to Aqua.

To run OpenOffice, I needed to download and install an X Window system, and it just so happens there’s one available — XDarwin. Additionally, there’s a X11 window manager that works with XDarwin — OroborOSX. To install both, it was literally a matter of downloading the packages, uncompressing them with Stuffit, and double-clicking on each installation package — first XDarwin and then OroborOSX. No muss or fuss with paths or parameters or settings of any form (based on default installation). Once the X Window environment was in place, I then used the same procedure with OpenOffice. The total time to download and install all three packages was less than fifteen minutes; a shorter amount of time then it takes to install a certain other office application product. A person could get used to this.

Blue seems to be a lucky color with Unix, because Red Hat’s newest Linux installation, Red Hat Linux 8.0, now comes with a spiffy new GUI the company calls Bluecurve. Having installed Linux many times over the years, I was relieved when the installation program was able to detect and configure all of my peripherals, including my wireless mouse and keyboard. I was also very pleased when I was able to add and configure my wireless network card with just a few clicks of the mouse.

Of course, activating the wireless connection failed at first, and I’m having to do some research to find a solution, and I’ll most likely have to do some tweaking to get it to work. But, hey! It wouldn’t be Unix if all the challenges were removed, now would it?