DEV Community

Cover image for Set up a Samba server in Ubuntu Linux: Quick Guide
Aaron Wolf
Aaron Wolf

Posted on • Updated on

Set up a Samba server in Ubuntu Linux: Quick Guide

This is a quick tutorial if you want to set up a home server and have files available to anybody who has access to your wifi or home network. This home server can be any computer; it doesn't need to be a dedicated machine.

All of my home computers run Linux (because I'm a nerd), so this tutorial covers how to set up Samba on Ubuntu. All the work is done in the terminal.

Step 1: Install Samba

Open the terminal: ctrl + alt + t.

$ sudo apt install samba

Alt Text

There's more output, just go with it.

step 2: Make sure Samba isn't running

$ sudo service smbd stop

Step 3: Rename the current Samba configuration file

We're just going to rename the current config file so that if we need it again we still have it, even though you probably won't need it.

$ cd /etc/samba
$ sudo mv smb.conf smb.conf.old

Alt Text

Step 4: Edit the config file

Well, since we renamed the original config file one we're going to create a new one in nano (feel free to use vi if you're a snob).

$ sudo nano smb.conf

Alt Text

server string is just a description of your server. workgroup is the name of your work group. These two can be whatever you want. The next 3 lines are just for quick easy settings (no passwords needed etc...).

Step 5: Edit the Samba shares

We're still editing /etc/samba/smb.conf, but I thought this deserved its own step.

You can make as many samba shares as you want. I have a documents directory that I want anybody to have access to. I'll also add the music folder from my plex server. What you put in [Square Brackets] will be the name of the folder/directory everyone sees on the network.

Alt Text

force user must be the user of the server, otherwise you may get a username and password prompt.

path is (obviously) the path to the shared directory.

If writable = no that means that nobody can make changes to this directory. Set to yes if you want others to be able to change it. This gives full CRUD abilities on your server to anyone who can access your wifi or home network.

public = yes so that everyone can see it!

Here's a picture of the whole file:
Alt Text

Hit ctrl-O to save (and enter), then ctrl-X to exit nano.

Step 6: Check your work.

Just like your math teacher used to tell you. (I used to be a math teacher, can you tell?)

$ testparm

What you'll see is a bunch of stuff. If you see what you just typed everything should be ok!

Alt Text

Step 7: Start the Samba service

$ sudo service smbd start

Step 8: Enjoy your Samba server

Now you can go into your computer's filesystem and check out your cool stuff!

Alt Text

Alt Text

Alt Text

Alt Text

Discussion (0)