Programming Blog

Jeremy Morgan

Mostly Coherent Ramblings of a Silicon Forest Software Developer

Set Up Easy File Sharing With Samba

In this tutorial, I’ll show you how easy it is to setup file sharing on your network using SAMBA. You can easily share files between Linux and Windows machines with a pretty minimal amount of setup.

How I’m Using SAMBA File Sharing

First, to give you little context, here’s how I am using Samba file sharing, with something I recently set up for course development.

How to setup file sharing with SAMBA

So I am developing courses and using a variety of Operating Systems for it. One course in progress is Windows related and I’m using Windows 2012 and 2016 Server machines. For another course I’m working on I’m using a variety of Linux machines. I’m spinning up multiple virtual machines with a fresh OS to demonstrate configuration and modification, then destroying them.


I have my workstation that I record with (my trusted Mac Mini), and I use Windows or OSX and run things like Camtasia, Final Cut Pro, Audio Tools, Photoshop, PowerPoint etc. I have a dual monitor setup and I use RDP to connect to a server, and use a full screen on one Monitor and have my recording tools on the other.


I’m using a server to run headless virtual machines that I described in this article. The sole purpose of this machine is to run these virtual machines and I want to dedicate as many resources as I can to it, because it runs several at one time.

I ran into an issue where i had a huge folder full of ISO images for each operating System. Combined with the disk space used by the virtual machines themselves, I decided I had to split it off.

How to set up file sharing with SAMBA

File Server

I found an old machine I wasn’t using and decided to drop a hard drive in it, and turn it into a file server. With an i3 and 4 gigs of RAM it’s plenty fast. I decided to go with a minimal install of CENTOS an install SAMBA on it.


So now I can ssh into my server and run commands to spin up the various virtual machines I need to run, and I have space to create many more. I have the installation ISOS residing on the file share server, which is mounted on the VM server. So to create a new virtual machine, I can just mount an ISO, run the installer and go, and create fresh new machines as needed.

If I see some cool distribution of Linux I just have to try, I can download the installer ISO with my workstation to the shared folder, then build a vm to install from the ISO.

It’s not redundant or secured tightly, but it’s all stuff I can download from MSDN or the internet to replace anyway. This is one of my uses for a Samba server.

Now, let’s get to the tutorial.

How to Set Up File Sharing with Samba

Here’s how you can set up a file server with Samba. For this I am using CentOS Linux, but it’s very similar for most Linux distributions.

I’ve created an account named jeremy that will be used for serving files. You never want to run this kind of stuff under the root account. So I’ll log in with the Jeremy account, and use sudo to run any commands that require administrative rights.

In a fresh install of CentOS you will need to add this account to the sudoers file.

Install Samba

First we’ll need to install Samba.

sudo yum install samba samba-client samba-common

Now we want to create a new folder for our file share. This is where the files will be stored that we’re sharing.

Then we’ll change the permissions on this share

mkdir -p /srv/samba/secure
sudo chmod -R 0770 /srv/samba/secure
sudo chown -R root:smbgrp /srv/samba/secure
sudo chcon -t samba_share_t /srv/samba/secure

Add Samba User Group

Next we’ll add the Samba user group. Then you’ll want to add a user to that group. You want to make sure this is an existing user on your machine, for this I used the Jeremy account I created the folder with.

groupadd smbgrp
usermod jeremy -aG smbgrp

Next, you want to add the Samba user, which should be the same as the account you’re using (in my case, jeremy).

sudo smbpasswd -a jeremy

it will ask you for your password. This will be the password for the Samba share, and you can put in your existing user password here.

Edit Smb.conf

Next we want to edit our smb.conf. Make a quick backup of the file

sudo cp /etc/samba/smb.conf /etc/samba/smb.bak

Now, let’s edit the file

sudo vi /etc/samba/smb.conf

First I’m going to change the name of my workgroup to WORKGROUP in all caps. this is the name of my windows workgroup.

Here we have homes which are home folders for each user if you’d like to use those

Let’s create a share that points to where we just created a folder.

    comment= my file share
    path = /srv/samba/secure
    valid users = jeremy
    public = no
    writable = yes
    browsable = yes
    printable = no
    create mask = 0765

Start Service

You want to test your configuration changes to make sure everything is correct.


Then, it’s time to restart the smb and nmb services:

sudo systemctl restart smb.service
sudo systemctl restart nmb.service


We’ll have to add an entry to the firewall to allow the samba service to be accessible from outside the network:

firewall-cmd --permanent --zone=public --add-service=samba
firewall-cmd --reload


Now, we can browse to the server from a Windows machine:

How to file sharing with Samba

You can even mount it as a mapped drive, or mount it on a linux machine. Samba setup is super easy, and great to use.


Setting up Samba is easy, and something to consider if you want easy file sharing between Linux and Windows machines, or even Linux and Linux machines. I gave some context of how to set it up, but there are tons of use cases for Samba. You can also tie it in to different authentication/authorization schemes if you’d like an use it with Active Directory as well. Check out for more information.

I also created a video tutorial for this:

Subscribe to my channel on YouTube for more tutorials!

Windows to Go With the Spyrus USB Drive

What we need is a good bootable live USB stick for Windows. I’ve said this many times over the years, and hacked together things to make that very thing happen, but nothing that worked really well. So when the folks at Spyrus sent me a Windows to Go USB to check out, I was pretty excited.

Which Distribution of Linux Should I Use?

I’m often asked this question: “hey, you’re a Linux guy right? What Linux should I use? I have this friend who recommends _____ and I want to know what you think?” I usually reply with the same question: what do you want to do? So I decided to make a blog post about it that I can send people instead.

My Latest Virtualization Setup

Like many geeks of the time I spent the 90s and 2000s with at least 2 or 3 old computers in a closet, connected by a switch running various operating systems with various services running on them. Giant, loud, clunky machines whirring away.

Load Testing Your IIS Web Server

All the theory, calculations, and estimations in the world aren’t going to tell you how your website will truly perform under a load. If you’re deploying a new server, or doing any kind of performance enhancements you don’t want to test your results in production. It’s always a good idea to see how your system behaves before your visitors do. To do that, you can use a load testing tool, and here are a few I use quite frequently.

Update: I’ve featured these tools is my latest IIS course on Pluralsight, IIS Administration in Depth, check it out!

How to Install Microsoft SQL Server on Ubuntu Linux in 5 Minutes

I must admit I was surprised when I learned that Microsoft SQL Server would be availble in Linux. They’ve been pushing the open source initiative hard, but I didn’t expect something this big. Oh yeah, Visual Studio is now available for Mac as well. I just saw a pig flying by.

While MS-SQL is not open source they have made it available to run on open source platforms such as Linux and OSX, which I can imagine took a ton of work. So I decided to take advantage of this new option and try it out. It works great! It took 5 minutes to install. Here’s how you can do it too. Note that you will need a server with 3.5 gigs of RAM for this.

Intro to Application Pools in IIS

Application Pools in IIS can be somewhat of a mystery. Since they’re created for you automatically many times Administrators don’t give them a second thought. But understanding application pools is crucial to having a good running IIS server.

I cover this and other IIS Administration topics in my IIS Administration Fundamentals course at Pluralsight. Check it out!

Hands on IoT With the Raspberry Pi

Great news! I finally got my IoT course done! It took a long time to develop, and a lot of learning but totally worth it. This is not really a post advertising it but just a quick talk about the process.

Review: Netgear WAC730 Wireless Access Point

In this article I’ll be reviewing the Netgear Prosafe WAC730 Wireless Access Point. This is a WAP geared towards small to medium sized businesses, and is designed to compliment your existing network. I received this product for free in exchange for my honest opinion as part of the Netgear Ambassador Program. They sent me this unit to try out, and after extensive evaluation here’s what I think.