Hi there, I’m on Bazzite KDE and recently somehow lost a my “gaming” folder…? No idea how but must gave been user faulty, e.g me. Therefore wondering if it’s possible to lock certain folders so that this cannot accidentally happen?

  • axzxc1236@lemm.ee
    link
    fedilink
    arrow-up
    23
    arrow-down
    1
    ·
    1 month ago

    sudo chattr +i (folder) prevents anything to modify/delete folders and files

    Add -R for setting the flag for all subdirectory/files

    • Sunny' 🌻@slrpnk.netOP
      link
      fedilink
      arrow-up
      5
      ·
      1 month ago

      Thanks I might try this! However does this allow for reads/writes from the system? Considering this is a folder for games, the files are constantly changing, such as the game save files etc…

  • MultipleAnimals
    link
    fedilink
    arrow-up
    10
    ·
    1 month ago

    Not really afaik, you can make file immutable with chattr +i /path/to/something but that means you cannot write to it either, which will probably cause problems.

  • digdilem@lemmy.ml
    link
    fedilink
    arrow-up
    10
    ·
    1 month ago

    Others have answered your question - but it may be worth pointing out the obvious - backups. Annoyances such as you describe are much less of a stress if you know you’re protected - not just against accidental erasure, but malicious damage and technical failure.

    Some people think it’s a lot of bother to do backups, but it is very easily automated with any of the very good free tools around (backup-manager, someone’s mentioned timeshift, and about a million others). A little time spent planning decent backups now will pay you back one day in spades, it’s a genuine investment of time. And once set up, with some basic monitoring to ensure they’re working and the odd manual check once in a blue moon, you’ll never be in this position again. Linux comes ahead here in that the performance impact from automated backups can be prioritised not to impact your main usage, if the machine isn’t on all the time.

    • Sunny' 🌻@slrpnk.netOP
      link
      fedilink
      arrow-up
      4
      ·
      1 month ago

      Definitely a very valid point! I have a server I can back up to aswell, just gotta set it up as you say 👌

      • zero_gravitas@aussie.zone
        link
        fedilink
        English
        arrow-up
        4
        ·
        1 month ago

        I think it’s worth emphasising here: Don’t put it off!

        There are millions who can tell you from experience that good intentions count for nothing when it comes to backups.

        I’d recommend going and setting up Timeshift right now: https://github.com/linuxmint/timeshift

        It’s easy to set up, it takes literally 10 minutes, and if you decide later you want to use something else, you can just uninstall Timeshift and delete its backups. But in the meantime you’ll be protected with backups.

        It’s literally the first thing I install on a new system and it’s saved me multiple times from having to do a complete reinstall.

      • vipaal@aussie.zone
        link
        fedilink
        arrow-up
        6
        ·
        1 month ago

        Every modification and deletion is prevented regardless of the method, be it mv, rm or other commands on the terminal or through a GUI, with or without sudo until sudo chattr -R -i /path/to/directory is performed

  • zero_gravitas@aussie.zone
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 month ago

    People have already given direct answers, and the indirect answer of ‘set up regular automated backups’ (which everyone should set up right now if they haven’t already), but for the sake of throwing another option out there, people could take a look at ‘trash-cli’: https://github.com/andreafrancia/trash-cli

    (P.S. I know OP might not have actually deleted the files with ‘rm’, but this addresses a broadly similar issue.)

  • catloaf@lemm.ee
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 month ago

    Sure, regular file permissions can do that. You may need to make the folder owner someone else, and set the sticky bit.

    • Sunny' 🌻@slrpnk.netOP
      link
      fedilink
      arrow-up
      2
      ·
      1 month ago

      Yeah actually this was more simple thanI had imagined, I simply changed it so that the owner(me) can only view the folder and not edit. Which totally works in my use case. Thought it would have been more difficult than just changing this tbh, thanks!

  • Tyoda@lemm.ee
    link
    fedilink
    arrow-up
    5
    ·
    1 month ago

    If you have the space (on a different drive, preferably) you could use Timeshift to create regular snapshots of (parts of) your system. You can restore deleted files like this from even months ago, if you configure it like that.

    The first snapshot takes up as much space as all the files you want to save, but every following one only uses as much disk space as the new/changed files since the last snapshot.

    • Sunny' 🌻@slrpnk.netOP
      link
      fedilink
      arrow-up
      2
      ·
      1 month ago

      Thanks for your input! This is defo something i do need to learn from indeed. This happened on a pretty fresh install too, the only program linked to that specific folder/path, was Bottles, as I need it for running the executeable for the game. No addtional drives or mounts (other than what Bottles is responsible for). However I would still like to be able to “lock” folders just to prevent my own sillyness from deleting it again.