
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
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
- Open File Explorer on a Windows machine.
- In the address bar, type:
\\<Ubuntu_Server_IP>\SharedDrive(Replace<Ubuntu_Server_IP>with your actual server’s IP address.) - Press Enter, and you should see the shared folder.
By default, the setup allows guest access. If you want to restrict it to specific users:
- Create a SAMBA user:
sudo smbpasswd -a username - Modify the configuration to restrict access: Edit
/etc/samba/smb.confand change:guest ok = no valid users = username - 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
