NEVER Run These 3 Linux Commands

Never Run these Linux commands. In this video, I break that rule and rune all three. Chaos ensues.

NEVER Run These 3 Linux Commands

In this week's video, I run dangerous Linux commands:

The commands are below in screenshot format to discourage copying them:

WARNING: RUNNING THE COMMANDS BELOW WILL BREAK YOUR SYSTEM. With Great Power, Comes Great Responsibility. If you run these commands, you are responsible for the results!
Three Linux Commands You Should Never Run. Dangerous Linux Commands fork bomb, sudo chmod -R 777 /  and rm -rf /* --no-preserve-root
Three Linux Commands You should NEVER Run. Dangerous Linux Commands

Vidoe Transcript below (apologies if it's a bit messy, this was a tough video to automatically transcribe):


laughter  No such file or directory, so my home folder is gone.

With great power comes great responsibility. In the Linux world, we often see this the first time we run sudo on a new system. You may be wondering, why is this warning in place? There are some commands that you can run as sudo that can completely break your system.

Today, we're gonna look at three Linux commands you should never run. And while this is all, of course, in theory, today we're gonna run these on hardware to see what happens.

Warning, do not run these on a machine that you do not wanna break. I am running these on my test machine, and that is why I'm actually gonna execute these. - Now we know. - And knowing is half the battle. - This is the end of the Vashinator PSA. 

First Command: Fork Bomb

So we're back here in Ubuntu. I decided before I wiped this out that I would run these commands on this. So for the first command, we're gonna have to watch htop. Now that we have htop running, the first command we're gonna run is a fork bomb. What this is, is a command that runs a function, and then within that function calls another function and does so recursively, until your entire memory is full of this particular call and your computer freezes and you have to restart.

I have 16 gigabytes of RAM on this machine. I'm not sure how quickly this will happen. I don't know if I'll be able to stick around for the whole thing, but I guess we'll find out. Let's try it. There we go. Oh, we jumped up quite a bit to seven gigs. Bash fork retry, resource temporary unavailable.

Still at seven gigs. Now we're at eight gigs. And as you can see, it's maxing out the CPU. And there are 16 cores, it looks like on this CPU and notice the number of tasks, 19,000 tasks. So yes, this is gonna continue until we run out of memory.

I don't even, honestly, I think we may be there. htop, yeah, I can't even get htop to come up, as you can see. I have no idea what's going on at this point. Try to quit that, maybe we'll get a little bit more RAM. Yeah, close terminal. Try to close this one out. This is still happening.

As you can see, I can't even read anything beyond resource unavailable. There's another message actually coming up there, but new window, let's try one more time here. No, I can't even get that to come up about if we go to the file manager. So we're able to at least move around the file system. What about... I think it's free. So if I run the free command here, this is another way to try to figure out how much RAM has been used.

This is the amounts that I copied over. As you can see, we're at about 11 gigabytes of 15.7 gigabytes or so. There's only four gigabytes left. I can't even get htop to run now. And just to put this in perspective, this has probably been running for about five minutes, another probably 10 minutes, and the entire system probably locks up.

See if we can close that. I wonder if this will actually try to... can I force quit? Is it gonna actually change anything is the question. I bet we're still gonna have to reboot. Oh, we got back. Okay, killing the terminal and that ended up killing the process. So that's good that we could at least do that.

That's what happens if you run a fork bomb. That's the first one down. Now the first one, you can restart the computer and essentially fix the issue. But the next two will have permanent effects on your system.

Command 2: chmod -R 777 /

All right, the next one we're gonna run is chmod -r and then 777. We're gonna do a sudo on that and enter my password. And it's gonna go in and change the permissions on everything. So now we're in /usr/bin. These are all of our program and this is xev.

This is a little program I believe that you can use to identify keystrokes and things like that from a mouse and keyboard, grep xev. So notice it's rwx, rwx, rwx. That rwx, that is 777. That means anybody, whether it be root, the owner, anybody can change this file. Meaning if I just wanna say rm xev, guess what? If I try to run that again, it's gone.

I deleted that without even be doing sudo. Everything in usr/bin is now available for me to edit and delete as a normal user. What this means is that if anybody else gets access to my standard user account, they can go and change anything that they want to anywhere in the root directory without even using my sudo password. I just deleted xev and uer/bin as my standard user account without sudo elevation. It is gonna bite you in the longterm severely.

What people intend to run: rm -rf ./*

And now the one people probably expected when they saw this video. sudo rm -rf / and then sometimes people use a star, sometimes they don't. We're gonna run this, but first I wanna run what most people think they're running when they go and accidentally run this.

Here in a test directory that I've made, if I look at it, I now have three folders in this directory and each folder has a file in it. But what that does is if I say rmdir and I say test 1, I can't delete it because it's not empty. And so now that we know that these test directories can't be removed by rm dir, I would try to run rm -rf ./* And now when I look here, there's no longer any files here. So the rm -rf and then period forward slash star did what I wanted it to do.

Unfortunately, what will happen is, especially if you have to invoke sudo, you'll have run sudo rm -rf and then /* without the period. What this does is it's gonna try to start deleting at the root level. I'm gonna hit enter on this. And as you can see, the  chmod, it started messing some stuff up. I'm gonna have to actually probably go into like rescue mode to actually fix this. (I had to reformat to get this cooperating again).

Channel Note

If you notice the new shirt, it's available to buy at If you think it's a cool design and you want to pick it up, the link will be in the description and a pinned comment. And I'll also have a link to sign up for the newsletter. Both would be great support to the channel, but watching and sharing the video is also a huge help too.

Command Three: sudo rm -rf /* --no-preserve-root

Let's take a look at this last command here, sudo rm -rf slash. It's gonna ask for my password. This security update was added in probably 2005 or 2006, as far as I understand. And you have to add this no preserve root flag. Preserve root.

As far as I understand it though, this will not actually completely remove everything because it's gonna just crash before that happens. And I think it just did. Oh, it actually came back up. I'm surprised. Let's see, cannot remove.

So let's see what we have here. Such file or directory. So my home folder is gone. Let's go to cd slash. Let's see what's left here. ls command is not found. I'm surprised cd still works, but cd is a an actual built-in Unix command. I believe an ls is a shell command. cd/usr? No, cd/etc. No, let's reboot. Yeah, let's reboot and see what happens here. It would help if I... Oh, reboot command not found.

Oh, that's great. Let's close this out. Maybe we can... Oh, that's not good. What about over here? We have a shut down? No. Okay. I'll hold the power button. Yeah, let's hold the power button. Maybe that'll fix it. All right. I'm sure this will boot right back up. I'm sure it will be good. Oh, no.

Yeah, that's what happens if you run rm-rf slash. I actually did not expect it to happen that quickly. That is the danger of running any of these commands. Again, do not run these commands unless you want that to happen to your computer. The sudo chmod777 actually ended up making it impossible to do sudo anything else. The sudo rm rm-rf slash removed everything, as you saw pretty much. And I guess that's why they say, with great power comes great responsibility. Thanks for watching, have a great day and I will see you next time.

Commands used, You've been warned

WARNING: RUNNING THE COMMANDS BELOW WILL BREAK YOUR SYSTEM. With Great Power, Comes Great Responsibility. If you run these commands, you are responsible for the results!
:(){ :|:& };:
chmod -R 777 /
rm -rf /* --no-preserve-root