{"id":2407,"date":"2019-05-03T02:36:28","date_gmt":"2019-05-03T02:36:28","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=2407"},"modified":"2019-05-03T02:50:10","modified_gmt":"2019-05-03T02:50:10","slug":"setup-samba-share-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/setup-samba-share-on-ubuntu\/","title":{"rendered":"Setup Samba share on Ubuntu"},"content":{"rendered":"\n<p>In the following commands change &lt;user_name> and &lt;share_name> to the user you want and the name of the share directory.<\/p>\n\n\n\n<p><strong>Install samba and samba client<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get install samba smbclient<\/pre>\n\n\n\n<p><strong>Setup Samba user<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo useradd -m  &lt;user_name>  --shell \/bin\/false &amp;&amp;  <br>sudo passwd  &lt;user_name> <br>sudo smbpasswd -a  &lt;user_name><br><\/pre>\n\n\n\n<p><strong>Create Share Directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo mkdir \"\/home\/&lt;user_name>\/&lt;share_name><br>sudo chown &lt;user_name>:&lt;user_name> \/home\/&lt;user_name>\/&lt;share_name<\/pre>\n\n\n\n<p><strong>Make share directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir \/home\/&lt;user_name>\/&lt;share_name><\/pre>\n\n\n\n<p><strong>Configure Samba conf<\/strong><\/p>\n\n\n\n<p>Add the following to the bottom of the \/etc\/smb.conf file.  Change the &lt;folder_name>, &lt;user_name> etc to the ones created above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[&lt;folder_name&gt;] <br>path = \/home\/&lt;user_name&gt;\/<br>&lt;folder_name&gt; valid <br>users = &lt;user_name&gt; <br>read only = no<\/pre>\n\n\n\n<p><strong>Bash script <\/strong><\/p>\n\n\n\n<p>You can use the following bash script to automatically install and setup a samba share.  Create a file called smb.sh and paste the following in<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">!\/bin\/bash<br> <br># incredigeek.com  <br># Ubuntu Samba share auto setup <br>#<br>sambaUser=\"smbuser\"<br>smbFolder=\"smb_share\"<br>sudo apt-get install samba smbclient<br>sudo useradd -m ${sambaUser} --shell \/bin\/false<br>echo \"Enter the password you want to use for the smb user. 4 times.\"<br>sudo passwd ${sambaUser}<br>sudo smbpasswd -a ${sambaUser}<br>sudo mkdir \"\/home\/${sambaUser}\/${smbFolder}\"<br>sudo chown ${sambaUser}:${sambaUser} \/home\/${sambaUser}\/${smbFolder}<br>sudo echo \"[${smbFolder}]\" >> \/etc\/samba\/smb.conf<br>sudo echo \"path = \/home\/${sambaUser}\/${smbFolder}\" >> \/etc\/samba\/smb.conf<br>sudo echo \"valid users = ${sambaUser}\" >> \/etc\/samba\/smb.conf<br>sudo echo \"read only = no\" >> \/etc\/samba\/smb.conf<br>sudo systemctl restart smbd<br>echo \"Samba setup script finished\"<br>echo \"Access via $(hostname -I)\/${smbFolder} ; username = ${sambaUser} ; password = whatever you put in\"<\/pre>\n\n\n\n<p>Make executable <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chmod +x smb.sh<\/pre>\n\n\n\n<p>Execute script<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo .\/smb.sh<br><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the following commands change &lt;user_name> and &lt;share_name> to the user you want and the name of the share directory. Install samba and samba client sudo apt-get install samba smbclient Setup Samba user sudo useradd -m &lt;user_name> &#8211;shell \/bin\/false &amp;&amp; &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/setup-samba-share-on-ubuntu\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,28],"tags":[616,7,613,615,614,49],"class_list":["post-2407","post","type-post","status-publish","format-standard","hentry","category-linux","category-ubuntu","tag-file-share","tag-linux-2","tag-samba","tag-share","tag-smb","tag-ubuntu-2"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=2407"}],"version-history":[{"count":7,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2407\/revisions"}],"predecessor-version":[{"id":2416,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2407\/revisions\/2416"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=2407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=2407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=2407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}