Simple Samba file sharing set-up for Kubuntu 20.04

Samba is the name of the open source version of the protocol that the Windows operating system uses to share files. It is useful because it is fairly well supported on Linux, Mac and Windows machines although Windows likes to change things to make it harder sometimes. The steps below will set up a simple share using the default users Public folder in Kubuntu 20.04.

First you need to install Samba. To do so open up Konsole and type,

sudo apt -y install samba

And push enter to execute the command. This will install the Samba server if it wasn’t previously installed. The next step is to add yourself as a samba user. You have to be a user already to be a Samba user so use your existing user-name or it won’t work.

In the terminal again, type,

sudo smbpasswd -a <insert user-name>

Where <user-name> is your user-name. It will then ask you to enter your password and then confirm it. You don’t have to use your account password. In fact it is more secure to use a different one for networking as you tend to give it out occasionally so other people can access it.

The next step is to backup the configuration file and then edit it. You can backup the file by typing in the terminal (or copying and pasting in this case),

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup

This will create a copy of the Samba configuration and name it smb.conf_backup so, if your file ever gets messed up and you need to go back to the start, you will have an original copy.

You can then edit the file using a program called nano. It is a text editor that works in the terminal. Open the smb.conf file with it by typing,

sudo nano /etc/samba/smb.conf

After the file has opened, you need to go to the very bottom of the file. This can be done using the down arrow or your mouse wheel. Once there, on a new line, you need to paste this share definition. You can change it in nano if you want but it might be easier to change it in a visual text editor like Kate. That can also be found in the main menu under the utilities category. Basically, you need to change all the parts in marked like <includingthebrackets> to suit your own installation.

[<share name>]
path = /home/<username>/Public/
valid users = <username>
read only = no
public = yes

(Correction with thanks to comment from Rowland Penny below)

So if my user name was squalidh then the share would look like,

[Squalidh Share]
path = /home/squalidh/Public/
valid users = squalidh
read only = no
public = yes

(Correction with thanks to comment from Rowland Penny below)

After finishing save the file in nano using ctl+x (press control and then the key x) and restart the samba server with the command,

sudo systemctl restart smbd

Then open up Dolphin, the file manager, and on the left there should be an entry called Network. Select that then Shared Folders (smb) and your Windows Network in your Workgroup should show up. Entering that should show your computer name and then entering that should show your share name (The /home/squalidh/Public/ share from above). You will be asked to enter your samba user password before being able to enter that directory at which point you will see inside the folder Public that you have shared. This is the same Public folder that is inside your home directory.

That should be it. You should be able to create and destroy files in that directory and so should anyone on the network with your user name and password.

2 thoughts on “Simple Samba file sharing set-up for Kubuntu 20.04”

  1. Hi, your effective smb.conf is this:
    [Squalidh Share]
    path = /home/squalidh/Public/
    valid users = squalidh
    read only = no
    public = yes

    You do not need the other lines, they are the defaults. Also, you have a problem, you cannot use ‘guest ok = yes’ (this is the synonym for public) with ‘valid users’. Any ‘guest’ users will be mapped to ‘nobody’ before they get to the share, so, as they are not ‘squalidh’, they will be denied access.

    Reply

Leave a comment