Is there a root password on OS X and Ubuntu?

I can answer only for Ubuntu.
In Ubuntu the root user has a locked password. From passwd man page:

   -l, --lock
           Lock the password of the named account. This option disables a 
           password by changing it to a value which matches no possible 
           encrypted value (it adds a '!' at the beginning of the password).

You can see the ! in /etc/shadow.

A user with a locked account cannot change its password, but root can, without prior entering of the old password.


Here's how to unlock (?) or create an actual root user in OSX:

  1. System preferences
  2. Users & Groups
  3. Login options (click lock and authenticate here)
  4. Click "Join" (NAS)
  5. Open Directory Utility
  6. Click the lock (authenticate again)
  7. Edit menu -> enable root user
  8. (Edit menu -> change root password)

Enjoy !


As enzotib said, Ubuntu has a root account but it's locked by default.

Now, about Macs:

As you can probably guess, root (along with all the daemon accounts) doesn't appear in the "Users & Groups" section of Settings.

Looking at my mac's /etc/passwd, there is an entry for root, along with a message

Note that this file is consulted directly only when the system is running
in single-user mode.  At other times this information is provided by 
Open Directory.

I tried to find the Open Directory user list, without success, but in the configurations there were mentions of explicitly giving root permissions even though they're implied. I was never prompted for a root password when I first set the machine up, so I'd guess the root account is locked as it is in ubuntu. I didn't (and don't really want to) try giving root a password and logging in with it, but you probably could.

The passwd line:

root:*:0:0:System Administrator:/var/root:/bin/sh

The perl command from keith's comment adds a :0 to the end. No password hash. There's no shadow file I can find either, I haven't been able to find them anywhere to check whether root might have a password.