Forum › Forums › General › Tips and Tricks › How-to create a (samba) shared folder in your local network
- This topic has 6 replies, 5 voices, and was last updated Aug 13-6:33 am by madibi.
-
AuthorPosts
-
March 14, 2022 at 5:19 pm #79058Member
PPC
I recently discovered the joys of using a shared folder to move files between my computers. It was a pain to set the shared folder because I did not find, in the repository any GUI that I was able to use to configure samba. I did eventually find a real nice GUI (not yet available in the repository), but, what really allowed me to first configure and use a network shared folder was the excellent YouTube channel “learnlinux.tv”. I jotted down a few notes that I used to create this “How to”. Following it will allow anyone to create a network shared public folder.
How to create a public shared folder on your local network:
(Adapted from https://www.learnlinux.tv/setting-up-simple-samba-file-shares/)1-Install samba with all it’s dependencies, Open a terminal and run this commands, enter your password if asked to:
sudo apt update && sudo apt install samba2- Make sure samba is not being executed, on the terminal, run this command:
sudo service smbd stopand then back up the default Samba configuration, just to be on the safe side (optional step)
sudo mv /etc/samba/smb.conf /etc/samba/smb.confBAK3- Open samba configuration file for edition:
sudo geany /etc/samba/smb.conf4- Edit the smb.conf file:
Delete any of the file’s contents and replace it with the text below, making sure that you replace the capitalized text with the appropriate values. FILESERVER and WORKGROUP do not have to be replaced, unless you what to and SHARED-FOLDER can/should be replaced with the name of the folder you want to be displayed (do not use spaces or special characters). The only value you have to adapt when editing this config file is /FULL/PATH/OF/FOLDER/TO/BE/SHARED that has to be replaced with the full path of the folder you want to be shared: for example- /home/ppc/PublicFiles
Optionally you can also replace the smbuser and smbgroup values with any values you select, but you’ll have to apply those exact values on the terminal commands that you’ll have to enter after editing the smb.conf file…[global]
server string = FILESERVER
workgroup = WORKGROUP
security = user
map to guest = Bad User
name resolve order = bcast host[SHARED-FOLDER]
path = /FULL/PATH/OF/FOLDER/TO/BE/SHARED
force user = smbuser
force group = smbgroup
create mask = 0664
force create mode = 0664
directory mask = 0775
force directory mode = 0775
public = yes
writable = yes5- Save the config file and close geany and, on the terminal run this commands to create the required and group and user:
sudo groupadd --system smbgroup sudo useradd --system --no-create-home --group smbgroup -s /bin/false smbuserIMPORTANT: make really sure that the folder you what to share already exists and DO NOT SHARE YOUR HOME FOLDER!!! (but you can share any sub-folder inside your home- example: /home/ppc/downloads
6- Change ownership/permissions of the shared folder (replace /FULL/PATH/OF/FOLDER/TO/BE/SHARED with the appropriate address to your shared folder):
sudo chown -R smbuser:smbgroup /FULL/PATH/OF/FOLDER/TO/BE/SHARED
sudo chmod -R g+w /FULL/PATH/OF/FOLDER/TO/BE/SHARED7- Make sure that samba is started:
sudo service smbd restartThat’s all.
How to access your shared folder from another device connected to your network:
You can now access your shared folder from any other computer connected to the same local network by entering, on the address bar of your file manager:
//IP.of.host.computer/SHARED-FOLDER
(replacing, of course, the “IP.of.host.computer” part with the real IP of the computer that is sharing the folder(s) and “SHARED-FOLDER” with the name you choose, for example//192.123.4.5/PublicFolder
How do you get the IP of the computer that is hosting the shared file? On that computer open the terminal and run this command:
ifconfig
On the line just below you network connection (ex: “eth0” if you are using a network cable or “wlan0” if you are using wi-fi) is a line staring with “inet”- the long string of four numbers separated by dots- that’s the IP you want.Extra tip- sharing more folders/sharing protected folders:
You can add as many shared folders as you want, to the smb.conf file, taking care to remember to:
-always disable samba before editing the config file:
sudo service smbd stop-edit the samba config file, adding and adapting the [SHARED-FOLDER] part included above. If you want to make it so the users accessing your shared folder can’t change it, make sure to change the last line “writable = yes” to “writable = no”:
Example:
[PROTECTED-SHARED-FOLDER]
path = /FULL/PATH/OF/FOLDER/TO/BE/SHARED/NUMBER/2
force user = smbuser
force group = smbgroup
create mask = 0664
force create mode = 0664
directory mask = 0775
force directory mode = 0775
public = yes
writable = no-Save your editions to the config file
-Don’t forget to change ownership of the newly shared folder(s), adapting the commands from step 6.
-Restart samba:
sudo service smbd restartTroubleshooting:
-Don’t forget- you are sharing the folder over your local network. You can’t access a shared folder over the internet (well, there are ways to do it, but it’s DANGEROUS. If you want to access your local files via the Internet, you’ll be better off using FTP)
-You can’t obviously access a shared folder if the device that hosts the shared folder is off or off-line… If the host of the shared folder is on-line but you can’t access the shared folder, make sure to run (on the host computer);
sudo service smbd restart
-Some File Managers get “frozen” if they lose connection to a mounted shared folder – zzzfm is one of such file manager- if that happens you’ll either have to re-enable the shared folder on the host computer and then unmount it on the remote computer or you’ll have to kill zzzfm and forcibly unmount the mount point… Yeah… it’s not pretty… You’ll have to force zzzfm to “let it go, let it go” (yes, it’s a “Frozen” joke)P.
- This topic was modified 1 year, 1 month ago by PPC.
- This topic was modified 1 year, 1 month ago by PPC.
- This topic was modified 1 year, 1 month ago by PPC.
March 14, 2022 at 10:24 pm #79080Membermadibi
::Many thx for the tireless work you do for all of us.
This kind of guide on Samba is quite easy to find on the internet, not in the antix world where there was another strategy to have a samba connection.
The one suggested in this post is the “traditional” one.
I would like to highlight the great usefulness of the contents of point 4. In fact this removes all the problems that are very easy to encounter when trying to make the Samba network work.
On some occasions I find useful the testparm command to verify that I have not made any type of error and to have a dump of my service definitions (simply open the terminal and type: “testparm”).
March 15, 2022 at 11:18 am #79103Member
marcelocripe
::Hello PPC.
Thank you very much for this excellent tutorial.
– – – – –
Olá PPC.
Muito obrigado por este excelente tutorial.
August 9, 2022 at 6:55 pm #87027Member
blur13
::PPC, thank you! I just used your guide to create samba shares and I too have discovered the joy in this. Now if only I could figure out how to have all my devices on one network. I have a network switch in my closet and ethernet cables going through the walls to different rooms. One cable goes straight into my desktop system. Another cable goes into a wireless router. Devices on the wifi can see each other. Devices connected to the LAN ports on the router can see wifi devices and vice versa. But nothing connected to the router can see my desktop. The obvious solution of connecting the desktop to the router isnt an option as they are too far apart. If I connect a laptop directly into the network switch it can see the desktop. If I connect from network switch into LAN part of the router then it acts like yet another switch but wont create a wifi. The other obvious option of having the router in the closet is also not a solution because then the signal gets really weak. It seems like the WAN port on the router creates a completely different network that cant be accessed by devices connected to the network switch. Any system admins out there?
August 10, 2022 at 12:08 am #87030Member
oops
::[global] # Change this to the workgroup/NT-domain name your Samba server will part of workgroup = Workgroup # With some BOX since Samba 4.11.9 the need to add into the [global] section: client ipc min protocol = NT1 client ipc max protocol = SMB3 client min protocol = NT1 client max protocol = SMB3 server min protocol = NT1 server max protocol = SMB3 ...August 10, 2022 at 8:45 pm #87059Member
blur13
August 13, 2022 at 6:33 am #87148Membermadibi
::Dear blur13, I’m not a system admin, it is for this reason that so far I have not answered you.
But in the absence of others, I try to spend my 2 cents.First of all it is important how is your router (brand and model should be helpful).
I assume that it is as the majority of the latest 8-10 years: on the back with 4 yellow ports (the lan ones – eth) and one red or blue (the wan one – this latest one may be or eth or rj45).
In case you have the factory settings, the wan port is the “internet in” this means from fiber, adsl, or another lan connected to the internet. And you are right: the wan port is another lan.
The 4 yellow ports act as a switch, if you link one of those to your switch, every pc linked to the switch, or to the yellow ports, or to the wifi, is on the same network and can see each other (ping, send files, print, etc).
—————————————————-
In case yor computer is the origin of the internet of your lan, and that is the reason why it is connected to the wan port of the router, AND for some reason if you connect it to the router through the yellow port the wifi don’t work,
IN THIS CASE the simplest way is to use a 2nd eth card or a wifi dongle on your pc to connect it also “downstream” to the router. In this way it can simultaneously do the 2 jobs: internet connection, and pc of the lan.The above is not a solution that purists like, but it worked well for me for a couple of years in my house
Good luck
m- This reply was modified 8 months, 3 weeks ago by madibi.
-
AuthorPosts
- You must be logged in to reply to this topic.