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
Now we need to create users to access this directiory
Now create a password for this user using the following command
#smbpasswd -a david
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.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
Now you need to restart the samba server using the following command
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
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
# 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