How UNIX is OS X?

Caze

macrumors newbie
Original poster
Jun 10, 2013
1
0
I always hear people say it's POSIX compliant, and that they took a lot from FreeBSD and NeXTSTEP. But in reality, how unix like is OSX?

If I opened up a terminal, entered sudo bash, (I already read that OSX doesn't come with a root user by default) and entered the command "chmod -R a+rwx /", would it actually do it what it would do on a real UNIX like OS? Would a bash script containing nothing but basic *NIX utils work as I would expect it to on OSX?

If anyone here has a lot of experience with Linux or other UNIX like operating systems, how similar would you say OSX is?
 

leman

macrumors G4
Oct 14, 2008
10,287
4,808
OS X is basically FreeBSD ;) It is a 'real Unix', not a Unix-like OS. And actually, much of the current FreeBSD code draws from Apple codebase. Anyway, the kernel and the Unix base system of OS X is open source, you can look it all up. Also, you have all the man pages.
 

Bear

macrumors G3
Jul 23, 2002
8,089
4
Sol III - Terra
...
If I opened up a terminal, entered sudo bash, (I already read that OSX doesn't come with a root user by default) and entered the command "chmod -R a+rwx /", would it actually do it what it would do on a real UNIX like OS? Would a bash script containing nothing but basic *NIX utils work as I would expect it to on OSX?

If anyone here has a lot of experience with Linux or other UNIX like operating systems, how similar would you say OSX is?
Yes that chmod would do what you expected. And the basic Unix utils will work as you expected baring the differences between different Unix variants.

Very similar. It is Unix.
 

chown33

Moderator
Staff member
Aug 9, 2009
8,490
4,497
Restivus
http://en.wikipedia.org/wiki/POSIX#Fully_POSIX-compliant

If anyone here has a lot of experience with Linux or other UNIX like operating systems, how similar would you say OSX is?
Linux is not fully POSIX compliant:
http://en.wikipedia.org/wiki/POSIX#Mostly_POSIX-compliant

Yes, there are differences in commands and command options. If you want to know whether a particular shell script or command works identically on OS X, you have to specify the command, and then check which version of the command is present on a given version of OS X.

The OS X commands are mostly available as source under the Darwin OS project:
http://en.wikipedia.org/wiki/Darwin_(operating_system)
 
Last edited:

benwiggy

macrumors 68020
Jun 15, 2012
2,186
15
I always hear people say it's POSIX compliant, and that they took a lot from FreeBSD and NeXTSTEP. But in reality, how unix like is OSX?

If I opened up a terminal, entered sudo bash, (I already read that OSX doesn't come with a root user by default) and entered the command "chmod -R a+rwx /", would it actually do it what it would do on a real UNIX like OS? Would a bash script containing nothing but basic *NIX utils work as I would expect it to on OSX?

If anyone here has a lot of experience with Linux or other UNIX like operating systems, how similar would you say OSX is?
As stated, OS X is "Certified Unix™". http://www.unix.org/what_is_unix/the_brand.html

OS X does have a root user, but it is disabled from being logged into for security purposes. You can use root-level behaviours by using sudo.

Yes, the command you give works as on other Unixes.
 

Dalton63841

macrumors 65816
Nov 27, 2010
1,449
5
SEMO, USA
...I already read that OSX doesn't come with a root user by default...
Well that's just not accurate. Go to /System/Library/CoreServices and launch Directory Utility. Click on Search Policy, and click the lock in the bottom left corner. Enter your password, then go to Edit in the menubar. There you will see an option to Enable Root User. Select it, give it a password, and log out.

The root user is simply disabled by default, for safety reasons. And for the record, the root user account is handy for a few niche things, but keeping it enabled is just not a good idea.
 

LordDeath

macrumors member
Feb 28, 2013
45
5
It depends on what you are doing.
Most command line tools are stuck at their latest GPLv2 licensed version and Apple is against using any GPLv3 software in their operating system.
If this causes some problems to you, you can easily switch to the newer versions with the help of package managers like MacPorts.

In the future this could cause bigger problems (security or compatibility issues) and Apple needs to either switch every little tool to an equivalent permissive licensed alternative or they have to change their view about the GPLv3.
 

bradl

macrumors 601
Jun 16, 2008
4,023
11,826
I always hear people say it's POSIX compliant, and that they took a lot from FreeBSD and NeXTSTEP. But in reality, how unix like is OSX?

If I opened up a terminal, entered sudo bash, (I already read that OSX doesn't come with a root user by default)
Hate to say it, but whoever wrote what you read is dead wrong:

bradl@bellicha:~> grep root /etc/passwd
root:*:0:0:System Administrator:/var/root:/bin/sh
bradl@bellicha:~> uname -a
Darwin bellicha 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64

So there definitely is a root user on a Mac. It is, however, set up more "Ubuntu Style", where there is no root password, but all root commands could be run via sudo. BTW. You could run "sudo su -", supply your password, and become the root user, with root's entire environment (including shell).

and entered the command "chmod -R a+rwx /", would it actually do it what it would do on a real UNIX like OS? Would a bash script containing nothing but basic *NIX utils work as I would expect it to on OSX?
Yes, and yes. that's what makes it completely portable from one *nix OS to another. The only thing you would have to worry about is the path to where the bash binary lives.

If anyone here has a lot of experience with Linux or other UNIX like operating systems, how similar would you say OSX is?
20-year Linux sysadmin here. It's very similar. Like someone above said, it is more similar to {Free,Net,Open,386}BSD than anything else.

BL.