Hi,
I am relatively new to the MAC platform. I find that I need to use sudo for a variety of things, such as installing X11 programs via fink.
I am unable to use sudo -- when I type
sudo command
I get back the message
sudo: can't stat /private/etc/sudoers: No such file or directory
I would be happy to make the file sudoers and put it in /private/etc/, but that seems to require root access, which I don't have since I can't use sudo.
The solution to this problem will be very apprecieated -- I couldn't find a solution after several google searches.
Thanks, Masud
Hi Masud -
Bit of a "chicken and egg" problem eh? You need the sudoers file to use sudo, but you need to use sudo to create the sudoers file.... Not to worry, there is a way around the problem. A warning though, the following method will make use of the UNIX command-line as root (superuser), so double-check every command before hitting
!
First of all, you need the sudoers file. You can download this from http://www.bgstech.com/download/sudoers
The file should open in your browser, simply save it to your desktop on your Mac. Make sure the name stays 'sudoers' (without the quotes).
Now, take note of your home directory. Open a terminal and type "pwd" (again no quotes). In my case it's /Users/brian. You will need this in a few moments.
Now, restart your mac. As soon as you hear the chime, hold down Command-S and don't release them until you see the familiar gray apple logo screen get replaced with a black screen and white text. Now wait until you see the "localhost #" prompt. Now type:
/sbin/fsck -fy
This will repair any inconsistancies in your filesystem. It should take a few minutes to run to completion. You'll know it's done when you see the "localhost #" prompt show up again. Take note, if the program finds and repairs and problems and prompts you to reboot, then follow it's lead! Type:
reboot
and again when you hear the chime, hold down Command-S as before. Repeat the "/sbin/fsck -fy" command, rebooting if prompted, until 'fsck' tells you that the volume appears to be OK. At this point, type;
/sbin/mount -uw /
This remounts the boot volume in read-write mode so you can make changes to it. Now you can put the sudoers file in place with the following commands. Note the use of the path to your home directory you noted down a few moments ago:
cd /private/etc
cp /Users/yourdirectory/Desktop/sudoers ./
chown root:wheel ./sudoers
chmod 0440 ./sudoers
sync
The commands are basically putting you in the correct directory, copying the sudoers file into place, and setting correct ownership and permissions on the file. The final command flushes disk caches to make sure anything help in memory is flushed to disk.
Now wait a few seconds to make sure sync does it's thing (which it doe behind the scenes), and then finish up with:
exit
At this point your mac will continue to boot until you see the familiar login screen. Login and you should now be able to use "sudo" no problem. As a final precaution, once everything is ok, you might run "Disk Utility" and select "Repair Permissions", and once completed, reboot normally. At this stage, you can delete the copy of sudoers you downloaded to your desktop.
I hope this fixes the problem for you. Let me know ho you get on, and if the problems persist we'll look into it some more.
- Brian
--------
Brian S.
MacOSX.com Technical Support
brian@macosx.com