Can't share a folder

Hello! I am facing an issue with sharing a folder. I have a folder in my home directory that I would like to share. I have full read/write permissions to it. I right click it in Dolphin, go to Properties>Share (I have two Share tabs for some reason and one is blank) and tick “Share this folder with other computers on the local network”. I click OK and it closes. But when I open it up again the checkbox is unchecked and the folder is not listed in the Network category. I don’t know how to fix it.

Welcome to the forum! :slight_smile:

You need to understand POSIX permissions and ownership. The folder is only readable to others if all the folders in the path to that one folder are also readable to others ─ r and x permissions for everyone, or in octal, 755 permissions. So that means that your home directory must also be world-readable.

Secondly, in order to share anything across the network, you need to have a file-sharing server process running. The two most used ones in the world of GNU/Linux are…

  1. NFS, the original Network FileSystem protocol for UNIX developed by Sun Microsystems; and…
  2. Samba (SMB/CIFS), the Microsoft networking protocol for both file and printer sharing.

Furthermore, the computer that you wish to share these files with must be running a client application that can import/read the share. With NFS that’s not much of a problem, because all you need to do is mount the NFS share somewhere. With Samba you need to have the smbclient running.

Both technologies are well-documented, so I’ll leave it to you as an exercise to look up on them and decide which one to use. I’ll just give you these two hints… :arrow_down:

  • NFS is faster and easier to set up in terms of permissions, because it was designed specifically for UNIX.

  • If the client machine runs either Windows or macOS, then you have to use SMB/CIFS, because neither Windows nor macOS support NFS ─ which in the case of macOS is peculiar, considering that it’s an officially certified UNIX system.

I decided to use Samba, as I need to share with my Windows machine. Is it a bad idea to do chmod o+x /home/<username> so that I can share anything I want? Will it pose a security risk?

No, not really, because being able to read something is not the same thing as being able to write to it. And you can further refine just how much will be exported over the network, and who gets access to those shared files. Because you would of course not throw everything wide open without requiring some authentication.

Safest would however be to move that directory out of your $HOME and into ─ say ─ /srv, and to then create a symlink to that directory in your $HOME. That way, it’ll still behave to you as if it’s in your $HOME, but it’ll no longer depend on the permissions for your $HOME. You may have to modify the ownership and/or permissions of the directory once you’ve moved it into /srv ─ by default, /srv and its contents will be root-owned, and thus not writable to unprivileged users ─ but that’s less of a problem.

So, say that the directory you want to export is called Stuff, then you would first move it and create the link… :arrow_down:

sudo mv Stuff /srv/export
sudo ln -s /srv/export /home/<user-name>/Stuff

Then, you create your /etc/smb.conf, and then you can determine who gets what access.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.