I try to share folder on ubuntu and connect to it through windows,
currently i know how to do it by these steps (which based on GUI):
https://linuxhint.com/share-folder-on-local-network-with-ubuntu/
but,
since I have a lot of computers I need to do it on, I want to build a bash file that will do it automatically on each computer i will run it,
I don't find on internet a way to share the folder with all the following checked (at "local network share picture" below) by a Command Line Interface.
these are the steps I wnat o do using CLI:
Choose the “Local Network Share” selection from the displayed list items:
Local Network share picture
check the boxes displayed in the following attached screenshot and then click on the “Create Share” button:
Folder sharing picture
Lets say i want to share the following folder:
/home/mkdahan/Desktop/Share_Folder
which terminal instruction can make this?
I tried to build a script that will share the folder /home/mkdahan/Desktop/Share_Folder but it still keep the folder "un-shared" as the GUI keep show, even after reboot:
#!/bin/bash
sudo apt-get update
sudo apt-get install samba
sudo apt-get install smbclient
sudo cp /etc/samba/smb.conf ~/home/mkdahan/Desktop/Share_Folder
if sudo grep -Fxq '[Share_Folder]' /etc/samba/smb.conf
then
# code if found
echo the '[Share_Folder] >> /etc/samba/smb.conf' exist at samba.conf
else
echo [Share_Folder] | sudo tee -a /etc/samba/smb.conf
echo path = /home/mkdahan/Desktop/Share_Folder | sudo tee -a /etc/samba/smb.conf
echo valid users = salab | sudo tee -a /etc/samba/smb.conf
echo read only = no | sudo tee -a /etc/samba/smb.conf
fi
if sudo grep -Fxq 'server min protocol = NT1' /etc/samba/smb.conf
then
echo the "server min protocol = NT1" exist at /etc/samba/smb.conf
else
# append after [Global] the line "server min protocol = NT1"
echo try to write to smb.conf
sudo cp /etc/samba/smb.conf /home/mkdahan/Desktop/Share_Folder
sudo sed -i '/^\[global\]/a\server min protocol = NT1' /home/mkdahan/Desktop/Share_Folder/smb.conf
sudo mv /home/mkdahan/Desktop/Share_Folder/smb.conf /etc/samba/smb.conf
fi
# Restart the samba
sudo service smbd restart
# check your smb.conf for any syntax errors
testparm
also, I see that if I share the folder through the GUI, the smb.conf file don't have the changes the script do, so i believe this is not the right method to do the requiered share (I used this method since this what i found on the NET).
LongStoryShort:
How can i do using CLI the two steps can be done using GUI demonstrated above?
No metter what thanks a lot!