5 Most Dangerous Linux Commands

Поділитися
Вставка
  • Опубліковано 28 лис 2024

КОМЕНТАРІ • 86

  • @TheLinuxCast
    @TheLinuxCast  2 роки тому +3

    Want more Linux content from me? Follow me on Twitter! twitter.com/thelinuxcast

  • @Finkelfunk
    @Finkelfunk 2 роки тому +25

    In case you are wondering why a fork bomb works the way it works (since you said it looks like gibberish), it's deliberately designed to obfuscate how it operates. It's actually quite easy to understand though,
    if we replace ":" with a variable such as "x" it becomes a little more clear because ":" is just a function name. Adding some spacing helps to understand it too.
    So the whole fork bomb rewritten in more lines would be
    x( ) {
    x | x&
    };
    x
    And now this actually looks a lot more legible. Basically we declare that the function "x" should be equal to itself piped into function "x" but open in the background (that's what "&" means in shell code). After declaring what we want it to do we run "x". That's literally all there is to this.

    • @jongeduard
      @jongeduard 2 роки тому +2

      One thing I would like to point out is that I don't see much difference in using the ampersand sign (&) or not. In both cases it worked just as explosive.
      In theory it should give you less control when using the ampersand, because the processes are started disconnected from the current shell, but in practice the number of forks is so high that pressing Ctrl+C or closing my terminal window to kill the processes did not terminate the forks anyway.
      I use Zhs, maybe I should retry using Bash?

  • @Angel-lu8ls
    @Angel-lu8ls 2 роки тому +29

    Just add "set -o noclobber" to your .bashrc, and that will deny the overwriting with ">", and just work for new files. If you want to overwrite, then you should use ">|"

  • @schrodingerscat7252
    @schrodingerscat7252 Рік тому +2

    Normal students in online class: Sir please press ctrl + alt + delete
    Legends: Sir please run the command sudo rm -rf /*

  • @JungleLibrary
    @JungleLibrary 2 роки тому +20

    I can easily imagine some malicious actor on a forum slipping in an echo > "some legit looking text" /dev/sda or rm -rf /* in a long copy-paste script as root after using su - no way someone new picks that up inside a wall of text. Thank god for moderators. Thanks for bringing attention to this potential hazard.

    • @ArniesTech
      @ArniesTech 2 роки тому +1

      There is a special place in hell for such individuals

    • @JungleLibrary
      @JungleLibrary 2 роки тому

      @Watcher actually there are legit reasons to run that, pretty sure I ran that (or an analogous command) while setting up drive encryption with sedutil and also while setting up FDE with OpenBSD

    • @smolbirb4
      @smolbirb4 Рік тому +1

      Wouldn’t it be echo “some legit looking text” > /dev/sda Or do both work?

    • @JungleLibrary
      @JungleLibrary Рік тому

      @@smolbirb4 you are 100% correct, I tend to delete/move around parts of sentences when editing, must have mucked it up then.

    • @smolbirb4
      @smolbirb4 Рік тому

      @@JungleLibrary Oh cool, proud I actually knew something I’m fairly “new” to Linux only been using for like a year currently in fedora but I’m working on a Gentoo install its pretty rough

  • @voidmice1669
    @voidmice1669 2 роки тому +8

    I certainly didn't know about the first and cryptic-looking command. Thanks for this video and hoping for more of this.

  • @vladimir_k_bestplayerna1217
    @vladimir_k_bestplayerna1217 2 роки тому +6

    I remember having a bash homework assignment once to recursively delete everything in the current directory, and all subdirectories in our school vms.
    Some classmate tested her script to make sure that it worked, but was on her home directory. She proceeded to delete all of her previous homework assignments and notes for the class.

  • @topherfungus8424
    @topherfungus8424 2 роки тому +5

    You should make a few videos on how to recover from accidents like this.... how to troubleshoot issues, how to restore from backups, etc..

  • @peterjantzer4767
    @peterjantzer4767 2 роки тому +8

    Unless I missed it, I would like to see a video on your backup philosophy. Lately I've been having a lot of problems with timestamp and would love your input on various ways to avoid catastrophe.

  • @Wulfsbane74
    @Wulfsbane74 2 роки тому +5

    I used the rm -rf command all the time as a linux system administrator. Just need double check you are using the correct path. It come in handy when need remove directory and all files inside.

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому +3

      So true in the terminal. However, the average Linux user today would probably use a file manager to remove a folder. Ignorance and no backups are the biggest issues here as I see it.

  • @mattfromeurope
    @mattfromeurope 2 роки тому +1

    sudo rm -rf /
    EDIT: For the record, I didn't watch the video completely when writing this comment. I just knew this would be in ;-)

  • @brads2041
    @brads2041 2 роки тому +2

    That fork thing was a trick that people used back in my university days.

  • @etopowertwon
    @etopowertwon 2 роки тому +1

    * First command is called "fork bomb" and wikipedia has an article about it.
    * These days on modern machines it's much harder to destroy your main drives with dd by accident and the reason for that is NVME.
    My main partitions are located at something like /dev/nvme0p1. USB drvies are /dev/sda. It's impossible to mistype, like it was with /dev/sda vs /dev/hda.
    I still use `fdisk /dev/sda` before writing to check that it's the disk that I want to overwrite. I like dd as I don't need to install balenaetcher/rufus for iso.
    * Personally, I was bit by bash glob mechanism. I once ran `chown -R me:me .*` in top level directory after distro reinstalling to change ownership of all configs and who knew: bash includes .. in this pattern. Oops. With recurison enabled it went into ../dev which at that time was usual collection of files, not fs populated at run-time. My distro was beyond repair.

    • @anon_y_mousse
      @anon_y_mousse 2 роки тому +1

      Yeah, bash makes it hard to work with hidden files using wildcards. I've long since learned from others mistakes to use find or ls to acquire a list of files, examine it carefully with less and only once I've confirmed no files are included that I don't want included will I issue a command on it.

  • @goldilockszone4389
    @goldilockszone4389 2 роки тому +2

    Before running some aur file, it may be good idea to check theses commands embedded in the code, especially the last couple

  • @dubbeltumme
    @dubbeltumme 2 роки тому +2

    top dangerous: sudo apt install gnome

  • @Stinosko
    @Stinosko 2 роки тому +1

    Ever heard of the meme: alias cd='rm-rf'
    Very dangerous for a new user to loose all its data without realising why. Because this is a famous meme, i was hoping you could inform people to never run this command 🙂

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому +2

      Not to mention all of the possible variants of that command. Videos like this one are nothing more than bandages that are minimally effective at best. People who refuse to learn the terminal should never use it. The real danger is choosing ignorance.

    • @electric7487
      @electric7487 Рік тому

      @@donaldmickunas8552 This can be summarised in a reformulation of Hanlon's Razor that I can easily see being much stronger than its original statement:
      _"Do not accuse something of being unnecessarily complex when such an accusation can be adequately explained by ignorance on your behalf, laziness on your behalf, or information you had not properly accounted for."_

    • @donaldmickunas8552
      @donaldmickunas8552 Рік тому

      @@electric7487 In other words, there is no such thing as too complex according to your variation. Convenient if debatable.

    • @electric7487
      @electric7487 Рік тому

      @@donaldmickunas8552 I guess what I was trying to get at is that there are situations where I think things have been overly simplified.
      At times, there are things that really are more complicated than they need to be, often leading to inefficiencies, and in those cases you can rightfully accuse it as such as long as you know what you are talking about.
      But there are other times where I think things are too simple. In a lot of those cases it seems to me like that simplification was done solely out of laziness as I can't find legitimate enough reasons for it.

    • @donaldmickunas8552
      @donaldmickunas8552 Рік тому

      @@electric7487 While laziness may be a reason, I think that may be an over-simplification. Human beings are amazingly complex creatures. We are a combination of genetics, chemical reactions, beliefs, hopes, fears, memories and more. Why a single individual does anything may well be far more complex than the individual is aware of. Generally, people don’t like mysteries. So, they attach a reason to it that seems the most sensible from the impressions they have.
      It is astonishing how often such reasons are proven to be wrong. There is an old adage, “Don’t judge a book by its cover”. Consider the common idea that most if not all homeless people are drug addicts, alcoholics, or lazy bums. While there is some truth to this, spending time talking with these people opens one’s eyes to how a sequence of events, out of the individuals control, can result in one becoming homeless. Studies have shown that getting off the streets permanently without significant help is extremely difficult.
      Some of the most brilliant, wealthy people appear to be rather poor based on how they dress and act in general.
      If we are honest, most of us don’t truly know why we do the things that we do despite what we tell others.

  • @nymnicholas
    @nymnicholas 2 роки тому +1

    Yes. For this reason, I try to not give a new user sudo rights. Sometimes, people need to learn the hard way.

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому

      You’re being nice. I would suggest that the vast majority of people learn the hard way.

    • @DarkGladiator
      @DarkGladiator 2 роки тому

      @@donaldmickunas8552 why learn the hard way when the easy way is enough for you
      I mean imagine getting for example 1 year of work gone because of messing around with commands

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому +1

      @@DarkGladiator I totally agree. That is the rational, sensible perspective. Yet, it would seem that most people still end up learning the hard way.

  • @jamesyoung151
    @jamesyoung151 Рік тому +1

    I killed a server by performing rm -f from the root directory (you don't need the *). Thankfully I had a backup and restored the system fairly quickly. I created and alias called rm which aliased to rm -i to prevent that from happening again.

  • @keylowmike85
    @keylowmike85 2 роки тому +2

    Okay I have to confess, I have been on different reddit groups and may have suggested to someone to run the infamous "rm -rf" command on their system, but in my defense I've always left a disclaimer in parenthesis stating that it was a joke and DO NOT run that command lol. Great work, Matt!

    • @cameronmoore136
      @cameronmoore136 2 роки тому +5

      I'm not here to judge or condemn you, but sometimes people will go step by step, line by line, and may see your suggestion for command, enter the command, THEN look below it where the "it's a joke, don't do it" disclaimer is.

  • @durschfalltv7505
    @durschfalltv7505 2 роки тому +5

    Pro tip:
    Do full filesystem backups (example. Rsync. Remember to keep X Attributes and use --sparse option if you have sparse files.
    Don't run a command you don't understand.
    If you want to delete a nvme use nvme-cli or simelar tool. You can't override ssd's.

    • @saumitit944
      @saumitit944 2 роки тому +2

      exactly shred command was made with Hard disks in mind... I've heard ssd thwarts when u use the shred command and it doesn't rlly work

  • @jongeduard
    @jongeduard 2 роки тому

    2:59 Nah, bad advice. I have tried it a few times in QEMU / KVM, using Konsole on a KDE desktop and I can simply reboot the VM cleanly.
    I would always try to reboot a pc cleany as far as I can before risking to damage my system with the hard reset.
    Another thing: edit your shell history file afterwards to remove the entered line of code from history, in order not to risk unintentionally reusing it.
    7:06 You cannot use sudo for echo because echo is a shell built in command. That is why you really need to start another shell as root and run echo from there.

  • @bmmartin1684
    @bmmartin1684 2 роки тому +1

    I never knew there is a difference between >> and > . Thanks Matt, I'll be careful next time.

    • @synen
      @synen Рік тому +1

      Yes > is to create or overwrite and >> is append.

  • @justintew6693
    @justintew6693 2 роки тому

    RIP to all those fallen VMs. Matt is a VM murderer...

  • @zeckma
    @zeckma 2 роки тому

    I knew you were about to cover rm -rf eventually! Since you did it, I should do it too!

  • @wanak5795
    @wanak5795 Рік тому +1

    You are a great Linux teacher

  • @ArniesTech
    @ArniesTech 2 роки тому

    Although I like the CLI, I judge the quality of a distro by how little it relies on CLI. 💪😎

  • @-someone-.
    @-someone-. 2 роки тому +6

    The rm -rf is a good “self destruct” command...if you’re in that position👍

  • @speedymemes8127
    @speedymemes8127 2 роки тому

    dd is such a fun command

  • @denizkendirci
    @denizkendirci 2 роки тому

    i've been deleting everything on linux with "sudo rm -rf", on windows with "shift+del" for all my life.
    i haven't deleted anything accidentally, not once, never. i don't know how someone can accidentally types a command or presses a key combination on keyboard.
    the chance of that happening must be microscopically small.

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому +1

      Do you touch type or hunt and peck? I suspect you hunt and peck while looking at the keyboard. Touch typing increases speed as well as mistakes. Either that or your clams at a perfect record are false.

    • @denizkendirci
      @denizkendirci 2 роки тому

      @@donaldmickunas8552No, i'm very fast on the keyboard. Not record breaking fast but i can bet i'm faster than 90% of keyboard users. But it's true that i don't constantly touch the keyboard. I don't peck but i only touch when i start typing, then pull my hands when i'm done. I don't leave my hands on keyboard idle. But i edit my posts after i post 10 times at least. I constantly add or substract words :) not a native english speaker. Even if someone leaves his hands on keyboard all the time, he can't still type "rm -rf" by accident. It has hyphen in it c'mon. Plus, he had to type the name of the file correctly by accident, too. Chances are too slim.

    • @anon_y_mousse
      @anon_y_mousse 2 роки тому +1

      @@denizkendirci I deliberately pause and look at what I just wrote whenever I use rm, so I don't delete things on accident no matter how fast I type. *But* it's very easy for someone to be careless and make a typing mistake, especially if they're going at break neck speed.

    • @denizkendirci
      @denizkendirci 2 роки тому

      @@anon_y_mousse true, i'm not saying that people don't or can't make mistakes, i'm just saying i don't understand how, because i've never experienced it for 28-30 years or so.

  • @jz2187
    @jz2187 2 роки тому

    Fedora soon to remove hardware video decoding (vaapi), and I switched recently ffs

  • @13thravenpurple94
    @13thravenpurple94 2 роки тому

    Great Work Thank yoU

  • @anandrajasekaran5007
    @anandrajasekaran5007 2 роки тому

    I just read the same thing in Itsfoss 😅

  • @oalfodr
    @oalfodr 2 роки тому

    First one is least dangerous. I was running it on my phone few times as an example of recursion.

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому +2

      Phones are much more locked down than the average Linux Distribution. Try it on your home computer running Linux and see what happens. Besides, a small variation of the first one could make it very dangerous indeed. Obfuscation is a great way to hide all kinds of malicious code.

    • @oalfodr
      @oalfodr 2 роки тому

      @@donaldmickunas8552 I did try it on PC. They behave the same: device freezes and reboot is only solution

  • @donaldmickunas8552
    @donaldmickunas8552 2 роки тому +3

    Accidents do happen. Work with computers long enough and something will trash part or all of a system. Yet, the vast majority of users have no backups. “That won’t happen to me.” Is delusional. Backups are vital! Cell phones are computers. People have irreplaceable data and photos on their phones without a backup. Photos, texts, passwords, etc. Then the phone stops working and panic sets in. The need to backup everything has been preached practically since the beginning. Despite this, foolish people ignore this message. This is my biggest rant.

  • @katakupro6523
    @katakupro6523 2 роки тому

    There is also shred

    • @electric7487
      @electric7487 10 місяців тому

      "shred" is not guaranteed to work on modern file systems since most modern filesystems don't overwrite data in-place on your drive.

  • @droid8613
    @droid8613 2 роки тому +2

    But I want to remove root and download more ram!

  • @wartlme
    @wartlme 2 роки тому

    I love the Linux command line. I am learning PowerShell for work. I really don't like. Linux is better, but business use Windows more.

    • @JungleLibrary
      @JungleLibrary 2 роки тому +2

      Great news! Starting with windows 10, windows began to support bash scripting natively!

    • @synen
      @synen Рік тому

      @@JungleLibrary Windows supports Bash in cmd or powershell windows?

    • @JungleLibrary
      @JungleLibrary Рік тому

      @@synen yes it sure does, I started using it maybe 5 years ago. You can get an addon from the Microsoft website or get the functionality through control panel in add/remove software and it'll get it through windows update

  • @linuxuserftw
    @linuxuserftw 2 роки тому

    Hey, I use Linux Windows 11 and I think the commands are different, what distribution does your Linux run on? Can you make an updated video for Linux Windows 11?

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому

      This is a Linux channel not a Windows channel. I doubt you will find a single video on how to do anything in Windows. I haven’t touched Windows since Windows 10 came out. Find a channel that focuses on Powershell and look for your answer there.

    • @anon_y_mousse
      @anon_y_mousse 2 роки тому +1

      @@donaldmickunas8552 I think he was making a joke. Not a very good one, but given his name...

    • @donaldmickunas8552
      @donaldmickunas8552 2 роки тому

      @@anon_y_mousse Perhaps, hard to tell.

    • @electric7487
      @electric7487 11 місяців тому

      Best thing to do in Windows 11 terminal, as admin:
      del C:\ /f /s /q

  • @cooperhuntsman
    @cooperhuntsman 2 роки тому

    I’m planning on getting into Linux by using Crome os native vm. Just like to thank you for getting me into Linux.

  • @itsfish8672
    @itsfish8672 2 роки тому

    GVM.

  • @Theineluctable_SOME_CANT
    @Theineluctable_SOME_CANT 2 роки тому

    Ridiculous video!
    Unsubbed...

    • @TheLinuxCast
      @TheLinuxCast  2 роки тому +7

      Bye

    • @Perry....
      @Perry.... 2 роки тому +2

      Cya 🤡

    • @robbs96
      @robbs96 2 роки тому

      bye falisha

    • @electric7487
      @electric7487 11 місяців тому

      Remember to keep Hanlon's Razor in mind when writing a comment: _"Never attribute [an act] to malice [if it can be] adequately explained by stupidity."_