The reason of the error is because you are not logged in as the root user on terminal.
If you already have root use enable on your mac in terminal type
$ su
If you dont have root user, you need to enable it using the following steps
- From the Apple menu choose System Preferences….
- From the View menu choose Users & Groups.
- Click the lock and authenticate as an administrator account.
- Click Login Options….
- Click the “Edit…” or “Join…” button at the bottom right.
- Click the “Open Directory Utility…” button.
- Click the lock in the Directory Utility window.
- Enter an administrator account name and password, then click OK.
- Choose Enable Root User from the Edit menu.
- Enter the root password you wish to use in both the Password and Verify fields, then click OK.
More at the same on http://support.apple.com/kb/ht1528
Atleast it works for me after getting stuck for couple of hours.