Objective:
To familiarize students with the file/printer sharing features of samba.
Scope:
The students would be able to do the following at the end of this lab:
• Share a printer on the network using samba.
• Create group shares on the samba server.
• Share CD-ROM drive and folders on the samba server
• Automate the mounting process using SMB clients
Exercise-1:- This exercise illustrates Adding a Printer to a Samba PDC
The easiest way to let Samba know the printer is available is via the Samba SWAT Web interface. Once you are in SWAT:
1. Click the "Printers" button
2. Find your printer in the pull-down menu. If the printer name has an asterisk (*) beside it, it has been auto-configured by Samba. It might not be visible on your network, however, if Samba hasn't been restarted since creating the printer. If this is the case, restart Samba.
3. If Samba did not auto-configure your printer, you need to edit or create it yourself. Click on the
"Commit Changes" button to create an updated /etc/samba/smb.conf file.
4. Click on the "Status" tab at the top of the screen and restart smbd and nmbd to restart Samba.
Your printer will now be available for use by all Windows workstations.
Exercise-2:- This exercise illustrates Creating Group Shares in SAMBA
On occasion, subgroups of a family need a share that is fully accessible by all members of the group. For example, parents working in a home office environment may need a place where they can share, distri-bute, or collaboratively work on documents. Here's how it's done.
Create The Directory And User Group
As with any group activity, the first step is to get organized.
1. Create a new Linux group parents:
[root@tmp]# /usr/sbin/groupadd parents
2. Create a new directory for the group's files. If one user is designated as the leader, you might want to change the chown statement to make them owner
[root@tmp]# mkdir /home/parent-files
[root@tmp]# chgrp parents /home/parent-files [root@tmp]# chmod 0770 /home/parent-files
3. Add the group members to the new group. For instance, the command to add a user named father to the group is:
[root@tmp]# /usr/sbin/usermod -G parents father All your members are in the group; now they need to share.
Configure the Share In SWAT
Next, you need to create the share in Samba using SWAT.
1. Click on the shares button then enter the name of the share you want to create, such as only-parents.
2. Click on the "Create Share" button. Make sure the path maps to /home/parent-files and make the valid users be @parents, where parents is the name of the Linux user group.
3. Click on the "Commit Changes" button to create a new /etc/samba/smb.conf file.
4. Click on the "Status" tab at the top of the screen and restart smbd and nmbd to restart Samba.
Your /etc/samba/smb.conf file should have an entry like this at the end:
# Parents Shared Area [only-parents]
path = /home/parent-files valid users = @parents
If it does, all is well and you can move on. If not, double check your work in the last steps.
Map the Directory Using "My Computer"
Finally, let the user log into the domain from a remote PC 1. Right click on the "My Computer" icon on the desktop 2. Click on "Map Network Drive"
3. Select a drive letter.
4. Browse to the HOMENET domain, then the Samba server, then the share named only-parents.
5. Click on the check box "Reconnect at Logon", to make the change permanent.
Now the files located in the Linux /home/parent-files directory will be accessible to the parents only and your job is complete!
Create a CD-ROM Drive Mount Point on Your Samba Server
You'll now need to create the mount point on the Linux server to mount and access the CD-ROM drive.
In this case, I've named it /mnt/winclient-cdrom, and you'll use the mount command to get access to this device from the Linux server.
Password Prompt Method
The Linux mount command will try to access the CD-ROM device as user "username" by using the
"username=" option. You will be prompted for a password.
[root@tmp]# mkdir /mnt/winclient-cdrom
[root@tmp]# mount -t smbfs -o username=username \ //winclient/cdrom /mnt/winclient-cdrom
No Prompt Method
Linux won't prompt you for a password if you embed the access password into the mount command string along with username as in the example below.
[root@tmp]# mkdir /mnt/winclient-cdrom [root@tmp]# mount -t smbfs -o \
username=username,password=password \ //winclient/cdrom /mnt/cdrom
Using the smbmount Command Method
Some versions of Linux support the smbmount command to mount the remote drive.
Incompatible versions will give errors like this:
[root@tmp]# smbmount //winclient/cdrom \ /mnt/winclient-cdrom -o username=username Password:
27875: session setup failed: ERRDOS - ERRnoaccess (Access denied.) SMB connection failed
To be safe, stick with using the Linux mount command.
Automating Mounting with Linux SAMBA Clients
You can also automate the mounting of shares by placing entries in your /etc/fstab file. In the example below the home directory of user peter on server 192.168.1.100 will be mounted on the /mnt/smb mount point as a samba filesystem (smbfs) using the login information in the file named /etc/cred.
#
# File: /etc/fstab
#
//192.168.1.100/peter /mnt/smb smbfs credentials=/etc/cred 0 0
The contents of the /etc/cred file needs to have the username and password for the account in this format:
#
# File: /etc/cred
#
username = peter
password = peterspassword
Once finished you can use the mount -a to mount the new /etc/fstab entry, and the /mnt/smb directory will now contain the contents of the share.
[root@smallfry tmp]# mount -a [root@smallfry tmp]# ls /mnt/smb backups profile docs data music [root@smallfry tmp]#
Exercises for lab:
Exercise 1:- Share a printer on the network using samba shares.
Exercise 2:- Create group shares on the samba server.
Exercise 3:- Share CD-ROM drive and folders on the samba server.
Exercise 4:- Automate the mounting process using /etc/fstab.
Home Work:
1) write a note on access permission setting for shared resourses on samba.