systems:media_server:setup_smb_samba_shares
Table of Contents
Systems - Media Server - Setup SMB (Samba) Shares
To share directories and files between this Linux server and other devices.
Install Samba
sudo apt install samba
Configure the Samba Share
Edit the Samba configuration file, /etc/samba/smb.conf, and add the following section at the end of the file to define the media share:
- /etc/samba/smb.conf
[Media] path = /mnt/media browseable = yes read only = no guest ok = no valid users = peter
NOTE: The config is:
- [Media] - This is the name of the share.
- When accessing Samba from a client device, this will appear as the share name in the network.
- path = /mnt/media - This specifies the directory on the server that will be shared.
- In this example, the directory /mnt/media is being shared.
- browseable = yes - Setting this to yes allows the share to be visible when browsing the network.
- If set to no, users would need to know the share name to access it manually.
- read only = no - This allows users to write (add, modify, or delete) files in the share.
- If set to yes, the share would be read-only, preventing users from making changes.
- guest ok = no - This prevents unauthenticated users (guests) from accessing the share.
- Only users with valid credentials will be allowed access.
- valid users = peter - This restricts access to the share to the specified username.
- This is the username set up on the Ubuntu server.
- This ensures only authorized users can access the share.
Test the Samba Configuration
testparm
Create a Samba User
Add the user on the server user as a Samba user:
sudo smbpasswd -a peter
NOTE: Follow the prompts to create a password for the Samba user.
Samba does not use the system account password, which is why it needs its own password.
- -a - This flag adds the existing linux user to the Samba user database.
- This command searches for the username in the Unix user database and adds it to the Samba user database.
- If not found, then the “smbpasswd” command will create as well as add the user to the Samba group.
Restart Samba Service
Restart the Samba service to apply the changes:
sudo systemctl restart smbd
NOTE: Remember to update any firewall rules to allow Samba traffic
Check the status of the service to confirm that Samba is working fine
sudo systemctl status smbd
systems/media_server/setup_smb_samba_shares.txt · Last modified: 2025/05/30 17:06 by peter