Setup SMB on Linux

Introduction

For some context, first read up on what “Samba” is: https://en.wikipedia.org/wiki/Samba_(software)

Samba is an implementation of the SMB protocol. You can read up on SMB here: https://en.wikipedia.org/wiki/Server_Message_Block.

But really, all you need to know is that SMB is a common way for Windows to access network file folders.

Scenario

Suppose you have a folder, or some disk mounted in /dev/media on some Linux computer. This Linux computer will be the “server”. You want to access the folder on some Windows client. This could be your main workstation running Windows 10, or Windows 11.

Here is how you can easily install and configure SMB on Ubuntu-based systems. These instructions work well for Pop!_OS.

First, make sure you have SMB installed:

sudo apt update
sudo apt install samba

Then you will need to configure smb.conf to host the share of interest:

sudo vim /etc/samba/smb.conf

In the workgroup configuration, you can leave it as-is if you haven’t renamed your network workgroup yet. (This is the case for most simple Windows home networks. ????)

Leave the user security as default, and just navigate to the end of the file and add the following. Please do note that ShareName just corresponds to your desired share name.

myUser, myUser2, should be valid SMB users.

[ShareName]
path = /path/to/your-directory
writeable = yes
browsable = yes
valid users = myUser, myUser2

Now, save the configuration. myUser, and myUser2 now has access to your-directory as ShareName.

Restart Samba:

sudo systemctl restart smbd
sudo systemctl restart nmbd

We are not done yet. myUser and myUser2 , etc need to exist as SMB users. So you need to add the users using this command:

sudo smbpasswd -a username

Where username corresponds to the username such as:

sudo smbpasswd -a myUser

Fill in a desired password for this SMB user.

Accessing the SMB Share on Windows

You should know the IP address, or hostname of your SMB server. (The Linux computer)

On Windows you can access the share name like this:

\\192.168.1.83\ShareName

That will then redirect to the proper path in your Linux computer. Again, ShareName corresponds to the config entry in smb.conf. So it is best to actually name it something memorable and not “ShareName”.