Apple - Can you actually use Terminal to crash your computer?
One way to crash a computer is to execute a so called fork-bomb.
You can execute it on a unix-sytem by:
:(){ :|: & };:
It's a command that will recursively spawn processes till the OS is so busy it won't respond to any action anymore.
Not sure what you mean about 'crash'ing the computer - if you would re-phrase it to say 'render the computer unusable', then yes. Certainly all it takes is a single stray command - just a moment where you're not thinking clearly about what you're doing, similar to when you speak without thinking, and the damage can be immense and almost immediate. The classic example:
$ sudo rm -rf /
If you let that command run for even just one second, that can wipe out enough of your system to render it unbootable, and possibly cause irreversible data loss. Don't do it.
Suppose you don't know what your doing and attempting to do a backup of some hard drive
dd if=/dev/disk1 of=/dev/disk2
Well if you mix those up (switch if and of), it will overwrite the fresh data with old data, no questions asked.
Similar mix ups can happen with archive utils. And frankly with most command line utilities.
If you want an example of a one character mix up that will crash your system take a look at this scenario: You want to move all the files in the current directory to another one:
mv -f ./* /path/to/other/dir
Let's accept the fact that you learned to use ./
to denote the current directory. (I do)
Well if you omit the dot, it will start moving all your files. Including your system files. You are lucky you didn't sudo this. But if you read somewhere that with 'sudo -i' you will never again have to type in sudo you are logged in as root now. And now your system is eating itself in front of your very eyes.
But again I think stuff like overwriting my precious code files with garbage, because I messed up one character or because I mixed up the order of parameters, is more trouble.
Let's say I want to check out the assembler code that gcc is generating:
gcc -S program.c > program.s
Suppose I already had a program.s and I use TAB completion. I am in a hurry and forget to TAB twice:
gcc -S program.c > program.c
Now I have the assembler code in my program.c and no c code anymore. Which is at least a real setback for some, but to others it's start-over-from-scratch-time.
I think these are the ones that will cause real "harm". I don't really care if my system crashes. I would care about my data being lost.
Unfortunately these are the mistakes that will have to be made until you learn to use the terminal with the proper precautions.