You are on page 1of 6

SAMBA SERVICE:

Samba is a file server which provides the compatibility between


windows and unix.
Samba is a third party tool.So install the package “samba.pkg” to configure the samba
server or samba client on unix machines.If it is a windows machine there is no need to
install any package because it is the default service for windows.
To install samba package:
#pkgadd –d <sourcelocation> samba.pkg
After installing the samba package,
#vi /opt/samba/lib/smb.conf
………………………………
………………………………
[global]
{add the fallowing entries here}
encrypt passwords = yes
smbpasswd file = /etc/smbpasswd
:wq!
#useradd -g 10 –d /usr/student -m student
#useradd -g 10 -d /usr/alice -m alice
#useradd -g 10 -d /usr/nice -m nice
#passwd student
Enter password:
Re-enter:

#passwd alice
Enter password:
Re-enter:

#passwd nice
Enter password:
Re-enter:

To convert these users as samba users,Execute the following script.


# cat /etc/passwd|/opt/samba/bin/mksmbpasswd.sh>/etc/smbpasswd
{This script reads the /etc/passwd file and converts the users as samba users by updating
their information in /etc/smbpasswd file}
Now to assign the samba passwords for these users(samba passwords may be different
from the normal passwords),execute the following command:
#/opt/samba/bin/smbpasswd student
New smbpasswd:
Retype:

#/opt/samba/bin/smbpasswd alice
New smbpasswd:
Retype:
#/opt/samba/bin/smbpasswd nice
New smbpasswd:
Retype:

This password information is updated in /etc/smbpasswd file.

CREATING A SAMBA SHARE:


#vi /opt/samba/lib/smb.conf ( This file already contains some data ,don’t edit the
existing data)
[public]
comment = Public directory
path = /tmp/pub
public = yes
writable = yes
[access]
comment = User access
path = /tmp/access
public = no
writable = yes
validusers = student alice
[group]
comment = Group access
path = /tmp/group
public = yes
writable = yes
writelist = @dba
[cdrom]
comment = CD-Romsharing
path = /cdrom
public = yes
writable = no
printable = no
:wq!

Now create the fallowing directories:

#mkdir /tmp/pub
#cd /tmp/pub
(create some files in this directory)

#chmod 777 /tmp/pub

#mkdir /tmp/access
#cd /tmp/access
(create some files in this directory)
#mkdir /tmp/group
#cd /tmp/group
(create some files in this directory)

#groupadd dba
#chgrp dba /tmp/group (this command brings the /tmp/group directory under dba group)
#chmod 770 /tmp/group
#usermod –g dba alice (initially this user was in staff group whose group id is 10)
#usermod –g dba nice (initially this user was also in staff group)

To see the status of samba server being at the server side,execute the following command

#/opt/samba/bin/smbclient -L localhost -N

To see the status of samba server from the client side,execute the following command,

#/opt/samba/bin/smbclient -L 192.168.0.4 -N (where 192.168.0.4 is server ip)

CONNECTING TO A SAMBA SHARE FROM UNIX CLIENT:

#/opt/samba/bin/smbclient //192.168.0.4/public -U student (where “public” is a share


name.student,alice and nice or any other user can access this share because all are having
authentication)
Password: (Enter sambapassword here)
Then we will get the samba prompt as following
Smb:\>pwd (to check the present working directory at the server side)
Smb:\>!pwd(to check the present working directory at the client side)
Smb:\>ls (to list the files at the server side)
Smb:\>cd <directory name> ( to change the present working directory at the server side)
Smb:\>lcd <directory name> (to change the present working directory at the client side)
Smb:\>get <file name> (to download a file)
Smb:\>put <file name> (to upload a file)
Smb:\>mget <filename> <filename> ……… ( to down load multiple files)
Smb:\>mput <filename> <filename> ………..(to upload multiple files)
Smb:\>get * (to download all the files)
Smb\>put * (to upload all the files)
Smb:\>exit (to exit from the samba prompt)
(These commands are same as that of ftp commands)

#/opt/samba/bin/smbclient //192.168.0.4/access -U student


Password:
Smb:\>
#/opt/samba/bin/smbclient //192.168.0.4/access -U alice
Password:
Smb:\>

#/opt/samba/bin/smbclient //192.168.0.4/access -U nice


Permission denied (Because nice is not authenticated user to access this share)

#/opt/samba/bin/smbclient //192.168.0.4/group -U student


Permission denied ( Because student is not under “dba” group)

#/opt/samba/bin/smbclient //192.168.0.4/group -U alice


Password:
Smb:\>

#/opt/samba/bin/smbclient //192.168.0.4/group –U nice


Password:
Smb:\>

Cdrom share is accessed by every one.

CONNECTING TO WINDOWS SHARES FORM UNIX CLIENT:


If samba server is a windows machine use the following command to connect to
The server
#/opt/samba/bin/smbclient //<serverip>/c$ -U Administator
Password:
Smb:\>

You might also like