… why it is a good idea, nay a must, to keep a live cd around.
After a system upgrade earlier tonight I got a message about an new sudoers file (placed in /etc/sudoers.pacnew) that had been downloaded and wanted me to take a look at it.
So I made a couple of mistakes here:
- I didn’t stop to think it through enough, which lead to…
- I didn’t edit the new sudoers file first before moving it in place, but also…
- I MOVED the original file to a backup spot, instead of COPYING it
- Of course, none of this would have mattered, had I logged into the root account before doing stuff, instead of relying on sudo… for tampering with sudoers… I’m so smart! S-M-R-T.
So, instead of doing things the right way, i.e.:
$ sudo su
# cp /etc/sudoers /etc/sudoers.bak
# vim -p /etc/sudoers.pacnew /etc/sudoers.bak
# mv /etc/sudoers.pacnew /etc/sudoers
what I did was (NEVER EVER DO THIS!):
$ sudo mv /etc/sudoers /etc/sudoers.bak
The instant I hit enter, I got a sinking feeling, knowing I’d frakked up. Attempting to undo the damage
$ sudo mv /etc/sudoers.bak /etc/sudoers
only resulted in an error message:
sudo: can’t stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
There might have been a root password set, but if so I couldn’t for the life of me remember it. Great! What now?
I knew of course I could access the filesystem from a live-cd but I hadn’t actually needed to do this before, so I was unsure about how to proceed once in the live-session (I had a vague notion about having to fiddle with chroot, something I have not done much of) but as luck would have it, hesa was online and helped me out (no need for chroot, just mount the partition, move some files, unmount, restart.)
Upon booting into Knoppix it was a small matter of
- remembering which of the disk, and partitions which housed the root-partition, and
- mounting it:
$ sudo mount /dev/sdb3 /media/sdb3
$ cd /media/sdb3/etc/
$ sudo mv sudoers.bak sudoers
$ cd /
$ sudo umount /media/sdb3
$ sudo reboot
Now, this would have been the sane thing to do, and start over from inside Arch… but instead I moved sudoers.pacnew into sudoers, forgot to edit it, rebooted, realized my new mistake, rebooted again (a hassle, since sudo reboot wasn’t available), remounted sdb3, edited sudoers adding myself again, and finally rebooted. And all was well.
So now I know, first hand… Live-CDs FTW!
:wq
Related posts:
- 2011w30 Hacking the shell I’ve scratched some itches this week, some...
- 2011w23 myConf This is a technology demonstrator of the FSCONS myConf...
- Easy identification of USB storage disks I have during the last couple of weeks begun the...
- Highlighting text on the command line A couple of days ago, as I was searching through...
Related posts brought to you by Yet Another Related Posts Plugin.

Haha fatal error my friend
I wouldn’t go so far as to call it fatal, since I did manage to undo it, but rather VERY stupid ;D
Hopefully it will be a looooooongcat iz looooooooooooong time before that ever happens again.