Hacker News new | past | comments | ask | show | jobs | submit login

There are some bad things that can happen in the UNIX shell.

Ofc. unset (empty) variables "rm -rf ${variable}/" ... I guess paths are given without a slash at the end (also for that reason).

But also other commands: "hostname", if you type "hostname help" then your new hostname is set to "help". For us that means a full rebuild/reinstallation of the machine is necessary.

This surely has been discussed before, but why not (again): Let me know of your horror stories, if you like.




A really simple typo - but it's always stayed with me. Many years ago on a Very Important Solaris Box(TM) I wanted to check when it had rebooted a few months before, so typed "last | grep reboot". Only I forgot to put in the 'grep'... (and if you're not a Solaris person - 'reboot' is pretty brutal on it - you may as well just pull the power cable out the back).

What a fun day that was....


Being primarily used to, and mainly using Linux.

Then using the killall command on a Solaris box, which just happened to be running the company's Oracle database...

Cue the support line phone ringing off its hook.

Cue BOFH Excuse : "Hmm it appears the server running the database has crashed. We're rebooting it now", etc etc.

Lesson learned : killall on a Sun/Solaris box behaves VERY differently from the killall on Linux :D


The similarity of "rm -rf *" and "rm -rf /" makes me nervous any time I "cd" somewhere and then issue the first.

There is no trash can in my Unix, deleted is gone forever.

A move (mv) or copy (cp) just overwrites files with the same name (as default)

Right clicking (&executing everything (every line) that just got pasted from the current clipboard/copy-buffer)


Why would you cd somewhere and then do rm -rf * when you can just rm -rf somewhere?

Having your shell expand * is just asking for trouble; on most systems you'll have no problems creating more entries in a directory than you can specify arguments on the command line, so rm -rf * will not work from 'somewhere' but rm -rf somewhere should still work fine.


> if you type "hostname help" then your new hostname is set to "help". For us that means a full rebuild/reinstallation of the machine is necessary.

What the hell? Why not just change it back?


I think the actual problem was that someone typed "hostname " (that is "hostname" and 2 blanks), which did set the hostname to " " (a blank). Yeah sure changing it back may work (it didn't for the colleagues that told me that).

Here is another one: I once shut down a server because I wanted to know how to shutdown & reboot. I typed "shutdown -h" (I thought that would display help-pages :)

It was the option to "halt" immediately.

We needed to open a ticket to start the machine up again.


I started using these recently:

set -o nounset

set -o pipefail

set -o errexit

set -o xtrace

I added them to all my scripts, and I also added all except errexit to ~/.bashrc

The first one would save you from unset variables.


The other classic rm: "rm * .o"

That's what taught me the importance of backups.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: