Wednesday, May 11, 2011

who needs /etc/passwd?



A funny thing happened to me today...

I had expanded a zipped file into our development server's /tmp directory, and accidentally littered that directory instead of expanding the files into their own subdirectory.
I wanted to clean those files up, so I started typing: 
sudo rm -rf    
....but then I thought, maybe I should be safe about it and only remove my files.
I forgot the syntax for removing files owned by a specific user, so I googled it, came back, and pasted in the command to find a given user's UID:
cat /etc/passwd |grep dtanner
then I hit enter.
That command somehow strangely didn't work, but whatever.  I cleverly realized I didn't need to read /etc/passwd for my own UID, so I typed "id", got my uid, then did the find and piped my files into the rm command.  Problem solved.

But...about five minutes later, one of our developers asked me why he couldn't sudo any more.  I thought that was a little odd, since he should've been able to.
I tried it myself, and got the message "user root does not exist".

*gulp*

I figured I had to have been the one to cause this problem, so I did a quick check of my command history.  About 10 commands back, I found this brilliant gem:

832  sudo rm -rf cat /etc/passwd |grep dtanner

*cough*. ohhhh fuuuuuuuuuuuu^*.

It actually turned out to not be that severe of a problem.  I had a backup of the /etc/passwd because of the /etc/passwd- automatic backup file, and after booting to single-user mode and fixing file ownership of some files that lost their owners during my multi-tasking mayhem, the server was back up.  

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home