Ubuntu 19.10: File Sharing to Windows and Mac

Setting up Samba under Ubuntu 19.10 is relatively easy. This guide will show how to install Samba itself, then configure both a public drive meant to be shared among multiple users, and a per-user drive.

NOTE: This guide assumes your linux machine is on your local network.

First, install both samba and smbclient:

sudo apt install samba smbclient

Next, create a directory that will be the shared public drive, and set its ownership:

sudo mkdir -p /srv/samba/public
sudo chown nobody:nogroup /srv/samba/public
sudo chmod 777 /srv/samba/public

Now it’s time to configure Samba. There’s two basic things that need to be configured: setting the user security, and adding the public drive.

To set the user security, set security = user in the [global] section of /etc/samba/smb.conf.

Enable the per-user drive in /etc/samba/smb.conf:

[homes]
    comment = Home Directories
    browseable = no
    read only = no

To add the public drive, add this section to the end of /etc/samba/smb.conf:

[public]
   comment = Public Files
   path = /srv/samba/public
   browsable = yes
   guest ok = yes
   read only = no
   create mask = 0755

Now, restart the Samba services to pick up these configuration changes:

sudo systemctl restart smbd.service nmbd.service

Since Samba doesn’t use the linux login credentials for a user, you must add each user that needs access to a shared drive using the smbpasswd command:

sudo smbpasswd -a <unix username>

Also, if you’re running a firewall on your linux machine, you’ll probably have to allow access for your local network. You can allow specific machines, or a subnet. I use ufw to control my firewall configuration, so for me I simply allowed all access for my internal network:

sudo ufw allow from 192.168.0.0/16

To connect to a drive from Windows, I right-click on the Network item in File Explorer and select Map network drive..., and use \\<hostname>\public or \\<hostname>\<unix username> as the Folder.

To connect to a drive from the Mac, I use Go -> Connect to Server... in the Finder, then use smb://<hostname>/public or smb://<hostname>/<unix username> as the address.

6 Replies to “Ubuntu 19.10: File Sharing to Windows and Mac”

  1. Your method worked to a point. I can make sub-directories inside the shared directory, however nothing can be added to them. I tried copying a number of directories with files in them into the shared directory, the folders were created, the files could not be copied into these copied folders. I went onto the target computer and did “chmod 777 *” then also did “chown user:user *” I was then able to copy the files into these directories. After they were in the directories, I could do nothing to them until I also did chmod and chown to the files. How do you make the directories and file accessible remotely. I need to do more than just read the newly created directories and actually be able write files to these sub-directories. Also the files can be read when sent, but again renames, moving them around are impossible. Adding files to directories only happens after walking over to the target machine, and file manipulation including writing only after chmod and chown is done to the sub-directories.

    1. You are correct, there was a missing option in the [homes] block, ” read only = no” (I’ve updated the post). Thanks for catching that!

  2. Everything worked perfectly yesterday. Today, after switching on my computers, they can’t connect. Error 0x80070035. Obviously, I made no changes in between. IP is static too. Any ideas?

    1. Nevermind, I disabled ufw and it works again. Is there a less blunt solution? sudo ufw allow from 192.168.0.0/16
      responds with “Skipping adding existing rule”.

      1. “ufw allow from 192.168.0.0/16” is just an example, you’ll need to allow access from whatever your internal network is…

Leave a Reply to dana Cancel reply

Your email address will not be published. Required fields are marked *