#apt-get install libcups2 samba samba-common cups
Move the current smb.conf file to smb.conf.bak:
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
And then create a new file smb.conf file:
nano /etc/samba/smb.conf
With the following content:
[global] workgroup = WORKGROUP server string = Samba Server %v netbios name = debian security = user map to guest = bad user dns proxy = no #this setting for disable share printer error message #like: Unable to connect to CUPS server localhost:631 - Bad file descriptor load printers = no printing = bsd printcap name = /dev/null disable spoolss = yes
net config workstation
#systemctl restart smbd.service
Adding Samba Shares
Now I will add a share that is accessible by all users.
Create the directory for sharing the files and change the group to the users group:
#mkdir -p /home/shares/allusers
#chown -R root:users /home/shares/allusers/
#chmod -R ug+rwx,o+rx-w /home/shares/allusers/
#chown -R root:users /home/shares/allusers/
#chmod -R ug+rwx,o+rx-w /home/shares/allusers/
#mkdir -p /home/shares/anonymous
#chown -R root:users /home/shares/anonymous/
#chmod -R ug+rwx,o+rx-w /home/shares/anonymous/
#chown -R root:users /home/shares/anonymous/
#chmod -R ug+rwx,o+rx-w /home/shares/anonymous/
At the end of the file /etc/samba/smb.conf add the following lines:
#nano /etc/samba/smb.conf
Group share
This is a share that is accessible and writable for all members of our "users" group. Add the following config at the end of the smb.conf file.
[allusers] comment = All Users path = /home/shares/allusers valid users = @users force group = users create mask = 0660 directory mask = 0771 writable = yes
Home directories
If you want all users to be able to read and write to their home directories via Samba, add the following lines to /etc/samba/smb.conf (make sure you comment out or remove the existing [homes] section):
[homes] comment = Home Directories browseable = no valid users = %S writable = yes create mask = 0700 directory mask = 0700
Anonymous share
You like to have a share were all users in your network can write to? Be careful, this share is open to anyone in the network, so use this only in local networks. Add an anonymous share like this:
[anonymous] path = /home/shares/anonymous force group = users create mask = 0660 directory mask = 0771 browsable =yes writable = yes guest ok = yes
Now we restart Samba:
systemctl restart smbd.service
Adding and Managing Users
In this example, I will add a user named tom. You can add as many users as you need, in the same way, just replace the username tom with the desired username in the commands.
useradd tom -m -G users
Set a password for tom in the Linux system user database. If the user tom should not be able to log into the Linux system, skip this step.
passwd tom
-> Enter the password for the new user.
Now add the user to the Samba user database:
smbpasswd -a tom
-> Enter the password for the new user.
Now you should be able to log in from your Windows workstation with the file explorer (address is \\192.168.1.100 or \\192.168.1.100\tom fortom's home directory) using the username tom and the chosen password and store files on the Linux server either in tom's home directory or in the public shared directory.
=========================