The other day Rob comes into my room. “I need some help,” he said. “I made a mistake on my Sun box and I'm wondering if you could help me.”
Turns out Rob renamed a critical directory (
/usr) and not only were
most of the commonly used programs stored under it, but so were all the
runtime libraries used by these commands, so nothing would run except for a
few statically compiled programs (programs that contained the libraries they
needed inside themselves). Nothing but the shell,
fdisk were available.
Now, I'm used to recovering with minimal commands but there was no way to rename a file, or change its permissions.
Heck, we were worse off than those in the classical Unix horror story. Had I known SPARC assembly and how
to call the kernel for Solaris 7, then yes, we might have had a chance.
Create the smallest binary to either create a directory, or to rename a
directory, and we'd be set. While it seems hard to create a file without
the normal commands one usually uses for such a task,
is a shell built-in, and using that with redirection and the
ability to specify arbitrary octal constants (with the “\nnn” notation
supported by the shell) and you have your program.
Okay, so you can't change the permissions on it, so pick some file you no longer need with execute permissions and write over that, then you'll be able to execute the hand-written program to get back into business.
Granted, that's if either of us new SPARC assembly and the executable format.
Since neither of us did, there wasn't much that could be done.
Well, maybe mounting the drives on another Solaris box, but Rob really didn't care all that much since we was planning on reinstalling Solaris on that system anyway.
But it was possible …