I have been playing around with chmod, chown, setfacl and special bits trying to get multiple system/full users in same group correct access permissions to my media collection.

But I’ve messed it up somehow and now I’m having weird problems that are hard to track.

I would like to set my whole collection back to the defaults.

What is the best way to do this?

One problem I’ve had when making changes to so many files is the process seems to go forever without completing. Eventually it gets killed so my filesystem has variable attributes throughout. how can this be worked around?

I want everything to be owned by myuser, group media, everything else default I will sort it from there once I have a fresh slate.

And is there a way to backup these attributes only? I don’t have enough storage to backup the files themselves.

It is Debian with ext4 filesystem.

Edit to add: Media collection is on its own separate drive/filesystem; this has no impact on anything else on the computer.

  • TootSweet@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    9 months ago

    I want everything to be owned by myuser, group media

    Wait, “everything?” Yeah, that’s probably contraindicated. You don’t want to be changing ownership of stuff in, say, /etc or /bin or whatever to your user. For the most part, stuff in those locations should be owned by root:root. If there are exceptions (things that should be owned by root:<something else>), the package manager will make sure they’re set as they should be.

  • dblsaiko@discuss.tchncs.de
    link
    fedilink
    arrow-up
    4
    ·
    9 months ago

    To back them up, perhaps cp -r --preserve=xattrs --attributes-only (or --preserve=all if you don’t want only xattrs)

    • Shadow@lemmy.ca
      link
      fedilink
      arrow-up
      6
      ·
      9 months ago

      If you use u+rwX style syntax instead of 755, the capital x will only apply to folders. Then you can do it all in one command and don’t need find.

      • layzerjeyt@lemmy.dbzer0.comOP
        link
        fedilink
        arrow-up
        1
        ·
        9 months ago

        When I was getting myself into this mess, I found different opinions about whether it’s faster to find, them modify attributes for only those files which require it, OR if you should just modify the attributes of all files en masse.

        I tried both ways and they both took a very long time; didn’t do any objective comparison.

          • layzerjeyt@lemmy.dbzer0.comOP
            link
            fedilink
            arrow-up
            1
            ·
            9 months ago

            An mp3 or a pdf has no business doing anything. The whole point of file permissions is to prevent the user from accidentally doing stuff they don’t mean to do.

            If you downloaded a malicious file that had some code in it, you could accidentally execute the code. Or maybe some legitimate code that means one thing in the file format but a different thing when executed accidentally.

            Even excluding the possibility of malice, I think it would screw up things like tab completion to have every file be an executable. Or if I double click in the GUI file manager, will it try (and fail) to run the .avi as an application instead of opening in VLC?

            I’m sure you could get a more comprehensive answer if you post a new thread or search on the web.

        • layzerjeyt@lemmy.dbzer0.comOP
          link
          fedilink
          arrow-up
          1
          ·
          9 months ago

          my version does support it, it’s fine

          if it wasn’t supported shouldn’t it throw an error or do nothing? or in other versions is X a synonym to x?

  • Brewchin@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    9 months ago

    One way could be to grep your history, then compare the matches against a distro source?

    It’ll be tedious if it’s lots, but might be a solution if you don’t have a backup.

    • layzerjeyt@lemmy.dbzer0.comOP
      link
      fedilink
      arrow-up
      2
      ·
      9 months ago

      It’s hard to sort out what happened because some tasks completed, others didn’t. Some commands were following symlinks, others weren’t. Some files already had permissions that prevented the current user from modifying them so were untouched. And some files have been moved. There is no way to sort it out from the history.

  • just_another_person@lemmy.world
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    9 months ago

    There are no “defaults”. If it’s just media, and you don’t care who can read it: chmod -R 755 /your/directory

    That sets your user to full access, and all other users to read and execute whatever files are in there. That’s as close to a default as you can get. Switch it to 744 for strict read-only for other users aside from yourself.