Ubuntu Samba Server

If you need to create a shared drive on an Ubuntu Server that Windows and Linux users can access, SAMBA is the perfect solution. This article will guide you through installing SAMBA, configuring a shared folder, and setting up user permissions.

Step 1: Update Your System

Before installing any software, update your system to ensure you have the latest packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install SAMBA

SAMBA is available in Ubuntu’s default repository. Install it using:

sudo apt install samba -y

Once installed, check the version to confirm the installation:

smbd --version

Step 3: Create a Shared Directory

Choose a location for your shared folder. For this example, we will create a folder called shared inside /srv/:

sudo mkdir -p /srv/shared

Change the folder’s permissions so all users can read, write, and execute files:

sudo chmod 777 /srv/shared

the /srv location is on the primary drive. If a secondary drive is needed it will need to be mounted. ****Article coming soon!!


Step 4: Configure SAMBA

Edit the SAMBA configuration file:

sudo nano /etc/samba/smb.conf

At the bottom of the file, add the following configuration:

[SharedDrive]
   comment = Shared Drive for Network Users
   path = /srv/shared
   browseable = yes
   writable = yes
   guest ok = yes
   create mask = 0777
   directory mask = 0777

Save the file (CTRL+o, then Y, then Enter).
Exit nano with ctrl + x


Step 5: Restart SAMBA Service

For the changes to take effect, restart the SAMBA service:

sudo systemctl restart smbd
sudo systemctl enable smbd

To check if SAMBA is running, use:

sudo systemctl status smbd

If systemctl commands do not work you can try using:

service samba restart

Step 6: Allow Firewall Access

If you have UFW (Uncomplicated Firewall) enabled, allow SAMBA traffic:

sudo ufw allow samba
sudo ufw reload

Step 7: Access the Shared Folder from Windows

  1. Open File Explorer on a Windows machine.
  2. In the address bar, type: \\<Ubuntu_Server_IP>\SharedDrive (Replace <Ubuntu_Server_IP> with your actual server’s IP address.)
  3. Press Enter, and you should see the shared folder.

Step 8: Secure the Shared Folder (Optional)

By default, the setup allows guest access. If you want to restrict it to specific users:

  1. Create a SAMBA user: sudo smbpasswd -a username
  2. Modify the configuration to restrict access: Edit /etc/samba/smb.conf and change: guest ok = no valid users = username
  3. Restart SAMBA: sudo systemctl restart smbd

Now, only the specified user can access the shared folder.


Conclusion

You have successfully installed SAMBA and created a shared drive on your Ubuntu Server. Whether you’re setting up a simple guest-accessible share or a secure user-restricted one, SAMBA makes file sharing between Linux and Windows seamless.

If you have any issues, verify the configuration using:

testparm

Similar Posts