I accidentally untarred archive intended to be extracted in root directory, which among others included some files for /etc directory.
I went on to rm -rv ~/etc, but I quickly typed rm -rv /etc instead, and hit enter, while using a root account.

  • MonkeMischief@lemmy.today
    link
    fedilink
    arrow-up
    43
    ·
    13 hours ago

    OOOOOOOOOOOF!!

    One trick I use, because I’m SUPER paranoid about this, is to mv things I intend to delete to /tmp, or make /tmp/trash or something.

    That way, I can move it back if I have a “WHAT HAVE I DONE!?” moment, or it just deletes itself upon reboot.

    • Alberat@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      9 hours ago

      i always do “read;rm ./file” which gives me a second to confirm and also makes it so i don’t accidentally execute it out of my bash history with control-r

      • MonkeMischief@lemmy.today
        link
        fedilink
        arrow-up
        10
        ·
        7 hours ago

        That’s certainly something you can do! I would personally follow the recommendation against aliasing rm though, either just using the trash tool’s auto complete or a different alias altogether.

        Reason being as someone mentioned below: You don’t want to give yourself a false sense of security or complacency with such a dangerous command, especially if you use multiple systems.

        I liken it to someone starting to handle weapons more carelessly because the one they have at home is “never loaded.” Better safe than sorry.

        • Sylveon@lemmy.blahaj.zone
          link
          fedilink
          English
          arrow-up
          3
          ·
          2 hours ago

          I think this is the best approach. I’ve created a short alias for my trash tool and also aliased rm to do nothing except print a warning. This way you train yourself to avoid using it. And if I really need it for some reason I can just type \rm.

          If you want to train yourself even more effectively you can also alias rm to run sl instead :)

      • I Cast Fist@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        10 hours ago

        After being bitten by rm a few times, the impulse rises to alias the rm command so that it does an rm -i” or, better yet, to replace the rm command with a program that moves the files to be deleted to a special hidden directory, such as ~/.deleted. These tricks lull innocent users into a false sense of security.