File Server Configuration in Debian Using Samba

Samba is a suite of Unix applications that speak the SMB (Server Message Block) protocol. Many operating systems,including Windows and OS/2, use SMB to perform client-server networking. By supporting this protocol, Samba allows Unix servers to get in on the action, communicating with the same networking protocol as Microsoft Windows products.

Install Samba in Debian

#apt-get install samba samba-common samba-client

This will start samba installation and prompted for the following questions

First you need to enter the Workgroup/Domain Name in this example i am using ruchi select ok and press enter

You want to use password encryption select yes and press enter

If you want to modify smb.conf to use WINS settings from DHCP.If you want select yes in this example i am selecting no
and press enter

Next one is how do you want to run samba daemon or inetd in this example i have selected as daemon and press enter

You want to craete samba password database file select yes and press enter

This will complete the samba installation part.

Preparing directories and users

Create directories for Samba to use with Windows

#mkdir windowsshare

Now we need to create users to access this directiory

#useradd david

Now create a password for this user using the following command

#smbpasswd -a david

Samba configuration

By default samba configuration file located at /etc/samba/smb.conf

In this file main section is Global where you can define all parameters and the example as follows


workgroup = ruchi
netbios name = fileserver
server string = %h server (Samba %v)
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0

Now you need to configure the share directory(ex:-samba) for users below is the example.


valid users = david
admin users = debian

Testing Your Samba Permissions

If you want to check your configuration file is correctly configured or not you need to run the following command


Output looks as follows

Load smb config files from /etc/samba/smb.conf
Processing section “[homes]”
Processing section “[printers]”
Processing section “[print$]”
Loaded services file OK.
Press enter to see a dump of your service definitions

Now you need to restart the samba server using the following command

#/etc/init.d/samba restart

If you want to know more configuration options available for samba check samba config man page

Testing your samba configuration

You want to test your samba configuration for user david run the following command

#smbclient -L //serverip -U david

Mounting Samba Directories in Linux

Linux can view your Samba shared directories as it does any other medium (hard disk, NFS shares,CD-ROM, and so on).
Use mount to mount a Samba shared file system so that it is permanently connected to your Linux file system.Here’s an example of the mount command in which a home directory (/home/david) from a computer named toys on a local directory (/mnt/toys) is mounted. The command is typed, as root user, from a Terminal window:

# mkdir /mnt/toys

# mount -t smbfs -o username=david,password=test //toys/david /mnt/toys

The file system type for a Samba share is smbfs (-t smbfs). The username (david) and password (test) are passed as options (-o). The remote share of the home directory on toys is //toys/david. The local mount point is /mnt/toys. At
this point, you can access the contents of /home/david on toys as you would any file or directory locally. You will have the same permission to access and change the contents of that directory (and its subdirectories) as you would if you were the user chris using those contents directly from toys.

To mount the Samba shared directory permanently, add an entry to your /etc/fstab file. For the example just described,
you’d add the following line (as root user):

//toys/david /mnt/toys smbfs username=david,password=test

Troubleshooting Samba Server

If your Samba server isn’t working properly you need to check the following procedure

1) First you need to check your basic networking is working or not

2) Check Samba Service is Running or not using the following command

$ smbclient -L localhost
Password: **********

3) Make sure that your firewall ports are open.You need to open access to ports 137, 138, and 139 in your firewall so

that the Samba server can accept connections for services.

4) Make sure user passwords are working.Try accessing a shared Samba directory as a particular user using the

following command.

# smbclient //localhost/tmp -U david

In this example, smbclient connects to the directory share named tmp as the Samba user named david. If the password is
accepted, you should see information about the server and a smb:\> prompt.

Configuring the Windows workstations

logon to the Windows workstation as any user with administrative priviliges

[Windows 2000] Start -> Settings -> Control Panel -> System -> Network Identification -> Properties -> Member of ->
Domain -> type the domain name as specified in the ‘workgroup’ section of smb.conf -> ok

[Windows XP] Start -> Control Panel -> System -> Computer Name -> change -> Member of -> Domain -> type the domain name as specified in the ‘workgroup’ section of smb.conf file -> ok

enter the root username and password for the Samba file server

if you simply wish to transfer existing users from a workstation, then if a user exists on the Samba file server and on the workstation, at this point you could log them into the Samba file server and their profile from the workstation would be copied to the Samba file server when they log out

Sponsored Link

One thought on “File Server Configuration in Debian Using Samba

  1. Absolutely killer. I have searched and tinkered all day trying to get a Samba server:

    1. Running on my Linux box
    2. Recognized from my Windows desktop

    I store all my development files on Debian as it’s LAMP setup…and hitherto I would copy the files back and forth using FTP or WinSCP, etc…

    I just finally got the Windows system to recognize the user by invoking this command:

    C:\> net use m: \\servername\service

    Now in my Windows I have an additional drive “M” which is accessible through Explorer…perfect. 🙂


Leave a comment

Your email address will not be published. Required fields are marked *