If you are wanting to connect your Windows machine(s) to your Linux machine(s) over your network, then Samba is what you need. Essentially, Samba allows your Linux machine to communicate with your Windows network to share files, resources, and printers. This document will cover the steps of installing and configuring Samba on Slackware 11.0.0. However, older versions of Slackware should still work the same.
Downloading and Installing Samba
If you did not choose to install samba during your initial installation of Slackware, you will need to download the package from the Slackware website. Go here for the official Slackware 11 samba package. You will be presented with a list of mirrors. Select a mirror closest to you.
To check and see if you already have samba installed, run:
adam@foo:~$ less /var/log/packages/samba*
If you get a “No such file or directory” return, then you need to install the package linked above. Otherwise, skip this section completely.
Here are the steps I ran:
adam@foo:~/packages$ wget http://slackware.cs.utah.edu/pub/slackware/
adam@foo:~/packages$ installpkg samba-3.0.23c-i486-1.tgz
Now we have Samba installed.
By default, samba installs a directory in /etc/. So lets su to root and navigate to it.
adam@foo:~$ su -
root@foo:~# cd /etc/samba/
Inside this directory, we have a smb.conf-sample file. It is important to take a look at this file and read the comments provided. This will help you have a better understanding of the options you have available to you. I am going to give you a standard configuration file that I start with, and I encourage you to build on it.
To use my configuration file as a base, run:
root@foo:/etc/samba$ touch /etc/samba/smb.conf
root@foo:/etc/samba$ vim /etc/samba/smb.conf
Then you’ll want to copy/paste the following:
workgroup = Darkstar
server string = foo
security = user
load printers = yes
log file = /var/log/samba.%m
max log size = 50
socket options = TCP_NODELAY
comment = Home Directory
path = /home/adam/
valid users = adam
writable = yes
Line by line description:
The [global] section contains global configuration parameters not specific to any directory shared.
workgroup = Darkstar is defining what the NT-Domain-Name or Workgroup-Name is. You will want to change Darkstar to whatever you have set in Windows as your workgroup.
server string = foo defines the description of the Linux machine. This is equivalent to the Windows description field. Change this to something that describes your Linux computer.
security = user is setting the security mode to user level security. We will discuss how to create users for samba later. See the samba documentation for other security modes available.
load printers = yes tells samba to automatically load the printer list.
log file = /var/log/samba.%m defines where you want samba to log to. The %m tells samba to keep a separate log file for each machine on the network.
max log size = 50 defines the maximum size of the log files, in (Kb).
socket options = TCP_NODELAY this setting supposedly helps samba perform better. See the official samba documentation for more details.
The [home] section is essentially a share definition. Everything residing under [home] is specific to the share, and no other shares.
comment = Home Directory defines what the shares description will be.
path = /home/adam/ is the direct path for the share. Change this to reflect the directory you want to share.
valid users = adam is telling samba to only allow the user adam access to this share. Change this to a user that exists on your machine. See /etc/passwd for a list of existing users.
writable = yes tells samba to allow the valid users to write to this shared directory.
Now that you have a simple smb.conf file to work from, save it.
Setting up Samba users with smbpasswd:
Since we chose to use the security mode “users” in our samba configuration file, we need to set up the users. To do so, run:
adam@foo:~$ smbpasswd -a adam
New SMB Password:
Retype new SMB Password:
Remember, you can only add samba users via smbpasswd if they already exists as real users on the machine. To see the real users, take a look at your /etc/passwd file. Also note, for all users you add in your smb.conf to the valid users line, you must create a password for them using smbpasswd.
Execute the rc.samba file like so:
adam@foo:~$ chmod 755 /etc/rc.d/rc.samba
adam@foo:~$ /etc/rc.d/rc.samba start
Starting Samba: /usr/sbin/smbd -D
Now you should be all set up to view your Linux share from Windows. Go to your Windows machine, select Start > Run … and type \\192.168.1.101 or whatever your Linux machines local IP is. After successfully connecting, you should first see a prompt for a user name and password. Enter in the user name added via smbpasswd and you should be granted access to your share.