Homelab Basics - Samba Network Shares









Hello there! Today I will be explaining what a Samba network share is, why you need one, and how to set it up. You will only need your server, and for this tutorial I will be using Ubuntu 18.04 Server LTS as my operating system, under my DL360 G6 running vSphere.





Requirements

-1 Core 500mhz+ Processor, 1ghz preferred

-256mb RAM, 1gb+ preferred

-Hard Drive/SSD to use as share

-Internal Network Connection, Ethernet preferred





What is a Samba Network Share, and why would you need one?

A samba network share is a filesystem that runs on your network, that is always connected to your network. Filesystems connected to your network are referred to as NAS' and are the backbone to both a business and home network. NAS' allow the user to store files not locally on their computer, but on a server's storage space. This helps conserve storage on the user's computer and allows easy file transfers between different user's computers.





Samba in particular uses the SMB/CIFS protocal for transferring files, and can be interfaced through (almost) all operating systems. This allows Samba to be very flexible in the transfer of files from Windows to Linux to MAC to Windows again.





How to set it up?

As stated above, for this install we will be using Ubuntu 18.04.1 LTS as our OS of choice. Simply download it from the link, and burn it to a USB drive using Rufus (Rufus is my preferred burning method, you can use whatever burner you want).





After you have installed ubuntu and followed the login directions, update your computer's packages and security updates. This should always be done on a fresh install





sudo apt-get update && sudo apt upgrade && sudo reboot





After done updating, check if samba is installed.





whereis samba





This checks to see if samba is installed. If samba is not installed, run the following command





sudo apt install samba && sudo apt update





After this is done, you need to make user's named based on permissions. For this example we will use the usernames "family", "plex", and "guest". Run the following commands to add your users, changing them as you see fit (if you dont want the names to be family plex and guest.)





sudo adduser family && sudo adduser plex && sudo adduser guest





You will need to create new password for the users when prompted with "Enter new UNIX password". Simply create new password and you are off to the races! Press enter to accept the defaults when prompted with





Full Name []

Room Number []

Work Phone []

Home Phone []

Other []





Enter Y or press enter to confirm defaults to continue. Now you will need to do the same on Samba. The passwords will need to be the same as the corresponding user's passwords.





sudo smbpasswd -a family





After you have run the first command, hit the up arrow to retype the previous command and just modify it from there. The sudo smbpasswd command adds a user to samba and configures the passwd. We will have to run this command for all users, so





sudo smbpasswd -a plex

sudo smbpasswd -a guest





Be sure that the passwords entered are EXACTLY the same as the ones used for the users. Now you need to make the directories you will be sharing. run the following commands to create sample directories for your users. Modify the commands as you see fit, as this command is not a one size fits all one. You will need to make sure that your folders are named the way you want them to. The things you should change will be in blue, not red





cd && sudo mkdir /Everybody && sudo mkdir /Everybody/Media && sudo mkdir /Family && sudo mkdir /Family/Documents && sudo mkdir /Plex && sudo mkdir /Plex/Media





You can rename directories at a later date by using





sudo mv OldDirectoryName NewDirectoryName





Now you need to assign permissions to the folders



sudo chmod 777 /Everybody && sudo chmod 777 /Everybody/Media && sudo chmod 777 /Family && sudo chmod 777 /Family/Documents && sudo chmod 777 /Plex && sudo chmod 777 /Plex/Media



This will enable all of the users with physical access to the Samba shared folders. This is important because it will allow Samba to access the folders and make changes when necessary.Now that users, passwords, folders, and permissions have been setup, its time to modify the config files in samba. To do this, we will modify the existing samba config file.



Configure The Share

To configure the config file of samba, we will need to edit the samba.conf file. To do this, we will run the following command



Edit: People of reddit have brought to my attention that Vi is not the most user friendly text editor. I agree with this sentiment, and have adjusted the guide to use nano instead of vi. You can use any text editor that you want, but Nano is recommended for beginners. It all goes to personal preference though.



sudo nano /etc/samba/smb.conf



Arrow down to the "Workgroup" area. Verify that it is the same as your window's computer workgroups. You can confirm what the name is by going to

Control Panel -> System and Security -> System and looking at the "workgroup" area.



After you have confirmed the workgroup selection coincides with your windows computer's workgroup, scroll down to the very end of the file. You will need to enter this text at the very end of smb.conf. Remember that case matters in folder names. The text should change color and look similar to how it does here. If it does not change colour, you have entered it incorrectly.



[Everybody]

path = /Everybody

browseable = yes

read only = no

valid user = family plex guest



[Family]

path = /Family

browseable = no

read only = no

valid user = family plex



[Plex]

path = /Plex

browseable = no

read only = no

valid user = plex



Explanation

The brackets name doesnt matter, as it just names it in the confige file for easy access if you have multiple shares.



Path is the path in your linux server where the files will be located. It is important that you get this part right.



Browseable shows whether or not you will be able to browse the files using windows file explorer without having the credentials to the users specified in valid user. Basically, make this no for all private folders, and yes for all public folders.



Read only denotes if the users specified can write to the file foler, ie; make changes



Valid User denotes the users that can log on to see the folders and sub folders.



After you have made the necessary changes, press escape to get out of write mode, and hit ctrl +x to exit. Then follow the prompts answering y to the prompt to save changes to the config file. You will need to test the file to make sure that it will work in your share, so do



testparm /etc/samba/smb.conf



This tests for any errors. If you followed the typing exactly no errors should popup. After you have finished this, congratulations! You have a new file server setup using samba. Do



sudo reboot



to reboot the system and let it go! To see if it is successfully configured, go to your ubuntu server's ip address in the file folder using //192.168.1.6 (use whatever IP was assigned either by you or by the DHCP. You can check this by typing ifconfig in your linux terminal.) It will prompt for login information, so just login using one of the users you created and off you go! You should be able to store files in your new local file server.



Thanks for reading as always, if I made any errors then yell at me in the reddit comments and I will be more than happy to change the guide. I made this guide because setting up a file server was one of the first things that I wanted to do with my server, and it was quite difficult the first time I did it. It gets very easy every time you do it after the first time though. This guide took me ~10 minutes to configure/setup the system, and around an hour to type it up.