Motivation
A common problem with running a mixed-environment is sharing files between GNU/Linux and Windows computers. The best way to provide Windows computers access to your GNU/Linux file server is using Samba.
Prerequisites
Install samba server and client packages.
$ sudo apt-get install -y samba smbclient
Configure Samba Server
I configure two shares: one read-only (called data) and one read-write (called data-rw). Append the following to the end of /etc/samba/smb.conf:
[data] comment = Data Share (read-only) path = /mnt/md0/ available = yes valid users = myuser read only = yes browseable = yes public = yes writeable = no [data-rw] comment = Data Share path = /mnt/md0/ available = yes valid users = myuser read only = no browseable = yes public = yes writeable = yes
Create Samba User
Next, create a new samba user using the following command and it will prompt you to specify a password for the user and then again to confirm the password.
sudo smbpasswd -a myuser New SMB password: Retype new SMB password:
Verify the Configuration with testparm
The testparm utility checks the /etc/samba/smb.conf configuration file for internal correctness.
$ testparm Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) WARNING: The "syslog" option is deprecated Processing section "[homes]" Processing section "[printers]" Processing section "[print$]" Processing section "[data]" Processing section "[data-rw]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions
Test the Samba Server with smbclient and smbget
smbclient can be used to verify that all the shares are available on the server.
$ smbclient -L euclid Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.5.8-Debian] Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers data Disk Data Share (read-only) data-rw Disk Data Share IPC$ IPC IPC Service (Samba 4.5.8-Debian) myuser Disk Home Directories Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.5.8-Debian] Server Comment --------- ------- EUCLID Samba 4.5.8-Debian Workgroup Master --------- ------- WORKGROUP EUCLID
smbget is a wget-like utility for downloading files from a samba share
$ smbget smb://euclid/data/test.txt Using workgroup WORKGROUP, user myuser smb://euclid/data/test.txt Downloaded 830b in 1 seconds