Are the unix commands the same for Mac and Ubuntu?

I wonder if the unix commands (cp, mv, grep, args etc) are the same for Mac and Ubuntu.

Do they have the same parameter lists and so on or do they try to stay the same but are slightly different?


The basic commands and options are the same, but each implementation provides its own additional commands and options.

Since shortly after the birth of Unix, there have been several flavors of Unix sharing a basic command set but each with their own extensions. Implementers regularly grab features from one another, so if system X introduces a new option, it may become available in system Y after a few years.

Eventually, the POSIX specification was elaborated to standardize on a common subset of features. This standard is currently managed by the Open Group. Although the current version of the standard is Single Unix version 4, most systems only implement version 3. On Ubuntu, the susv3 package contains the Single Unix version 3 specification. This is a reference document, so it can be a stiff read, but it can be useful at least to check whether an option you already understand is standard.

There are POSIX-conforming tools for most desktop/server operating systems. Anything unix-based (Linux, Solaris, *BSD, OSX, ...) has them natively. The native utilities on Linux are the GNU utilities. Several implementations exist for Windows, including Microsoft's Services for Unix and ports of GNU utilities such as cygwin and GNU Win32 utilities.


OS X (Darwin) uses BSD versions of the standard tools. Ubuntu (and Linux in general) uses GNU versions. They are very similar, but the differences (such as presence and order of options) can trip you up if you're not careful.


They are different enough that (1) you cannot rely on them being the same, (2) it will frustrate you a great deal, and (3) you really should carefully test any script you plan to use on both systems.

The way I usually handle all this is to install the GNU coreutils and find and use those versions in preference to the Mac ones. You can install the GNU versions via one of the *nix packaging tools for OSX:

  • Homebrew
  • MacPorts
  • Rudix
  • Fink

Those are listed in my order of preference, but you should investigate to see which will fit your needs best.