I have just done something very stupid...
I was connecting to a Mac OS X box in my office remotely and I tried to grant rights to certain users to run the sudo command. Here is what I did:
- sudo vi /etc/sudoers
- edit the file
- :wq (i.e. save and quite in vi)
Experienced users should be able to point out my stupid mistake here. Yes, I should never edit the sudoers file directly using an non-root user... Reason? It is really simple - what if I accidentally screw up the file?
$ sudo vi /etc/sudoers
>>> sudoers file: syntax error, line 23 <<<
sudo: parse error in /private/etc/sudoers near line 23
Just like this.
...
Yes. I have no way to fix the problem until I can get back to the office next Monday and boot the box into single-user mode.
Hurray! No more work this weekend!
...
Anyway, remember to use the visudo command to change the file, it can help to check the syntax before finalizing changes... Or at least I should su to root before editing this file, so that I don't need sudo to fix the sudo problem...
Note: this is not only applicable to Mac OS X but also other *-nix system too.
2008-09-29 Updated: I finally got back to office and boot the Mac into single-user mode. However, I need one more trick to update the files as the root filesystem is mounted at read-only by default. Here is the trick:
# mount -uw /


0 comment(s):
Post a Comment
HTML Tags allowed (e.g. <b>, <i>, <a>)