When you have Windows and Linux machines coexisting on the same network, file sharing becomes an issue because each Operating System has its own file system. This is where Samba comes in. Samba runs on Linux and happily shares files and printers between Linux, Windows and Mac.
Although Linux will recognize the Windows NTFS file system, the two Operating Systems don't always play nice with one another. If you have a network with both Linux and Windows computers sharing files, it is best to set up a Samba Server. However, configuring Samba can be a bit of a chore. Previously, Pranav Thadeshwar has shown you how to mount a Windows Share from a Linux Machine and Jack Wallen has shown you how to use Samba to set up a home file server. Now we're going to expand on those two articles and add more users and set up a print server.
First, grab the latest copy of Samba. You can do this through any package manager. For Ubuntu and other Debian based systems, the command is:
sudo apt-get install samba
Before you make any changes, stop the service:
sudo /etc/init.d/samba stop
Backup the default configuration file:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bkup
You can actually just make changes to the smb.conf file, but it is still a good idea to make a backup file anyway. In that case, the command would be:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bkup
Here is a sample smb.conf file that you can copy and paste into your editor:
[global]
workgroup = WORKGROUP
netbios name = MYNAME
security = user
null passwords = true
username map = /etc/samba/smbusers
hostname lookups = yes
hosts equiv = /etc/hosts
hosts allow = 192.168.0.0/255.255.255.0 localhost
hosts deny = All
interfaces = lo eth0
bind interfaces only = yes
guest ok = yes
printing = CUPS
printcap name = CUPS
[printers]
comment = All Printers
browseable = no
printable = yes
writable = no
public = yes
guest ok = yes
path = /var/spool/samba
printer admin = root
[PhotoSmart]
comment = HP PSC 1500
printable = yes
path = /var/spool/samba
public = yes
guest ok = yes
printer admin = root
[public]
path = /home/public
browseable = yes
read only = no
guest ok = yes
public = yes
create mode = 766
[home_directories]
path = /home/%U
read only = no
valid users = %U root