{"id":1888,"date":"2021-04-14T17:31:38","date_gmt":"2021-04-14T17:31:38","guid":{"rendered":"https:\/\/dft.wiki\/?p=1888"},"modified":"2026-06-08T22:58:25","modified_gmt":"2026-06-09T02:58:25","slug":"samba-server-and-client-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=1888","title":{"rendered":"SAMBA Server and Client on Ubuntu"},"content":{"rendered":"<p>The choice between NFS and Samba depends on who you are sharing with. Linux supports both NFS and Samba, but Windows only supports Samba.<\/p>\n<p>To learn about NFS file sharing, read: <strong>NFS Server and Client on Ubuntu 22.04<\/strong> [<a href=\"https:\/\/dft.wiki\/?p=195\">Link<\/a>].<\/p>\n<hr \/>\n<p><strong>SERVER &#8211; SAMBA CONFIG<\/strong><\/p>\n<pre>sudo apt update\r\nsudo apt install samba -y\r\nsudo ufw allow samba\r\nsudo nano \/etc\/samba\/smb.conf<\/pre>\n<p>The Samba configuration file is self-explanatory. Parameters prefixed with &#8216;<strong>;<\/strong>&#8216; are commented out and inactive.<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" class=\"wp-image-318\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/image-20.png\" alt=\"\" \/><\/figure>\n<p>Samba configuration is organized in blocks. Add this block at the end of the file:<\/p>\n<pre>[Home_<strong>userName<\/strong>]\r\npath = \/home\/<strong>userName<\/strong>\/\r\ncomment = Personal Files\r\nwriteable = yes\r\ncreate mask = 0777\r\ndirectory mask = 0777\r\nbrowseable = yes\r\npublic = yes\r\nvalid users = <strong>userName<\/strong><\/pre>\n<p>Customize this block to match your setup:<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td>[Home_<strong>userName<\/strong>]<\/td>\n<td>The <strong>share name<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>path = \/home\/<strong>userName<\/strong>\/<\/td>\n<td>The <strong>directory being shared<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>comment = Personal Files<\/td>\n<td>A <strong>description<\/strong> of the share.<\/td>\n<\/tr>\n<tr>\n<td>writeable = yes<\/td>\n<td><strong>Allow<\/strong> the client to <strong>write<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>create mask = 0777<\/td>\n<td>Permissions applied when a file is created.<\/td>\n<\/tr>\n<tr>\n<td>directory mask = 0777<\/td>\n<td>Permissions applied when a directory is created.<\/td>\n<\/tr>\n<tr>\n<td>browseable = yes<\/td>\n<td>Make the share <strong>visible<\/strong> when browsing.<\/td>\n<\/tr>\n<tr>\n<td>public = no<\/td>\n<td>Deny guest users.<\/td>\n<\/tr>\n<tr>\n<td>valid users = <strong>userName<\/strong><\/td>\n<td>Allow user &#8216;<strong>userName<\/strong>&#8216; to access the share.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Note: <strong>parameter syntax may vary depending on the Samba version<\/strong>. Always refer to the examples in the config file or check the manual:<\/p>\n<pre>man smb.conf<\/pre>\n<p>You must set a Samba password for the user and enable it, even if the user already has a local system password. Samba manages passwords separately.<\/p>\n<pre>adduser -s \/usr\/sbin\/nologin <strong>userName<\/strong>\r\nsudo smbpasswd -a <strong>userName<\/strong>\r\nsudo smbpasswd -e <strong>userName<\/strong><\/pre>\n<p>After editing the configuration file, restart the service and verify it is running:<\/p>\n<pre>sudo systemctl restart smbd\r\nsudo systemctl status smbd<\/pre>\n<p>OR<\/p>\n<pre>sudo service smbd restart\r\nsudo service smbd status<\/pre>\n<hr \/>\n<p><strong>CLIENT &#8211; SAMBA MOUNT<\/strong><\/p>\n<pre>sudo apt update\r\nsudo apt install cifs-utils -y<\/pre>\n<p>Test connectivity and authentication:<\/p>\n<pre>smbclient -U <strong>userName<\/strong> -L \\\\\\\\192.168.2.40\r\nsmbclient -U <strong>userName<\/strong> \\\\\\\\192.168.2.103\\\\Home_<strong>userName<\/strong><\/pre>\n<p>To mount a remote share on the local file system:<\/p>\n<pre>sudo mount -t cifs -o username=<strong>userName<\/strong> \/\/192.168.2.40\/Home_<strong>userName<\/strong> \/tmp\/hu<\/pre>\n<p>Customize this command to match your setup:<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td>-t cifs<\/td>\n<td>Specifies the filesystem type &#8216;cifs&#8217;, the protocol used by Samba.<\/td>\n<\/tr>\n<tr>\n<td>-o username=<strong>userName<\/strong><\/td>\n<td>The user to authenticate as.<\/td>\n<\/tr>\n<tr>\n<td>\/\/192.168.2.40\/<\/td>\n<td>The <strong>server address<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>Home_<strong>userName<\/strong><\/td>\n<td>The <strong>share name<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>\/tmp\/HU<\/td>\n<td>The local <strong>mount point<\/strong>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>The directory &#8216;<strong>\/tmp\/HU<\/strong>&#8216; must exist on the local file system. If it does not, create it:<\/p>\n<pre>sudo mkdir \/tmp\/HU\r\nsudo chmod 755 \/tmp\/HU<\/pre>\n<p>To <strong>mount automatically on boot<\/strong>, edit fstab:<\/p>\n<pre>sudo nano \/etc\/fstab<\/pre>\n<p>Add this line at the end of the file:<\/p>\n<pre>\/\/192.168.2.40\/Home_<strong>userName<\/strong> \/tmp\/HU cifs username=<strong>userName<\/strong>,password=pass,iocharset=utf8,file_mode=0777,dir_mode=0777<\/pre>\n<p>Customize this line to match your setup:<\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td>\/\/192.168.2.40\/<\/td>\n<td>IP <strong>address of the server<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>Home_<strong>userName<\/strong><\/td>\n<td>The <strong>share name<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>\/tmp\/HU<\/td>\n<td>The local <strong>mount point<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>cifs<\/td>\n<td>The filesystem type, the protocol used by Samba.<\/td>\n<\/tr>\n<tr>\n<td>username=<strong>userName<\/strong><\/td>\n<td>The user to authenticate as.<\/td>\n<\/tr>\n<tr>\n<td>password=pass<\/td>\n<td>The user&#8217;s password.<\/td>\n<\/tr>\n<tr>\n<td>iocharset=utf8,<br \/>\nsec=ntlm 0 0<\/td>\n<td>Keep these arguments as they are.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>This guide was written and tested on Ubuntu 18.04, 20.04, 22.04, and Raspbian Buster 10. The firewall command does not apply to Raspbian, but everything else works the same.<\/p>\n<p>To apply the new fstab entries without rebooting:<\/p>\n<pre>sudo mount -a<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The choice between NFS and Samba depends on who you are sharing with. Linux supports [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[],"class_list":["post-1888","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/1888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1888"}],"version-history":[{"count":9,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/1888\/revisions"}],"predecessor-version":[{"id":5743,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/1888\/revisions\/5743"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}