• remon@ani.social
    link
    fedilink
    arrow-up
    8
    ·
    20 hours ago

    It will delete everything in the directory after that, without asking for further confirmation.

    • 0xKeshara@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      8
      ·
      20 hours ago

      Unless it’s on /, where preserve-root should be kicking in, unless the bypass flag is used (can’t remember this one)

      • Havatra@lemmy.zip
        link
        fedilink
        English
        arrow-up
        5
        ·
        edit-2
        20 hours ago

        Not all systems have the preserve-root flag enforced, actually… I accidentally did the rm -rf / in a bash script (the variable for the path returned empty), and it irreversibly deleted a bunch of my system, including sudo and a big part of /etc, before I realized and did Ctrl+C. However the damage was done, rendering the system both unusable and unbootable. Fortunately I managed to recover some data, as the drive was not encrypted.

        Edit: Yes, like a fool I ran the script as sudo… I am now older and wiser.

          • Havatra@lemmy.zip
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 hour ago

            Iirc, it was Debian 10 (Buster). I thought they enforced it (rm did support it at the time), but perhaps it was tricked by using an empty variable or something?

            • 0xKeshara@lemmy.dbzer0.com
              link
              fedilink
              arrow-up
              1
              ·
              13 minutes ago

              Ahhh, I just re-read your comment, and yeah that would have been the case.

              I think another quick bypass without using the proper flag could be to use a wildcard (for example, rm -rf /*), I think that might work too maybe

    • Successful_Try543@feddit.org
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      19 hours ago

      No, it does nothing.

      $ mkdir test
      $ cd test
      ~/test$ touch 1 2 3 4 5
      ~/test$ rm -rf
      ~/test$ ls
      1  2  3  4  5
      

      If you dont specify the -f option, which among other things tells rm to be quiet, it throws an error:

      $ rm -r
      rm: missing operand
      Try 'rm --help' for more information.
      
      • remon@ani.social
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        19 hours ago

        Because you’re using it on nothing.

        $ mkdir test
        $ cd test
        ~/test$ touch 1 2 3 4 5
        ~/test$ cd ..
        $ rm -rf test
        $ ls
        

        No more test folder.

          • remon@ani.social
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            19 hours ago

            What are you talking about? The does exactly what I said it does.

            It only does nothing for you because you used it incorrectly (in the wrong folder without the required argument).

            • Successful_Try543@feddit.org
              link
              fedilink
              arrow-up
              4
              ·
              19 hours ago

              The question is:

              what happens when you give the command in the command line rm -rf ?

              rm -rf * or here rm -rf test are different commands.

              • remon@ani.social
                link
                fedilink
                arrow-up
                3
                ·
                edit-2
                19 hours ago

                rm is the command, -rf are the flags and “test” is an required argument. So no, they are not different commands.

                  • remon@ani.social
                    link
                    fedilink
                    arrow-up
                    2
                    ·
                    edit-2
                    19 hours ago

                    It does nothing because you used the wrong syntax but also set the flag that suppresses the output of syntax errors …

                    Imagine someone would asked “What does a toaster do?”

                    I say “It toasts bread”.

                    You come in with a picture of bread in a toaster and say “It does nothing”.

                    I tell you “You have to press the button”.

                    "You say “oh well, that wasn’t the question, a toaster with the button pressed is basically a different device!”

                    Insert <Futurama not sure if trolling …> meme.