Share folder on local network with ubuntu
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):
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:
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]/aserver 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).
How can i do using CLI the two steps can be done using GUI demonstrated above?
No metter what thanks a lot!
There are two different files you could change to create a samba share:
You can use the file manager GUI to do this, using
Local Network Share. Or you can use the
net usershare add ... command, but I find the syntax awkward (see this post on Ubuntu Forums). Finally, you could edit the files manually if you know what you are doing.
This will add a "share" emblem on the folder being shared.
Check the created share using
net usershare info --long
There is no GUI tool to edit this, you must edit it manually.
This will not create a "share" emblem on the folder being shared.
Check the created share using
I would advise creating the shares in smb.conf itself since you are altering the base settings there anyway with your "server min protocol" adjustment.
Just remember not to share the same folder using both methods at the same time.