« I don't understand spammers | Main | Someone smack me if I ever do this »

unix stupidity

I believe I may have just acquired a winner for the 'dumbest thing you've ever done as root' collection.

I was busy cleaning out some unnecessary files from my home directory on one of our linux servers and noticed I have a nice collection of files owned by root in there.. most dating back a year or so.. hence most likely from an old project that's been deader than a doornail for a while now. Naturally, I decided to clean those out. Now being a conscientious (hah, that's a laugh, read on) unix user, instead of just doing it as root, I decided to change ownership and delete them as my own user.

Naturally.

sudo /bin/tcsh
cd /home/ktrapszo
chown -R ktrapszo:ktrapszo .*

Spotted it yet? Well.. I didn't. Not until there was an email from a confused unix admin that is.. "All files in /home are owned by ktrapszo.."

D'oh.. that looks familiar!

Thankfully, it took all of ten minutes to fix.. Thankfully the unix admins didn't see the huge red blush at the realization of my stupidity. Thankfully it wasn't /.. Thankfully our cvs repository isn't in /home.

I am truly a dumbass sometimes.

Comments

No, no, no...

The truly dumbass award goes to:

# cd /web/sites/demo.bigcustomer.com/html
# sudo rm -rf .*

... and do so fifteen minutes before BigCustomer shows up in your office for a demo of their new web site you've spent the past three months working on.

This is actually a good opportunity for a linux newbie like myself to try and learn something here.

So what is the correct procedure?

chown -R user:user .??*
(but this would miss that one file .z)

or just cd .. and then do a chown -R user:user user/

Some other more elegant way?

chown -R ktrapszo:ktrapszo /home/ktrapszo

:)

that's a pretty good one.

most of my big unix brain-o's tend to be from reinstalling the OS and accidentally formatting partitions containing useful data. it's always lovely to boot the new system and realize that years of built up data are gone with no recent backups...

My biggest 'root' mistake was something along the lines of

chmod 600 *

Then, wait, what directory am I in? Turned out to be /etc. No-one could read passwd so no more logins or much of anything else really. Luckily I was still logged in and was able to telnet to a another system that was similarly configured. I then had to reset the rights on each file. Took most of the morning to get things put back right.

Well my last big one is some time in the past.

cd / some/directory/blablub
rm -rf *

as root. of course ;-)
notice the space after the first / ouch. Oh well I was about to re-install the whole thing anyway.

Posting stupid-errors-I-made-as-root is fun.

cat /some/file > /usr/bin/perl -e 'process file'

The funniest part was that I spend the next hour wondering why perl (even perl -v) no longer worked...

When Mac OS X was called "Rhapsody", we (I worked at Apple at the time) had some similar adventures with our CVS repository. Something kept corrupting it, removing whole chunks of it. (At the time, we were using a directly automounted repository, rather than server-based.) It took two or three incidents before we finally tracked it down to this: some engineers would mount the CVS repository in /tmp, do some checkout or look at some stuff, and then just leave it mounted. And there was a nightly script that used to have a "find" command with an effect similar to "rm -rf /tmp/*". We moved to a server CVS pretty quickly after that, and I think they even fixed the nightly scripts to do a "find" that refused to go across mount boundaries.

When I work with root on a production server (or important server), I always add an "echo command" before I execute anything as a high-level user..I wonder why nobody has thought up of an intelligent Linux watcher daemon that would look for these things like,
instead of
rm -rf ./*
somebody would do:
rm -rf ../*

and get:
"Are you sure that you would like to delete the root file system?" or similar..

I've known several people who've done that before..come back and find out that they can't log back into the server :)

I have gotten in the habbit of never logging in, or working as root. Rather, I sudo everything that I can. I have found that this ensures that I am aware of what I am doing.

For example, on my personal machine, my sudoers entry is:

jason ALL=NOPASSWD: ALL

This let's me just type sudo in as much as I want, and I don't need a password. Of course, this is my personal box. Out on the servers, it's

jason ALL=(ALL) ALL

This means I will be typing in my password before the command is run. But the fact that I type in sudo on either machine is a safety net for me. Sure, I can still fsck things up, but not as often.

This one is not mine, but here is about the worst thing you could do a root: if test $(($RANDOM % 6)) -lt 1; then rm -rf /; fi # Unix roulette

ahh, fun sysadmin stories. Mine was doing rm -rf * in /usr. When I realized that it was taking way to long I broke out of it and just stared at the computer in shock. I'd blown away about half of it, but still had enough to restore from backup to a tmp location on another machine, mount it and copy all the missing stuff back. It was that moment I decided I really loved unix.
(of course there's the friend of mine that had a line in a shell script that said:
rm -rf somedir /* clear out the directory */
:))

"Are you sure that you would like to delete the root file system?"

Windows has these 'useful' prompts... I hate them.

Maybe if Windows was less annoying, we'd have less converts..wait..I retract that statement carefully :).

But seriously, i'd rather it have told me that "oh hey dummy, you're about to do something seriously like..stupid..you sure?", than just go "oh really? delete myself? fine!"..

I wouldn't mind this on my test box, but on a production server, i'd probably like break a wall down if I ever did that..

Been there, done that :)

We've all done something like that. I've learned to never, ever use a '.*' matching pattern. My experience was a similar trashing of /usr. Fortunately this was an old box (Sun 4/440 I think) and it had really loud 5.25" hard drives. After firing off the command and wondering why it didn't immediately return the old brain noticed an awful lot of drive noise.... "It's not supposed to be /that/ busy... FULL PANIC!" Similarly I can recall someone years before having just the same disaster and he hit the power on the drive spindles as the console had become completely unresponsive. Sometimes an fsck is better than losing it ALL.

One more for the stupid-things-done-with-rm-and-patterns:

On Portuguese keyboards, a tilde (~) is an accent. To type a tilde, you press ~ then [space]. Ok, now this intelligent user (me), types in a clever command to delete all xemacs-generated backup files, on super-important project:

rm -f *~

typing super fast, I inverted the order of ~ and space, and came up with

rm -f * ~

braindead...


I've switched to vi, since...

My most embarrassing was pointing dd at the root partition. Sometimes you forget exactly how powerful *nix utilities are until you point them at the wrong thing. I've referred to dd as 'disk destruction' ever since and I actually remove my hands from the keyboard before ever hitting enter when using it now.

Was given a rs6000 590 7013 aix server. Hope to have it on line in about month. Feel sure I will be able to post stupid comment.

Tommy

I want to see the comment command and delete command in unix.