I've added a counter (of successful commands in a row) to my bashrc. I've seen it as high as 120.
function promptCommand()
{
LAST_STATUS=$?
# Set title of window to dir, then add new line to prompt.
PS1='\[\e]0;\w\a\]\n'
if [ $LAST_STATUS -eq 0 ]; then
((successes++))
PS1+='\[\033[1;32m\][$successes]'
else
successes=0
PS1+='\[\033[1;31m\][0 $LAST_STATUS]'
fi
PS1+='\[\033[0;32m\] '
PS1+='\w $(date +%H:%M) \$ \[\033[0m\]'
}
lastStatus=0
successes=-1
PROMPT_COMMAND="promptCommand"
> The reaction from the OS is actually rather underwhelming.
Somehow related, a coworker at a previous place unmounted some disks on an old AIX production box. It took him a solid minute to realise he had mistakenly unmounted / due to a typo (yes it was possible) as old processes with already opened files were happily serving stuff and only new attempts at opening files were beginning to produce errors.
Also, a similar interactive mishap in the heat of the action:
somebox:~$ rm * .o
rm: .o: No such file or directory
somebox:~$ # ...
somebox:~$ # *stares a prompt*
somebox:~$ # Wait, what? _Please_ tell me those C files were versioned! (The answer was, obviously, "no")
Within the first year or so of having installed Linux (mid-90's), I made the mistake of accidentally deleting /etc (wrote a script to tidy /tmp at boot, but it hadn't cd'd correctly).
That was possibly the best unix/linux learning experience of my life. Rebuilding /etc sufficient to rescue my files I cared about before a reinstall. Rescue CDs weren't really a thing, USB was a new thing at the time, and I was on dial-up.
A few months back I was wiping some old drives using a USB->SATA adapter plugged into an old Linux machine I keep around for experimenting on random things. Mostly because I could just leave it to run for however long it took. There were two drives in the machine, sda and sdb. So the drive came up as sdc.
So then I typed:
$ shred -n1 -v /dev/sda
Took me about 4 seconds to realize what I did before hitting Ctrl-C.
Then, I sighed. Considered whether I could save anything. Realized there wasn't anything on there worth saving, and reinstalled. :)
I'm usually much more cautious than that and I'm thankful it happened on a dumb test machine at home and not something important, but it was still a bummer and my first real sysadmin-type screw up. Mistakes happen, though. Even Linus once dialed his hard drive [0].
Waay back in the day I was using crusty old shared Sun3 workstations. The keyboard was really sticky because, well, some students are pigs. I developed the habit of SLAMMING the Enter key on each command, until one day I was deleting backup files (rm *~) and my fingers grazed the delete button before striking Enter...
Years ago, I forget how, I managed to wipe the partition table of a DOS PC. I ended up reconstructing it by hand using MS-DOS Debug and a copy of Peter Norton's book.
Another fun one: "killall" on Linux kills processes with names matching a string. "killall" on Solaris reboots the machine ...
On Illumos rm -rf / does nothing. POSIX says that removing / has undefined behavior, so the obviously smart (useful, user-friendly, GOOD) thing to do is to do nothing, as that fits "undefined behavior".
That's quite funny... but ultimately futile. It doesn't say what happens if you say "DROP TABLE xyz<ENTER>WHERE...ohshit". (The <ENTER> bit is because you're used to doing that in your preferred SQL-DB editor.)
One should NEVER do anything non-scripted on a production system. ALWAYS enter it into a file and then do the "run-sql-from-a-file" command.
EDIT: Yes, I also realize that "rm -rf /" can theoretically happen if you have a bad variable substitution, but you MUST turn on the flags that cause your shell to error out instead of just substituting the empty string.
If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands.
That also reminds me of something similar, where a random offset in /dev/mem is clobbered. What potentially makes it more amusing is that it would probably just crash your machine, rather than completely destroy it.
"Update 2015-04-18 -- I suppose I should finally clear this up: The autocorrect functionality I originally described here was a feature of the first Linux systems I ever used, so I assumed it was how every Linux system worked by default. Since then I've come to understand that it's a completely optional extra doodad."
There's the cdspell shopt: "If set, minor errors in the spelling of a directory component in a cd command will be corrected. The errors checked for are transposed characters, a missing character, and a character too many. If a correction is found, the corrected path is printed, and the command proceeds." (https://www.gnu.org/software/bash/manual/html_node/The-Shopt...)
Just have to mention, since I recognize the domain, that Sam Hughes has some excellent science fiction freely available in a serialized form here as well. Well worth investigating.
This is funny. I think I’ll stick with “thefuck” [1] though.
It would make a good prank to set up on someone that left their machine unlocked. Not sure if it’s more funny than changing their background to goatse.
In all seriousness, what if it's a machine that no one should ever really be running commands on? This could be an effective, albeit naive, way to discourage undesirables in the system.
I was in a sys admin class with a friend of mine and we both had access to the same machine to work on our assignments. I aliased each and every common command to `sl -f` on my friend's user as a prank (he never actually logged in as it turns out). However, my instructor, while projecting his screen to 150+ students (and recording) picked our box and my friend's user to use as an example. My instructor was flabbergasted for a few minutes and the class got a kick out of flying trains. :D
It would be nice for someone to develop a suicide-g++. Whenever you compile a program that results in Undefined Behavior, the execution of it will wipe your disk.
bash corrects your spelling?? Is this a cute way of saying "I made a typo that turned out to be a legit command" or is there some DWIM I don't know about (and thankfully don't have enabled)?
One idea I like is randomly flipping a bit on the root partition every day or so. You'll have to take an incredibly long time to find the problem, of which there will be one eventually.
[+] [-] kingvash|8 years ago|reply
[+] [-] kedean|8 years ago|reply
[+] [-] mondoshawan|8 years ago|reply
[+] [-] sp332|8 years ago|reply
[+] [-] hyperpallium|8 years ago|reply
[+] [-] warent|8 years ago|reply
[+] [-] kakarot|8 years ago|reply
[+] [-] omginternets|8 years ago|reply
[+] [-] lloeki|8 years ago|reply
Somehow related, a coworker at a previous place unmounted some disks on an old AIX production box. It took him a solid minute to realise he had mistakenly unmounted / due to a typo (yes it was possible) as old processes with already opened files were happily serving stuff and only new attempts at opening files were beginning to produce errors.
Also, a similar interactive mishap in the heat of the action:
[+] [-] omginternets|8 years ago|reply
(Hilarious and unnerving)
[+] [-] tech2|8 years ago|reply
That was possibly the best unix/linux learning experience of my life. Rebuilding /etc sufficient to rescue my files I cared about before a reinstall. Rescue CDs weren't really a thing, USB was a new thing at the time, and I was on dial-up.
[+] [-] peckrob|8 years ago|reply
So then I typed:
$ shred -n1 -v /dev/sda
Took me about 4 seconds to realize what I did before hitting Ctrl-C.
Then, I sighed. Considered whether I could save anything. Realized there wasn't anything on there worth saving, and reinstalled. :)
I'm usually much more cautious than that and I'm thankful it happened on a dumb test machine at home and not something important, but it was still a bummer and my first real sysadmin-type screw up. Mistakes happen, though. Even Linus once dialed his hard drive [0].
[0] https://liw.fi/linux-anecdotes/
[+] [-] legohead|8 years ago|reply
rm *>o <-- kept shift held down while he pressed period
Been using "make clean" ever since.
[+] [-] FullyFunctional|8 years ago|reply
[+] [-] pjc50|8 years ago|reply
Another fun one: "killall" on Linux kills processes with names matching a string. "killall" on Solaris reboots the machine ...
[+] [-] cryptonector|8 years ago|reply
[+] [-] lomnakkus|8 years ago|reply
One should NEVER do anything non-scripted on a production system. ALWAYS enter it into a file and then do the "run-sql-from-a-file" command.
EDIT: Yes, I also realize that "rm -rf /" can theoretically happen if you have a bad variable substitution, but you MUST turn on the flags that cause your shell to error out instead of just substituting the empty string.
[+] [-] jwilk|8 years ago|reply
If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands.
Source: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm...
[+] [-] earenndil|8 years ago|reply
[+] [-] siegelzero|8 years ago|reply
[+] [-] Ajedi32|8 years ago|reply
[+] [-] Retr0spectrum|8 years ago|reply
[+] [-] Bromskloss|8 years ago|reply
What? No, what's that about?
[+] [-] Jedd|8 years ago|reply
From TFA:
"Update 2015-04-18 -- I suppose I should finally clear this up: The autocorrect functionality I originally described here was a feature of the first Linux systems I ever used, so I assumed it was how every Linux system worked by default. Since then I've come to understand that it's a completely optional extra doodad."
[+] [-] atdt|8 years ago|reply
[+] [-] pierrec|8 years ago|reply
[+] [-] kbenson|8 years ago|reply
[+] [-] andrewflnr|8 years ago|reply
[+] [-] odammit|8 years ago|reply
It would make a good prank to set up on someone that left their machine unlocked. Not sure if it’s more funny than changing their background to goatse.
[1] https://github.com/nvbn/thefuck
[+] [-] bmiller2|8 years ago|reply
[+] [-] DKnoll|8 years ago|reply
[+] [-] talyian|8 years ago|reply
[+] [-] sova|8 years ago|reply
[+] [-] abtinf|8 years ago|reply
[+] [-] tekstar|8 years ago|reply
[+] [-] knappe|8 years ago|reply
I was in a sys admin class with a friend of mine and we both had access to the same machine to work on our assignments. I aliased each and every common command to `sl -f` on my friend's user as a prank (he never actually logged in as it turns out). However, my instructor, while projecting his screen to 150+ students (and recording) picked our box and my friend's user to use as an example. My instructor was flabbergasted for a few minutes and the class got a kick out of flying trains. :D
[+] [-] KGIII|8 years ago|reply
I have my priorities.
[+] [-] Retr0spectrum|8 years ago|reply
[+] [-] isostatic|8 years ago|reply
[+] [-] osxrand|8 years ago|reply
$ ls -F
dammit!
$ sl -F
So I guess it's corrected my typos already :)
[+] [-] dkresge|8 years ago|reply
[+] [-] htfy96|8 years ago|reply
[+] [-] majewsky|8 years ago|reply
[+] [-] Viper007Bond|8 years ago|reply
http://www.ee.ryerson.ca:8080/~elf/hack/recovery.html
[+] [-] johnvonneumann|8 years ago|reply
[+] [-] gumby|8 years ago|reply
[+] [-] waterhouse|8 years ago|reply
[+] [-] stevefan1999|8 years ago|reply
[+] [-] Bromskloss|8 years ago|reply
Edit: The video in question: https://www.youtube.com/watch?v=Q_pgnMWgd34
[+] [-] mar77i|8 years ago|reply