I try to share folder on ubuntu and connect to it through windows, currently know how to do it by these steps:
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, I don't find on internet a way to share the folder with all the following checked by a Command Line Interface.
These are the steps I want to 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/Shared_Folder
which terminal instruction can make this? No matter what thanks a lot!
I tried to built a bash script that will do that for me (based on ubuntu community link ):
sudo apt-get update
sudo apt-get install samba
sudo apt-get install smbclient
sudo cp /etc/samba/smb.conf ~/Desktop/backup
if sudo grep -Fxq '[Shared_Folder]' /etc/samba/smb.conf
then # code if found echo the '[Shared_Folder] >> /etc/samba/smb.conf' exist at samba.conf
else echo [Shared_Folder] | sudo tee -a /etc/samba/smb.conf echo path = /home/mkdahan/Desktop/Shared_Folder | sudo tee -a /etc/samba/smb.conf echo valid users = mkdahan | sudo tee -a /etc/samba/smb.conf echo read only = no | sudo tee -a /etc/samba/smb.conf
fi
# Restart the samba
sudo service smbd restart
# check your smb.conf for any syntax errors
testparmbut, when i open the properties of this folder using the GUI of the ubuntu I see that this folder is still un-shared:folder_unshared
if I open /etc/samba/smb.conf, i see the new lines appear:
[Shared_Folder] path = /home/mkdahan/Desktop/Shared_Folder read only = No valid users = mkdahanmeans after the reset of the samba it should be shared according to the smb.conf file.
few questions:
- Does the GUI aligned to what i execute using CLI (Does the sharing should be updated at the GUI also)?
- Do I miss something at my steps?
2 Answers
I just found a great piece of software that helped me in a similar situation, I just started using it. It's called SSHFS, it lets you mount the filesystem of remote devices (Linux or Windows) on your Windows PC over SSH and SFTP. Very good GUI, good for many hosts. Very fast to install and use on your server and Windows PC. You can also change the root folder that it goes into, such as a single folder you want to share instead of the whole filesystem.
Does the GUI aligned to what i execute using CLI (Does the sharing should be updated at the GUI also)?
According to your script. Yes.
Do I miss something at my steps?
Your file explorer and server might be having a protocol mismatch. In /etc/samba/smb.confTry inserting this line just below [global]
server min protocol = NT1