Shadowbane Guide to setting up Samba Server

Hi everyone Shadowbane here, I thought I would share how I set up a Samba server. This guide is made up of ideas gathered from two different guides and some of my own. A big shout out to @kenkoda who was a huge help trying to figure out why I couldn’t get the instruction from the first guide to work. Great Job Kenkoda.

Now for the guide. I used a video from a YouTuber called Chris Titus Tech and a guide from a web site called FOSSLinux. Now on to the steps.

Step 1 – Setting up Ubuntu and Windows Hosts

On your distro of choice, put IP and hostname in the /etc/hosts file. Also, add a record for the Windows IP and hostname. I am using Linux Mint and nano for this guide, you might need to use different commands or document editor than me. You will need to open Terminal and input the following command.

sudo nano /etc/hosts

That command will open your distros hosts file. Now you need to add the name of your Samba server and your IP address to the file. I have added mine as an example.

27.0.0.1       localhost
127.0.1.1 shadowbane-desktop
192.168.200.58 shadowbane-desktop
192.168.200.219 DeskTop-FBMM7QS
192.168.200.67 battleax-VirtualBox

Don’t forget you will need to change the IP addresses and server name to match your server name and IP address. You will also need to add any Windows and Linux machine IP addresses and names you want to share. I will demonstrate how to find that information for Windows when I get to the windows setup. As you can see from the example above, I have added a Linux machine that I wanted to share. The IP address for it is 192.168.200.58 and the name is shadowbane-desktop. The name of my server is battleax-VirtualBox. The IP address is 192.168.200.67.

On any Windows machines, you want to share files on open Windows Power Shell, open Notepad using the following command.
Notepad C:\Window\System32\drivers\etc\hosts. Now add your Samba Server’s IP address and its name, also add the IP address and name for each Windows machine and Linux machine you want to access. I have included a picture of my Windows hosts file.

Step 2 – Configure domains

Both machines must be in the same domain, check the default Windows workstation domain using the next command. To find what workgroup to set both machines in Open Power Shell with admin access. What you are looking for is the workstation domain name and the full computer name.

what you are looking for is the domain name and the full computer name of all your Windows machines.

Step 3 – Enable File Sharing on Windows

Enable File Sharing on Windows, open cmd or Power Shell with administrator privileges and run the next two commands.

netsh advfirewall firewall set rule group=“File and Printer Sharing” new enable=Yes
netsh advfirewall firewall set rule group=“Network Discovery” new enable=Yes

The first command sets up Windows 10’s default firewall to allow connections to your Linux Machines threw. The second command sets up SMB on Windows I believe. The output you should receive if the commands run correctly is as follows.
Enable-Filesharing-and-Network-Discovery

Remember I am using Windows 10 and its default firewall if you are using a different version of Windows or different firewall software you might need to do some research on how to set them up. If the second command doesn’t set up SMB on Windows you will need to do an additional step that I will demonstrate at the end of the guide.

Step 4 – Install Samba on Linux Mint

Make sure the distro you are using is up to date and all packages are up to date. On Ubuntu and all distros based on Ubuntu, the following commands should work.

sudo apt update
sudo apt upgrade

If you get a message after running update that all packages are up to date then running the sudo apt upgrade command isn’t necessary, but it won’t break anything if you go ahead and run that command.
Now that your distro is up to date, we can now install the Samba server on your Linux distro. Run the following command to install Samba.

sudo apt-get install samba samba-common python-glade2 system-config-samba

This command should install Samba on your Samba Server. I have included an example of my output from my terminal.

BlockquoteReading package lists… Done
Building dependency tree
Reading state information… Done
python-glade2 is already the newest version (2.24.0-5.1ubuntu2).
samba-common is already the newest version (2:4.7.6+dfsg~ubuntu-0ubuntu2.15).
The following additional packages will be installed:
libuser1 python-dnspython python-libuser tdb-tools
Suggested packages:
bind9 bind9utils ctdb ldb-tools smbldap-tools winbind
Recommended packages:
samba-dsdb-modules samba-vfs-modules
The following NEW packages will be installed:
libuser1 python-dnspython python-libuser samba system-config-samba tdb-tools
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,300 kB of archives.
After this operation, 16.8 MB of additional disk space will be used.
Do you want to continue? [Y/n]

You will want to press y for Yes to install or n for not to install. Go ahead and install it. The resulting output should look like this.

Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 python-dnspython all 1.15.0-1 [84.9 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 tdb-tools amd64 1.3.15-2 [22.4 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 samba amd64 2:4.7.6+dfsg~ubuntu-0ubuntu2.15 [855 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libuser1 amd64 1:0.62~dfsg-0.1ubuntu2 [56.4 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 python-libuser amd64 1:0.62~dfsg-0.1ubuntu2 [16.1 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic/universe amd64 system-config-samba all 1.2.63-0ubuntu6 [266 kB]
Fetched 1,300 kB in 1s (1,393 kB/s)
Selecting previously unselected package python-dnspython.
(Reading database … 293295 files and directories currently installed.)
Preparing to unpack …/0-python-dnspython_1.15.0-1_all.deb …
Unpacking python-dnspython (1.15.0-1) …
Selecting previously unselected package tdb-tools.
Preparing to unpack …/1-tdb-tools_1.3.15-2_amd64.deb …
Unpacking tdb-tools (1.3.15-2) …
Selecting previously unselected package samba.
Preparing to unpack …/2-samba_2%3a4.7.6+dfsg~ubuntu-0ubuntu2.15_amd64.deb …
Unpacking samba (2:4.7.6+dfsg~ubuntu-0ubuntu2.15) …
Selecting previously unselected package libuser1.
Preparing to unpack …/3-libuser1_1%3a0.62~dfsg-0.1ubuntu2_amd64.deb …
Unpacking libuser1 (1:0.62~dfsg-0.1ubuntu2) …
Selecting previously unselected package python-libuser.
Preparing to unpack …/4-python-libuser_1%3a0.62~dfsg-0.1ubuntu2_amd64.deb …
Unpacking python-libuser (1:0.62~dfsg-0.1ubuntu2) …
Selecting previously unselected package system-config-samba.
Preparing to unpack …/5-system-config-samba_1.2.63-0ubuntu6_all.deb …
Unpacking system-config-samba (1.2.63-0ubuntu6) …
Setting up python-dnspython (1.15.0-1) …
Setting up libuser1 (1:0.62~dfsg-0.1ubuntu2) …
Setting up python-libuser (1:0.62~dfsg-0.1ubuntu2) …
Setting up tdb-tools (1.3.15-2) …
update-alternatives: using /usr/bin/tdbbackup.tdbtools to provide /usr/bin/tdbbackup (tdbbackup) in auto mode
Setting up samba (2:4.7.6+dfsg~ubuntu-0ubuntu2.15) …
Samba is not being run as an AD Domain Controller, masking samba-ad-dc.service.
Please ignore the following error about deb-systemd-helper not finding samba-ad-dc.service.
Created symlink /etc/systemd/system/multi-user.target.wants/nmbd.service → /lib/systemd/system/nmbd.service.
Failed to preset unit: Unit file /etc/systemd/system/samba-ad-dc.service is masked.
/usr/bin/deb-systemd-helper: error: systemctl preset failed on samba-ad-dc.service: No such file or directory
Created symlink /etc/systemd/system/multi-user.target.wants/smbd.service → /lib/systemd/system/smbd.service.
Setting up system-config-samba (1.2.63-0ubuntu6) …
Processing triggers for ufw (0.36-0ubuntu0.18.04.1) …
Processing triggers for mime-support (3.60ubuntu1) …
Processing triggers for ureadahead (0.100.0-21) …
Processing triggers for desktop-file-utils (0.23+linuxmint8) …
Processing triggers for libc-bin (2.27-3ubuntu1) …
Processing triggers for systemd (237-3ubuntu10.33) …
Processing triggers for man-db (2.8.3-2ubuntu0.1) …
Processing triggers for hicolor-icon-theme (0.17-2) …

Now Samba has finished installing we can see if it installed properly, run the following command.

whereis samba

If you get back the following message Samba is installed correctly.

samba: /usr/sbin/samba /usr/lib/x86_64-linux-gnu/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz

Step 5 – Setup Public Shared Folder on Linux Mint

We are now going to set up a public share on Linux Mint, type the following command.

sudo mkdir -p /home/shadowbane/sambashare

What this command does is set up a public share folder called sambashare. remember you will need to replace /home/shadowbane with your home folder. You can set up more public shared folders by just changing the name of the folder in this command to something else than sambashare.

Now we need to set the permission for the folder so anyone can access it, type the following commands.

sudo chown -R nobody:nogroup /home/shadowbane/sambashare/
sudo chown -R nobody:nogroup /home/shadowbane/sambashare/

What the first command does is set up default user. The second command sets up the permissions for nobody.

Step 6 – Copy and setup Config file

Copy Samba default configuration file to be a backup file in case any error happens in the future. It is a good idea to copy the default Samba configuration file in case you want to or need to go back to the default configuration. You do this by issuing the following command in Terminal.

sudo mv /etc/samba/smb.conf /etc/samba/smb.backup

What this command does is it takes the default SMB config file and creates a new one called smb.backup. Now that we have a copy of the old SMB config file encase we need to switch back, let’s create a new config file for Samba. Type the following command in Terminal.

sudo nano /etc/samba/smb.conf

We have just opened the samba config file smb.conf, that is what this command does. Now add the same information as I have in my smb.conf file except you will want to make some changes that I will explain in a minute.

[global]
         workgroup = WORKGROUP
         server string = Samba Server %v
         netbios name = DeskTop-FBMM7QS
         security = user
         usershare owner only = false
         hosts allow = 192.168.200.0/24
         hosts deny = 0.0.0.0/0


[SambaShare]
              Comment = Samba Shared Directory
              path = /home/shadowbane/sambashare
              writable = yes
              guest ok = yes
              read only = no
              force user = nobody

You will want to change the Netbios name to whatever the full computer name is for the Windows computer you are trying to add as a Samba client. You will want to change the path line to whatever your Home directory is on the Linux machine you installed Samba. Also, you will want to replace the IP address to whatever your local network address is. Now I have explained the changes needed I will explain what each line does in the Samba config file.

The global section is where you set all for global options (meaning all the options that aren’t used for the individual shared folders. The workgroup line tells the Samba server which workgroup your Linux machines and Windows machines are in. Remember for this option to work all your Linux machines and Windows Machines have to be in the same network and workgroup. I don’t know what the line server strings do, all I know is the guide I used to config my smb.conf file had it in there. The NetBIOS name is the full Windows computer name you are trying to share files from. The line usershare owner only sets up the option for guest access (this is just a guess on my part). I don’t know what the line security does, but I would take a guess it has something to do with allowing guest access. The line host allow sets up the option only allowing computers within a certain IP range access to share folders or files. For example, the line host alow in my smb.conf file only allows computers on my network access to the Samba Server. The line hosts deny makes sure the Samba server doesn’t allow any computers, not in the approved network range. Now I will explain the options for the shared folders.

The options for the guest share are explained as follows. A guest share is a shared folder anyone can access. The line

Comment = Samba Shared Directory
is just a comment explaining the following lines are the options for the guest share. The path option is only showing where the share is located. the following option is telling the Samba Server anyone can read and create files within the SambaShare.
writable = yes
The guest OK option tells the Samba Server everyone has access to this samba share.
guest ok = yes
The read-only option tells the Samba Server everyone can read and write files inside the Samba Share.
read only = no
If this option was changed to yes then the files inside the Samba Share would only be readable by everyone, no one would be able to make any changes. The force user option tells Samba Server what user name to use as a guest.
force user = nobody

I don’t know for sure, but I suspect because of how Windows works you need a general user name when you set up guest Samba share to be able to access your guest shares, otherwise you won’t be able to access your guest shares.

Check the Samba configuration file using the next command.

testparm
You should get the following output in Terminal if you correctly set your setting in smb.conf.
Load smb config files from /etc/samba/smb.conf

Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

Now to the next step.

Step 7 – Restart Samba Service.

You will need to restart the Samba Server to see if your Windows machine will be able to access the Samba share you created. The following command will restart the Samba Server.

sudo service smbd restart
If you don't get any errors and your output in Terminal looks like the following Picture the Samba server is running.
shadowbane@shadowbane-desktop:/etc/samba$ sudo service smbd restart
[sudo] password for shadowbane:            
shadowbane@shadowbane-desktop:/etc/samba$ 



Step 8 – Access Samba Share on Windows

Now from your Windows machine, open run and use the following command to open Ubuntu shared folder.

/your ip address/sambashare.

1 Like

I had to look up a guide a few days ago, but it wasn’t nearly as good as yours! :smile:

@Ethernet_Warrior Thanks for the comment, if I was a little help I am glad. I know it isn’t complete yet. have been having internment issues with the network which causing the concent saving of edits, so I can get my network back up.

1 Like