"Linux Gazette...making Linux just a little more fun!"


Using SAMBA to Mount Windows 95

By Jonathon Stroud, jgstroud@eos.ncsu.edu


Many major universities are now offering network connections to students in their rooms. This is really a wonderful thing for the Linux community. Whereas, the majority of student owned computers on these networks are still running Windows 95, many students are making the switch to Linux. One thing that newcomers to Linux are constantly asking is, "Can I access a directory shared by a Windows 95 computer in the 'Network Neighborhood', and can I share files to Windows 95 users?" The answer, of course, is YES. I keep trying to tell them that there is nothing that Linux can not do, yet they continue to come to me and ask if they can do this in Linux, or if they can do that. I have never once answered no.

Samba

To mount a Windows 95 share, we use a program called Samba. Samba is a program that allows Linux to talk to computers running Windows for Workgroups, Windows 95, Windows NT, Mac OS, and Novel Netware. Samba even allows you to share a printer between computers using these different operating systems. Samba comes with most distributions of Linux, but if you do not have it installed, you can obtain a copy from the Samba home page at https://lake.canberra.edu.au/pub/samba/.

Mounting Windows 95 Shares

The first thing you will probably want to do, is check to see what directories are shared on the computer you are trying to mount off of. To do this type smbclient -L computername. This will list all the directories shared by the machine. To mount the directory, we use the command smbmount. Smbmount can be a little tricky though. I have created a script, named smb, that allows users to mount drives using smbmount, with relative ease.

   #usage  smb computername sharename
   #!/bin/sh
   if [ $UID = 0 ]; then
      if [ ! d /mnt/$1 ]; then
         mkdir /mnt/$1
      fi
   #You may want to add the -u option here also if you need to 
   #specify a login id (ie: mounting drives on Windows NT)
      /usr/sbin/smbmount //$1/$2 /mnt/$1 I $1 c etc
   else
      if [ ! d ~/mnt/ ]; then
         mkdir ~/mnt/
      fi
      if [ ! d ~/mnt/$1 ]; then
         mkdir ~/mnt/$1
      fi
   #You may want to add the -u option here also if you need to 
   #specify a login id (ie: mounting drives on Windows NT)
      /usr/sbin/smbmount //$1/$2 ~/mnt/$1 I $1 c etcfi

To execute this script you simply type smb followed by the name of the computer you are mounting off of, and then the directory you wish to mount (ex. smb workstation files). If you are root, the script creates a directory in /mnt by the same name as the computer, and mounts the directory there. For any other user, the script makes a directory in the users home directory named mnt. In that directory it makes another directory by the same name as the computer and mounts the share there.

Sharing files with Windows 95

Now to share a file. This also is not too difficult. To share a directory you need to edit /etc/smb.conf. By default, Samba shares users' home directories, but they are only visible (and accessible) to the owner. This means that the person accessing the share should be logged into Windows 95 with the same loginid, as they use to log into your Linux box.

Let's say you want to let 'bob' access the directory '/shares/files', and you do not want anyone else to access it. To do this, add these lines to your /etc/smb.conf file.

   [bobsfiles]
      comment = files for bob
      path = /shares/files
      valid users = bob
      public = no
      writable = yes
      printable = no
  1. indicates the name the directory will be shared under.
  2. is a comment that can be displayed in the Windows 95 Network Neighborhood.
  3. lists the directory on your computer that will be shared
  4. when set to yes allows users to access the directory with guest privileges.
  5. indicates whether or not the user has write permissions to the indicated directory
  6. when set to yes allows users to spool print jobs from that directory

More examples on sharing files can be found in the default smb.conf file. For more help on setting up this file, see the Samba web page, or type man smb.conf.

More cool Samba stuff

If a Windows 95 user on your network is running winpopup (an instant massaging program), you can send them a winpopup message using Samba. To do this just type

smbclient -M computername
message_text
.


Copyright © 1997, Jonathon Stroud
Published in Issue 19 of the Linux Gazette, July 1997


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next