Unix vs. Apple OS?
August 29, 2011 3:09 PM   Subscribe

CompSciFilter: Someone kindly explain to me what differentiates Unix and Apple OS.

So this semester, I decided to enroll in my first computer science course, "Object Oriented Programming: Java." Today -- the first day of class -- my professor lectured a bit about Unix, and how Apple incorporated(...?) Unix into its operating system a few years ago.

We then went into the computer lab (where we used Macs), and used the program "Terminal" to start/close programs, save text documents, ect. The professor said something along the lines of: "the commands you are entering communicate with the Unix operating system."

So, I really don't get the difference between Unix and Mac OS, at all. With that in mind, is there something exactly like Terminal (or is that Windows' command prompt?) for Windows Seven so that I can "practice" what we did in class on my laptop?

Sorry if this seems somewhat confusing.

Thanks!
posted by lobbyist to Computers & Internet (28 answers total) 13 users marked this as a favorite
 
Best answer: The short answer: Unix is a general name for a lot of slightly-different operating systems, and Mac OSX is one of them.

Cygwin is a Unix-like environment for Windows. It should give you some practice with the basic commands.
posted by jozxyqk at 3:12 PM on August 29, 2011 [1 favorite]


Mac OS X is based on Unix. The part that you see most of the time (e.g. the windows, the dock, the menubar) are all programs running on top of Unix. The Terminal is a way to access the Unix part 'directly.'

This Wikipedia article helps explain it.
posted by jedicus at 3:19 PM on August 29, 2011


Best answer: Everyone will have their own opinion on this, but:
  • The terminal you had up there was probably talking to bash, the "Bourne again shell", a free implementation of something that started out like a Unix tool called the "Bourne shell".
  • There are a bunch of different parts to any "Unix-like" operating system:
    • There's the kernel, often you'll hear "Linux" bandied about as though it was a full operating system, but it's really just a kernel. Other kernels in popular use include FreeBSD, and the MacOS kernel which I believe is a descendent of something called "Mach"
    • There's the command-line tools. Usually these are based on the GNU utilities, although on various other systems, like Solaris, you might find other versions of them. These utilities also include the "init" application, which manages daemons running and starts up the login process and other stuff like that. On the Mac I think it's now called "Launchd", but I'm not sure. Anyway, that's just the first program that the kernel starts, that starts other things that you can then interact with, and you care only because it changes how you start and stop daemons
    • There's the graphics layer and shell combination. In Linux systems, "X" is the graphics layer and windowing systems, but then there are window managers laid on top of that, and environments like "Gnome" and "KDE" on top of that. In the Mac, there's a graphics and interface layer that can coexist nicely with "X", but you have to install X to do so
  • As jozxyqk mentioned, Cygwin is a great little system that runs the GNU tools on top of Windows, which means it can give you a bash shell on Windows. With a number of quirks, but, hey, it's Windows, you should feel lucky it runs at all.

posted by straw at 3:22 PM on August 29, 2011 [7 favorites]


Best answer: Taking your questions one at a time and breaking them down a bit...

Apple's operating system, which is to say Mac OS X, is actually a specific implementation of UNIX. "UNIX" is a trademark owned by The Open Group, who controls who gets to apply it to their products, based on whether they meet certain requirements (the Single UNIX Specification). Apple got Mac OS X certified a few years ago, meaning that it is actually a UNIX implementation.

That said, when technical people talk about "Unix-like" operating systems, they more often (in my experience) mean a proprietary UNIX like HP-UX, SunOS, AIX, or Irix, or even one of the BSDs, rather than Mac OS X. But technically Mac OS is a UNIX.

Linux, interestingly, isn't a UNIX because it's never been certified by The Open Group and differs in some technical ways from the Single Unix Specification. But from a purely functional standpoint, using a Linux distro probably feels more like a traditional UNIX environment than Mac OS X, mostly because Linux uses XWindows/Xorg in its GUI layer in common with traditional UNIX environments, while Mac OS X has a proprietary GUI (Aqua).

By the way, it's not a requirement to be a UNIX that an OS use a particular kernel ... Mac OS X uses the Mach microkernel (sort of), while BSD has a monolithic kernel, and the proprietary vendors each have their own, infused with their brand of secret sauce. You can achieve compatibility with the UNIX spec using basically whatever kernel you want ... in theory you could get it on top of the Windows kernel if you built the right compatibility layer.

Which brings me around to your second question, getting a UNIX-like user environment on Windows. There are a couple of ways to do this. The way I would probably do it, if I were you, is get a copy of VMWare Workstation (or Server, if you can't afford Workstation) and set up a BSD (FreeBSD, OpenBSD, etc.) environment running on a virtual machine inside your Windows host. You could play around with that and do whatever you want.

If that's a no-go (maybe your computer is too slow or doesn't have the memory), then another option is to install Cygwin. Cygwin is an attempt (a good one) at grafting a UNIX-ish shell onto Windows. I have it installed on most of my Windows machines just because I find the traditional DOS command prompt to be so braindead, as I suspect you will too once you've used a proper command-line interface. However, it's not quite like having a real UNIX or UNIX-like machine and I'd caution you on using it too much for study.

What I would probably do in your shoes is ask your CompSci professor about getting a shell account on a UNIX machine at your college .... most places still have these, if you ask. Logging onto a shared system is the traditional way to use a UNIX environment and I think there's some value in at least trying this out. (Plus you probably won't be given enough access rights to really hose the whole system, which can be good.) If your school doesn't offer shell accounts, then you can get yourself a free one at the SDF; if you tell them you are taking a course, you'll get compiler access and a bunch of other neat stuff gratis.
posted by Kadin2048 at 3:30 PM on August 29, 2011 [7 favorites]


Linux uses XWindows/Xorg in its GUI layer in common with traditional UNIX environments, while Mac OS X has a proprietary GUI (Aqua).

But, confusingly, OS X can also use (and I believe ships with) an X Window implementation. It's used to run various programs originally written for more traditional Unix-like operating systems (e.g. the GIMP, which is a photo editing program).
posted by jedicus at 3:42 PM on August 29, 2011


Read the Wikipedia article on the Single UNIX Specification.

A lot of it boils down to POSIX specifications for how the user interfaces with the OS through the shell utilities and through a C-based API.

For example, a C program that uses POSIX-compliant code can generally be compiled on POSIX-compliant systems like Linux and OS X with less extra work.

If you want to run a POSIX-compliant UNIX environment within Windows, take a look at Cygwin, which is mostly compliant.

Windows PowerShell is not equivalent, though it aims to provide a command-line interface and toolset similar to what is found on a UNIX operating system. You would learn the same principles of piping commands together, handing input and output streams, that sort of thing, certainly.
posted by Blazecock Pileon at 3:43 PM on August 29, 2011


Knowing the command line is really useful for Macs and pcs. Many basic Unix commands work on all *nix systems. I used an old DOS command recently. If you're planning to be an IT professional, it's good stuff. More so for System Admins than programmers.
posted by theora55 at 4:13 PM on August 29, 2011


As a CS nerd with an emphasis in operating systems, technically OSX isn't UNIX. It has a compatibility layer, which is good enough for user program developers. That's what's meant by incorporated. OSX is a microkernel, which means unlike normal UNIX, the core OS is a collection of small modules that interact via message passing. The OSX microkernel is known as Xnu.

One of the core principals of microkernels is to do very little other than message passing, and let programs handle things like system memory allocation, filesystems, and networking. Problem is there's a ton of useful programs written for POSIX, which assumes the kernel can do a LOT of that stuff. So Apple wisely wrote a compatibility layer that implements the POSIX library by communicating with those filesystem and system memory programs. To the point that all the normal programs you'd use in UNIX systems work. That's what the Terminal gets at; it starts a UNIX shell and gives it a place to accept input and display output.

Probably the easiest way to get a UNIX playground on your windows laptop is through virtualization. Virtualbox is free and popular just install that while you download an Ubuntu .iso. Or you can try out a javascript linux emulator.
posted by pwnguin at 4:14 PM on August 29, 2011


is there something exactly like Terminal (or is that Windows' command prompt?) for Windows Seven

Dunno about Windows 7 specifically, but the Windows command prompt opens up the DOS command-line window which is much like a Unix terminal window. Note that some call DOS "baby Unix".
posted by Rash at 4:57 PM on August 29, 2011


pwnguin, you're a little heavy on theory, little light on facts.

technically OSX isn't UNIX. It has a compatibility layer, which is good enough for user program developers.

Technically, OS X (at least 10.5 and 10.6) is entirely UNIX. It conforms to the Single UNIX Specification and Apple gets to use the UNIX trademark and logo. Full stop.

UNIX is just a set of standardized APIs, available programs, and behaviors. How an operating system chooses to comply does not matter for being UNIX. Apple did it with xnu (mach, and borrowing a bunch from FreeBSD). But SUS doesn't mandate a kernel.

OSX is a microkernel, which means unlike normal UNIX, the core OS is a collection of small modules that interact via message passing. The OSX microkernel is known as Xnu.

xnu started out as a microkernel design, but it's long since diverged. Many, many functions have been moved into the kernel. For example, drivers (IOKit) have the option of running in userspace, but many are loaded directly in the kernel for efficiency reasons. Lots of stuff borrowed from the monolithic FreeBSD kernel (permissions, network stack, vfs, nfs, auditing, mac, etc) sits right in kernelspace.

Problem is there's a ton of useful programs written for POSIX, which assumes the kernel can do a LOT of that stuff. So Apple wisely wrote a compatibility layer that implements the POSIX library by communicating with those filesystem and system memory programs.

Calling libSystem a "compatibility layer" is disingenuous. It's a core part of the OS and every program on the system uses it.

Plus, the vast majority of POSIX in any OS is not implemented in the kernel, but in a userspace library. Linux has glibc and uClibc which are the equivalents of libSystem. The extent to which the Linux kernel implements POSIX is the same as xnu.

Virtualbox is free and popular just install that while you download an Ubuntu .iso.

Except Linux is not UNIX, and never will be. But I agree, it's similar enough for most purposes.
posted by sbutler at 4:59 PM on August 29, 2011 [7 favorites]


Note that some call DOS "baby Unix".

No one does that.
posted by GuyZero at 5:09 PM on August 29, 2011 [18 favorites]


Perhaps I missed it above, but another option for playing with using *nix commands in a shell setting is to use a live disc OS available from a number of the linux distributors. Basically you use a CD or flash drive to boot your laptop and it loads the kernel, etc. without effecting your Windows installation at all (turning off or rebooting your laptop without the disc or flash drive returns to booting Windows 7).
posted by BigHeartedGuy at 5:12 PM on August 29, 2011


To further confuse things, while Linux may not be UNIX™, the command shell bash is bash everywhere, even on windows. So if what you want to do is learn how to use bash, the underlying OS is not that big a deal, although every OS is going to stick files in different places just to keep you on your toes.
posted by GuyZero at 5:17 PM on August 29, 2011


I should point out that you should try to find the Putty terminal when working with Cygwin. Using VIM as a text editor for the version control utilities is much easier when not using the Command Prompt.
posted by DetriusXii at 5:19 PM on August 29, 2011


Best answer: Wow, way to get pedantic, people.

Lobbyist, there's a general class of operating systems (the program that actually runs the computer itself) that are called Unix. Technically, as a number of people above have pointed out to really call yourself a Unix you have to have gone through a certification process, so some people call all the OS's that are in this group Unix-like. The general class of Unix-like systems is pretty large, mostly because the specifications are well documented and once you've written enough of it to get the GNU (GNU's Not Unix, just to make it more confusing) then the rest of it comes along for the ride.

This generally means that if you're familiar with one Unix-like system and are plunked in front of another, you'll still be able to get a bunch done because they share a lot of the same commands and functions. A working knowledge of the minimal set of commands ("rm" to delete files, "ls" to list the contents of a directory, etc) will get you far in being able to drive just about any Unix system.

Unix started out as a command-line environment, and there are a few graphical user interfaces that can be used if you prefer a windows/mouse interface. The one most frequently found on Unix systems is called "X".

A number of years ago Apple decided that the underlying systems at the heart of their operating system (OS) were insufficient for the functionality they required as the OS developed. So they threw out the old, hired/bought a bunch of smart people, and their new OS started with a couple of Unix-like systems and built up from there. They then got it certified so it can actually be called Unix.

Despite putting a GUI on top of it, a lot of the power of Unix is found in the command line. Thus OSX retains the terminal program so that power users can still run commands and do things. This is roughly equivalent to the Windows Command prompt. In fact, some of the commands are even the same, because DOS borrowed from Unix back in the mists of time and Microsoft has been courting Unix power users ever since by re-incorporating Unix commands back into their command environment.

So, what most people consider OSX at the user level is a graphical interface running on top of a Unix operating system, with a whole bunch of extensions. What this means is that a unix program will most likely run on OSX with some modification, but the opposite is not necessarily true.

To answer whether you can use your Windows system to do your homework and play around when you're not in the lab, the answer is "it depends". What it depends on is what things beyond the command line and editor you're going to be using to develop and run your Java programs. The best way to get an answer to that question is to say to your professor: "Professor, I've got a Windows computer at home. What software can I use on it to practice the labs?", and your professor will either give you a list or tell you that he really wants all lab work done in the computer lab.
posted by Runes at 5:32 PM on August 29, 2011 [3 favorites]


Response by poster: Thanks everyone for your answers. Kadin2048 and Runes: seriously, thank you -- your answers were phenomenal. Just what I needed to hear.
posted by lobbyist at 6:22 PM on August 29, 2011


The Windows command prompt IS NOT DOS. You are not running DOS commands when you open a command prompt on any NT-based Windows. Though they may look and act the same, all those commands you run are win32 PE executables, they are not MS DOS executables. There is no DOS in Windows.
posted by Rhomboid at 6:23 PM on August 29, 2011


win32 PE executables

Continuing the pedant trend, Windows Executables that you run from the command prompt are just that -- Windows Executables. Doesn't really have anything to do with WinPE.

Strictly speaking, the Windows command prompt has not been "DOS" since Windows 2000, when command.com (the MS-DOS command-line interpreter) was superseded by cmd.exe, which was basically a modern implementation of the exact same thing that played more nicely with Windows. (However, just to confuse you, Microsoft continued to bundle command.com with windows after that for compatibility reasons)

Coincidentally, since we're talking about POSIX, it's prudent to mention that Windows technically meets all of the POSIX specifications through a compatibility layer. Nobody mistakes it for Unix though -- Windows' implementation of the POSIX spec is the absolute bare minimum, and it's not terribly useful for anything.

Microsoft's also got a new command prompt -- PowerShell, which is a fairly unique beast, and probably not a particularly great thing to learn if you're new to command prompts. I've been using command-based computer systems almost my entire life, and find PowerShell to be weird, cumbersome, and not all that useful.
posted by schmod at 9:20 PM on August 29, 2011


In practical terms for a beginner, Cygwin won't give you the full Unix experience you're looking for. It may be a Unix-style shell but it's running inside a Windows system & will give you a fair amount of headaches in porting commands & scripts between the two, especially if you're doing anything at the system level or involving services. And despite it being a platform independent language, the same holds true for Java. If you want to practice at home you'd be much better off running some form of Linux or BSD inside a VMWare virtual machine (VMWare Player, which is all a basic user needs, is completely free). There are tons of ready-to-go virtual OS installs on VMWare's website & more scattered around the Internet. You'll spend a lot less time worrying about compatibility/portability issues & more of it on learning the language you're studying.
posted by scalefree at 9:31 PM on August 29, 2011


I've been using command-based computer systems almost my entire life, and find PowerShell to be weird, cumbersome, and not all that useful.

Seconded.

If sh is a Telecaster and bash is a Strat, then command.com is a Guitar Hero game controller and PowerShell is... well... this.
posted by flabdablet at 10:08 PM on August 29, 2011 [1 favorite]


"is there something exactly like Terminal (or is that Windows' command prompt?) for Windows Seven so that I can "practice" what we did in class on my laptop?"

To directly answer your specific question, no. There isn't.

(And apropos of your other question, the Windows command prompt is totally unrelated to UNIX.)

There exist quirky though valiant attempt to provide a UNIX-like experience on Windows, including Cygwin which others have mentioned. But it isn't the same thing. And if your professor is assuming that students will be using actual UNIX systems such as Mac OS X or Linux, and you're inexperienced, then trying to use Cygwin for your class is likely to add another layer of confusion on top of an already challenging learning experience. I don't think that's a good solution.

"In practical terms for a beginner, Cygwin won't give you the full Unix experience you're looking for. It may be a Unix-style shell but it's running inside a Windows system & will give you a fair amount of headaches in porting commands & scripts between the two."

Absolutely true.

You'll have the best chance of succeeding in this class if, one way or another, you get your hands on a real UNIX system:

- Borrow someone's OS X system, or if you can afford it buy a cheap one off Craigslist. I think you can get a Mac mini for a few hundred bucks.

- "If you want to practice at home you'd be much better off running some form of Linux or BSD inside a VMWare virtual machine (VMWare Player, which is all a basic user needs, is completely free). There are tons of ready-to-go virtual OS installs on VMWare's website & more scattered around the Internet. You'll spend a lot less time worrying about compatibility/portability issues & more of it on learning the language you're studying." Seconded. If your PC can handle it, this may be your best option after getting a Mac.

- Get a cheap PC and install Linux. (You may need some help with this.)
posted by eeby at 10:11 PM on August 29, 2011 [1 favorite]


Doesn't really have anything to do with WinPE.

Forgive me if I'm not interpreting your message correctly, but here I'm referring to the Portable Executable format which describes the file format used by all executables and libraries on Windows, not the Preinstallation Environment which lets you boot from a Windows LiveCD.
posted by Rhomboid at 8:06 AM on August 30, 2011 [1 favorite]


Using the metric, "If I ask if this is Unix, will I get twenty answers that are technically correct, yet vehemently disagree?" then this is most assuredly Unix.

There is a Unix family tree that may clear up some of the relationships for you. Historically, Unix was proprietary, and in the 1970s attempts were made to duplicate what Unix did without using the proprietary bit -- for economic, philosophical, or practical reasons. Later on, some of these efforts split in different directions, while all of them cross-pollinated features from each other. This spawned a lot of divergent but ultimately closely related OS implementations. Often there were passionate justifications made for one choice or another, with lifelong loyalties given to one implementation or another.

For you, the important thing to remember at this stage is that almost none of that matters. For a lot of people, the important bits are the command line utilities, most of which you can find in gnu or something closely similar in a non-gnu environment or you can port gnu to that environment and have both. For others, i.e. in web development, the LAMP software environment is what they need to concentrate on. At the nittier and grittier level, workhorse corporate functions such as transaction processing and distributed database development, much is going to depend on what you are actually doing and what you actually must interface with, but if you're well versed in the basics your skill set should be flexible and portable enough to handle a slightly different named OS.

What you really want to develop for yourself is not so much proficiency in a single OS or implementation, but the Unix mindset, which is built around common tools used in conjunction to produce consistent results. Understand this, and you'll be able to adapt what you know to a different environment with, if not exactly always ease, at least confidence.
posted by dhartung at 12:14 PM on August 30, 2011 [1 favorite]


Wubi lets you install Ubuntu Linux as an uninstallable Windows app (roughly speaking.) As has been noted at length, Linux isn't precisely UNIX, but if your aim is practicing with command-line tools, it's close enough (you'll find the terminal emulator under "Accessories" in the main menu.)
posted by Zed at 10:08 AM on August 31, 2011


Just as one final suggestion, though this is getting a bit into the weeds ... if you do end up running Linux (which is a fine idea) but want to become proficient enough to sit down at the console of a commercial UNIX system, install ksh.

If you use Ubuntu this is as easy as "sudo apt-get install ksh" to install it, and then "chsh -s /bin/ksh yourusername" to set it as your default shell. (Don't run those unless you understand how they work, though; it's a bad habit to blindly run commands without understanding them.)

The default shell used by Linux is bash, which varies in some arguably-subtle-yet-nonetheless-important ways from the traditional ksh shell used on most UNIX variants. You can get a real holy war going over which is "better," though I don't have a horse in that particular race; they're just a little bit different in how they do certain things.

I learned bash fairly thoroughly by playing around on Linux boxes, and had a few frustrating experiences the first time I sat down at an AIX console where bash wasn't installed.

That said, if you don't think you're ever going to use a commercial UNIX system, you could just choose to learn bash -- most Linux and BSD systems will have bash as an option, and it's in some ways more pleasant to use.
posted by Kadin2048 at 11:27 AM on August 31, 2011


Of course, since bash is free, you can always install it on systems that don't have it already.
posted by grouse at 2:58 PM on August 31, 2011


Good luck running that past your local AIX admin... :)
posted by Kadin2048 at 6:51 PM on August 31, 2011


It shouldn't require root to install.
posted by grouse at 7:35 PM on August 31, 2011


« Older Good camping near Sloquet BC?   |   Looking for conference ideas... Newer »
This thread is closed to new comments.