Samba is the open-source implementation of the SMB/CIFS protocol used by Windows for file and printer sharing. By running a Samba server (i.e. smbd), your Linux server can present shared folders on the network that Windows (and macOS/Linux) can browse and access like a normal Windows file share.
The Samba service is already installed on the jPC, but the Samba server is disabled by default. You'll enable/start the services, create a share directory, set permissions, configure Samba, add a Samba user, and connect from a client.
Enable the services to start at boot, and start them now:
sudo systemctl enable --now smbd nmbd wsdd2
Samba uses its own password database. Create a Samba password for the admin user using smbpasswd:
# Set password sudo smbpasswd -a "admin" # Enable user sudo smbpasswd -e "admin"
Restart Samba to apply changes:
sudo systemctl restart smbd
At this point, you should be able to see your user(s) home directories by navigating to \\JPC_IP_ADDRESS\ on a Windows PC. Log in with the Samba username/password you set with smbpasswd.
NOTE: Sometimes it can take approximately 30 seconds to access the share for the first time.
# Create a directory to share sudo mkdir -p /srv/samba/my_shared_folder # Set group ownership and permissions: # - 2770 = rwx for owner+group, none for others; setgid bit keeps group on new files sudo chgrp sambashare /srv/samba/my_shared_folder sudo chmod 2770 /srv/samba/my_shared_folder
Edit the Samba configuration file:
sudo nano /etc/samba/smb.conf
Add this share definition at the end of the file:
[my_shared_folder] path = /srv/samba/my_shared_folder browsable = yes read only = no valid users = @sambashare force group = sambashare create mask = 0660 directory mask = 2770
Restart Samba to apply changes:
sudo systemctl restart smbd
To access the previously created my_shared_folder folder, enter the following in Windows' file explorer.
\\JPC_IP_ADDRESS\my_shared_folder
Log in with the Samba username/password you set with smbpasswd.
NOTE: Sometimes it can take approximately 30 seconds to access the share for the first time.
Most “Access denied” problems are Linux filesystem permission issues. Verify:
sambashare group, by running groups./srv/samba/shared is group-owned by sambashare and has mode 2770If you previously connected to the Linux Samba share from Windows, but it won't connect again, tell Windows to forget the previous connection with the following command
net use \\JPC_IP_ADDRESS\Shared /delete