Install Samba
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install samba samba-common-bin
Edit configuration and add share
sudo nano /etc/samba/smb.conf
[y2v]
path = /opt/downloads
writable = yes
create mask = 0777
directory mask = 0777
public = yes
browsable = yes
guest ok = yes
valid users = user
write list = user
# More information about create mask and directory mask: https://chmod-calculator.com/
Add user which will use SMB Share
sudo smbpasswd -a pi
Restart service
sudo systemctl restart smbd
Change ownership
chgrp -R samba /opt/downloads
chown -R user:user *
chmod -R 2775 /opt/downloads
Explanation of the chmod -R 2775 /opt/downloads command
Let me break down the permission string “drwxrwsr-x“:
d
: This indicates that it is a directory.rwx
: The owner (user) has read, write, and execute permissions.rws
: The group has read, write, and execute permissions, with the setgid bit set.r-x
: Others have read and execute permissions.
The 2
at the beginning of the octal mode corresponds to the setgid bit, which ensures that new files and subdirectories created within this directory inherit the group ownership of the parent directory.
The -R
option makes the chmod
command apply the changes recursively to all files and subdirectories within the specified directory.