{"id":16571,"date":"2024-11-02T08:19:52","date_gmt":"2024-11-02T08:19:52","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=16571"},"modified":"2024-11-02T08:27:55","modified_gmt":"2024-11-02T08:27:55","password":"","slug":"how-to-set-up-samba-for-file-sharing-on-linux-servers","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/","title":{"rendered":"How to Set Up Samba for File Sharing on Linux Servers"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">What is Samba?<\/h3>\n\n\n\n<p>Samba is an open-source implementation of the SMB\/CIFS protocol that allows Linux and Unix systems to share files with Windows clients, as well as with other Linux machines. With Samba, you can set up a file server that can be accessed by computers on a local network.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A <strong>Linux server<\/strong> (such as Ubuntu or CentOS) with root or sudo access.<\/li>\n\n\n\n<li>Basic understanding of network configuration.<\/li>\n\n\n\n<li>Installed Samba package on the Linux server.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Install Samba<\/h3>\n\n\n\n<p><strong>Update the package index<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update # On Debian\/Ubuntu\n\nsudo yum update # On CentOS\/RHEL<\/code><\/pre>\n\n\n\n<p><strong>Install Samba<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install samba    # On Debian\/Ubuntu\n\nsudo yum install samba samba-client  # On CentOS\/RHEL<\/code><\/pre>\n\n\n\n<p><strong>Check the Samba version<\/strong> (optional):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>smbstatus --version<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Configure Samba Share<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a directory<\/strong> that will be shared over the network. Here, we\u2019ll use <code>\/srv\/samba\/share<\/code>.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/srv\/samba\/share<\/code><\/pre>\n\n\n\n<p>  2. <strong>Set permissions<\/strong> for the directory to allow Samba access. You can restrict permissions later based on your needs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R nobody:nogroup \/srv\/samba\/share # On Debian\/Ubuntu<br>sudo chown -R nobody:nobody \/srv\/samba\/share # On CentOS\/RHEL<br>sudo chmod -R 0775 \/srv\/samba\/share<\/code><\/pre>\n\n\n\n<p>3. <strong>Open the Samba configuration file<\/strong> to define the share:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/samba\/smb.conf<\/code><\/pre>\n\n\n\n<p>4. <strong>Add a new share<\/strong> at the end of the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ShareName]\npath = \/srv\/samba\/share\nbrowsable = yes\nwritable = yes\nguest ok = yes\nread only = no<\/code><\/pre>\n\n\n\n<p><strong>Explanation of options<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>[ShareName]<\/code>: Name of the share that clients will see.<\/li>\n\n\n\n<li><code>path<\/code>: Path to the shared directory on the server.<\/li>\n\n\n\n<li><code>browsable = yes<\/code>: Makes the share visible when browsing network shares.<\/li>\n\n\n\n<li><code>writable = yes<\/code>: Allows write access to the share.<\/li>\n\n\n\n<li><code>guest ok = yes<\/code>: Allows access without a password (for public shares).<\/li>\n\n\n\n<li><code>read only = no<\/code>: Enables read and write access.<\/li>\n<\/ul>\n\n\n\n<p>5. <strong>Save and close<\/strong> the file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Set Up Samba User<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Add a Samba user<\/strong> (if you want password-protected access):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo smbpasswd -a username<\/code><\/pre>\n\n\n\n<p>2. <strong>Set the password<\/strong> for this Samba user when prompted.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Note<\/strong>: Samba users must have an account on the Linux server.<\/li>\n<\/ul>\n\n\n\n<p>3. <strong>Restart Samba services<\/strong> to apply the changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart smbd\n\nsudo systemctl restart nmbd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Configure Firewall (if applicable)<\/h3>\n\n\n\n<p>If you have a firewall enabled, allow Samba traffic.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Open Samba ports<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow samba              # On Debian\/Ubuntu with UFW\nsudo firewall-cmd --permanent --add-service=samba  # On CentOS\/RHEL with Firewalld\nsudo firewall-cmd --reload<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Access the Samba Share from Other Computers<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. From a Windows Client<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open File Explorer.<\/li>\n\n\n\n<li>In the address bar, type <code>\\\\server_ip_address\\ShareName<\/code> (replace <code>server_ip_address<\/code> with the IP of your Samba server and <code>ShareName<\/code> with the name of your Samba share).<\/li>\n\n\n\n<li>If prompted, enter the Samba username and password.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. From a Linux Client<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the following command to mount the share:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount -t cifs -o username=username,password=password \/\/server_ip_address\/ShareName \/mnt<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Replace <code>username<\/code>, <code>password<\/code>, <code>server_ip_address<\/code>, and <code>ShareName<\/code> with your values.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Enable the Samba Share at Boot (Optional)<\/h3>\n\n\n\n<p>To automatically mount the Samba share at boot on a Linux client, add it to the <code>\/etc\/fstab<\/code> file.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Open the fstab file<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/fstab<\/code><\/pre>\n\n\n\n<p>  2. <strong>Add the following entry<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/server_ip_address\/ShareName \/mount\/point cifs username=username,password=password 0 0<\/code><\/pre>\n\n\n\n<p>3. <strong>Save and close the file<\/strong>.<\/p>\n\n\n\n<p>4. <strong>Test the fstab entry<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mount -a<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Manage and Troubleshoot Samba<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>To check the status of the Samba service<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status smbd<\/code><\/pre>\n\n\n\n<p>   2. To restart Samba if you make configuration changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart smbd<br>sudo systemctl restart nmbd<\/code><\/pre>\n\n\n\n<p>3. <strong>To view Samba logs for troubleshooting<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tail -f \/var\/log\/samba\/log.smbd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>You\u2019ve successfully set up Samba on your Linux server for file sharing across your network. This setup allows Windows and Linux clients to access shared directories on the server. With Samba, you can create a secure a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Samba? Samba is an open-source implementation of the SMB\/CIFS protocol that allows Linux and Unix systems to share files with Windows clients, as well as with other Linux machines. With Samba, you can set up a file server that can be accessed by computers on a local network. Prerequisites Step 1: Install Samba [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-16571","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-07","word_count":622,"total_views":"0","reactions":{"happy":"23","normal":"0","sad":"0"},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Set Up Samba for File Sharing on Linux Servers -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Up Samba for File Sharing on Linux Servers -\" \/>\n<meta property=\"og:description\" content=\"What is Samba? Samba is an open-source implementation of the SMB\/CIFS protocol that allows Linux and Unix systems to share files with Windows clients, as well as with other Linux machines. With Samba, you can set up a file server that can be accessed by computers on a local network. Prerequisites Step 1: Install Samba [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-02T08:27:55+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-samba-for-file-sharing-on-linux-servers\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-samba-for-file-sharing-on-linux-servers\\\/\",\"name\":\"How to Set Up Samba for File Sharing on Linux Servers -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2024-11-02T08:19:52+00:00\",\"dateModified\":\"2024-11-02T08:27:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-samba-for-file-sharing-on-linux-servers\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-samba-for-file-sharing-on-linux-servers\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-set-up-samba-for-file-sharing-on-linux-servers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set Up Samba for File Sharing on Linux Servers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set Up Samba for File Sharing on Linux Servers -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Up Samba for File Sharing on Linux Servers -","og_description":"What is Samba? Samba is an open-source implementation of the SMB\/CIFS protocol that allows Linux and Unix systems to share files with Windows clients, as well as with other Linux machines. With Samba, you can set up a file server that can be accessed by computers on a local network. Prerequisites Step 1: Install Samba [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/","article_modified_time":"2024-11-02T08:27:55+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/","name":"How to Set Up Samba for File Sharing on Linux Servers -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2024-11-02T08:19:52+00:00","dateModified":"2024-11-02T08:27:55+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-set-up-samba-for-file-sharing-on-linux-servers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Set Up Samba for File Sharing on Linux Servers"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=16571"}],"version-history":[{"count":1,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16571\/revisions"}],"predecessor-version":[{"id":16572,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16571\/revisions\/16572"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=16571"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=16571"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=16571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}