this post was submitted on 27 Oct 2023
24 points (96.2% liked)

Linux

48092 readers
870 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

The one thing stopping me from having a "work profile" "private profile" etc, is the permissions.

I could hardlink folders from one user to another, but then there would be permission issues.

I could do a chown -r /home/user/Work but every newly created file would again belong to "work" and I couldnt edit it with "private" for example.

Libreoffice also doesnt like any permission issues and will only open a copy in those cases.

Would I need an autostart script using pkexec, or a systemd service to always make both users recursively owners of these directories? Is there a better way?

Btw, I use Fedora Kinoite (KDE) and moving things from one user to another takes very long, unlike moving withing the same user. It seems as if it would really change the file location, not just the pointer, but I am no BTRFS expert at all.

top 11 comments
sorted by: hot top controversial new old
[–] ouch@lemmy.world 46 points 1 year ago (2 children)

Create group, add users to group, create a new directory, chown it to the group, chmod g+s and done.

[–] Dirk@lemmy.ml 10 points 1 year ago

Best solution.

[–] knobbysideup@lemm.ee 2 points 1 year ago

You'll also need umask for each user to be 002 for it to work transparently.

[–] ElderWendigo@sh.itjust.works 30 points 1 year ago (1 children)

Why are you making this so complicated?

Create a shared directory outside of home. Put both users into a group. Make sure that the directory and the files created inside it are owned and writeable by that shared group.

Read up on permissions and ACLs for more on doing this. (I'm being deliberately vague on specifics here because I always seem to fuck up the details here and need to go back to the manuals anyway.)

Home is for your stuff. It is possible to setup sharing of stuff from within home, but there are always going to be more problems with this route because it's designed to be private by default.

You can't hardlink directories. Hardlinking files wouldn't help anyway because each link would get identical permissions. I can't even hardlink at all between home directories on my system because each home directory is a separate filesystem.

[–] Pantherina@feddit.de 2 points 1 year ago (1 children)

Hmm I like Nextcloud and Flatpak apps accessing my files. Not sure about other directoris, but /var/shared/work could fit on immutable OSses

[–] ElderWendigo@sh.itjust.works 1 points 1 year ago

What does an immutable OS, flatpak, or Nextcloud have to do with basic file permissions between users on the same machine? You still need to learn how basic permissions work with any of those in order to get them working properly anyway.

[–] lily33@lemm.ee 24 points 1 year ago (1 children)

You could put users in the same group, and give some folders group permissions.

[–] jcrabapple@infosec.pub 2 points 1 year ago (1 children)
[–] luthis@lemmy.nz -1 points 1 year ago

This is the way.

[–] dack@lemmy.world 6 points 1 year ago

Aside from the group suggestions, you could also use ACLs. https://wiki.archlinux.org/title/Access_Control_Lists

[–] fhein@lemmy.world 3 points 1 year ago* (last edited 1 year ago)

I could hardlink folders from one user to another

I don't think you could, afaik hardlinks are only allowed for files. You might be able to something similar with a bind mount though.

Personally I keep those kind of folders outside a single user's home dir. On one computer I have /home/Shared (not a real user, I just put the folder there.. no idea if it's a bad idea, but noone else is going to be creating users on that computer anyway).