• 0 posts
  • 11 comments
Joined 3 years ago
Cake day: June 5th, 2023
  • This is apparently a joke! But I have done this in real life. It’s an honest mistake you can make if you’re experienced, fast, complacent and careless. Always be prepared for it. Here are some tips:

    1. Don’t use sudo for anything other than system operations. Not even for editing configuration files.

    2. Never put any development/sysadmin projects under ownership of root. Always develop the project under your personal unprivileged user account. Use sudo only for the final deployment of project to system directories.

    3. Use sudoedit to edit any system configuration files.

    4. Avoid ./* at all times in favor of just *. While this is counterintuitive, this is actually safer. You will have less habitual urge to type the / alone by accident.

    5. Avoid the -f flag in all instances for any command until some operation fails. That will leave you with enough time to reflect on your mistakes when you make one.

    6. Always keep a data recovery plan. Backups are highly recommended. If you use Btrfs partitions, you can make periodic read-only snapshots of your critical data. You can automate this process with a tool like Snapper.
      Btrfs snapshots store de-duplicated data. So each snapshot stores only the changes from the previous one. It doesn’t use a lot of space, even when backing up large media files. You’ll still get the chance to recover your data at the time of the last snapshot.

    7. Most operating system files aren’t critical data and don’t need to be backed up. Backup the system configuration files in /etc and the package installation list if your package manager facilitates it.

    8. This is optional, but useful in case your Linux installation gets nuked somehow, including this nonsense.
      You can always reinstall the distro and start over again. But often times, you can trivially recover the installation by booting from a live USB/CD and doing some manual repair. Learn to chroot into your nuked root partition and operate from inside it.
      Most live disks give you an option to repair an installation, in case you deleted the root partition by accident. You can also repopulate the deleted files using commands like debootstrap and pacstrap.

  • Why not just:

    rm -r *
    

    What is the necessity of that sudo, -f and /?

    Disclaimer: I have carelessly committed this nonsense too. Thankfully, the important data was backed up. I used a live USB to access the nuked OS partition and used chroot to repopulate the deleted system files. Didn’t even have to reinstall the OS.

    Always have a disaster plan. If you have a btrfs partition, even periodic btrfs snapshots are a cheap lifesaver. Everything else can be saved like a breeze with some terminal magic.

  • There are two disturbing tendencies being demonstrated here:

    1. Using useless AI to engage and disperse complaining customers. The AI can’t make meaningful solutions to many customer complaints. But companies use it to annoy the customers into giving up, so that they can save the cost of real customer support.
    2. Either blaming the AI or insisting that it’s right, when it makes a mistake. AI by nature is biased and unpredictable. But that doesn’t stop the companies from saying ‘the computer says so’.

    These companies need a few high profile hefty penalties as a motivation to avoid such dirty tricks.