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.

  • BCsven
    link
    fedilink
    arrow-up
    58
    arrow-down
    1
    ·
    3 days ago

    Oof. I always type the whole path just because I have made this mistake before.

    • BillyClark@piefed.social
      link
      fedilink
      English
      arrow-up
      15
      ·
      3 days ago

      That doesn’t protect you from typos.

      rm -rv /home/schmuck /etc

      “Whoops, I accidentally added a space.”

      I have three ways around this:

      1. ls ~/etc … <press up arrow, replace ls with rm -rv>
      2. ls ~/etcrm -rv !$
      3. Add the commands to a simple script and use variables to remove the danger of a command line.
      • BCsven
        link
        fedilink
        arrow-up
        3
        ·
        3 days ago

        Thankfully I don’t hit the space bar randomly (yet) but btrfs snapshotting has saved the day for other mishaps

        • BillyClark@piefed.social
          link
          fedilink
          English
          arrow-up
          3
          ·
          2 days ago

          I think the bigger point is that if you type the entire path, you are obviously typing more characters, which gives more opportunities for typos, whatever they may be.

          It’s far safer to find ways to type less. Less typing, fewer typos. As long as you can do it safely.

          • BCsven
            link
            fedilink
            arrow-up
            1
            ·
            2 days ago

            I don’t think that applies when you intend to type something but accidental type enter after your first slash / :)