To share directories and files between this Linux server and other devices.
Install Samba
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]
comment = Contents are read/write by all.
path = /mnt/media
browseable = yes
read only = no
guest ok = yes
force user = root
force group = root
force directory mode = 0777
force create mode = 0777
NOTE: The config is:
[Media] - This is the name of the share.
path = /mnt/media - This specifies the directory on the server that will be shared.
browseable = yes - Setting this to yes allows the share to be visible when browsing the network.
read only = no - This allows users to write (add, modify, or delete) files in the share.
guest ok = yes - Allow guest users to access the share.
force user = root - Allows all file operations to be performed as the root user, regardless of the username used to connect.
force group = root - Force group ownership of the share.
force directory mode = 0777 - Force all created directories to have read, write and execute permissions set for everyone.
force create mode = 0777 - Force all newly created files to have read, write and execute permissions set for everyone.
Test the Samba Configuration
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.
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