LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
::In The News
::Industry
::Interviews
::Reviews
::Tips
::Tutorials
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Articles :: Tutorials :: Setting up Samba

02 September 2004

Introducion
I decided to get samba working between my linux box (`Edge') and my Windows 98 carcass (`Caffeine'). This was for a number of reasons:

  • Transferring files between my Nokia 9110 and Edge used to be a complete chore.
    Moving files from the 9110 to Edge meant copying them to Caffeine's c:\ drive and them FTPing them across. The hierachical tree in the Nokia PC suite pretty much implies that it can detect other computers within the 'Network Neighbourhood' and let me drag and drop the files between the 9110 and Edge! This is much simpler, turning a two stage chore into something much more simpler and quicker to do.
  • Silly me bought a winprinter (a Lexmark 3200) and I wanted to see if I could make use of it under Linux through some way or another.
    I haven't gotten around to figuring out how to do this yet. Some other time...

Setting things up.
Naturally you need to have a TCP/IP network set up. I did this around the same time that Kevin Lyda hosted his Installfeist, so I'm a little bit fuzzy about the detais. All it involved was:

  • Getting a crossover cat-5 cable for connecting the two PCs (I have noticed that cat5 is much more robust than coaxial network cable).
  • Slotting a network card into each of the machines assigning IP numbers and a subnet mask to the cards (I used YaST to do this under SuSE)
  • Pinging the other machine to check things worked.

The next thing to do was to get samba installed and working, in hindsight this wasn't all that difficult to do, though I must admit that I made a few silly mistakes initially - reading the documentation (/usr/doc/packages/samba) helped. To summarise though (if, like me, you couldn't be bothered to read documentation most of the time) this is what you need to check:
  • Ensure that the interfaces line in smb.conf is uncommented and that the IP number for your linux box replaces the example (happily enough the two were identical for me) and also that the subnet mask is correct. Samba does not figure out this information on the fly because it is possible to have more than one IP address assigned to one network card and it would get rather confused.
  • Ensure you have these five lines in the global section of /etc/smb.conf included/uncommented if you want to be able to see your 'user space' in Windows:
    [homes]
    comment = Home
    browseable = no
    read only = no
    create mode = 0750
    
  • If you set browseable to yes rather than no then an extra folder called 'Home' will be displayed in the Network Neighborhood on your Windows box. This folder is the same as your user's home folder so there isn't really any point having it displayed...
  • Also make certain that the guest account that you may have specified in the global section of smb.conf does exist. It's best to create a 'pcguest' account with minimal privilages (don't forget to add it to /etc/ftpusers).
    If you don't want the bother of doing this then comment out that option; Samba will then use the 'nobody' account for browsing the Network.

Some tweaks and changes.

  • To speed things up slightly I added the line socket options = TCP_NODELAY to the global section of the samba configuration file.
  • I added a section to the smb.conf file to let me access a 'shareall' or public 'drive' hosted on the Linux box. This meant copying these lines from a sample configuration file and creating the /usr/public directory chmoded to 777 (being way to trusting, but as it's only for a home setup I think I can get away with that):
    [public]
    path = /usr/public
    public = yes
    only guest = yes
    writable = yes
    printable = no
    
  • Just for the sake of it, I decided to share out Edge's cd drive. I discovered that editing fstab to automatically mount the cd drive makes no difference if the drive has been unmounted some time before exploring its contents in Windows - this is something worth remembering. To get around this you will have to either login in and type 'mount /cdrom' (or some such equivalent for your own system) each time that you want to access a Linux CD from Windows, or use a cgi script such as this:
    #!/bin/bash
    mount /cdrom
    printf "Content-type: text/plain\n\nDone."
    
    Note that using this is a huge security risk, use this script at your own peril!
  • Initially the comment for Edge in Windows Network Neighborhood was 'Samba 1.9.18p4' - I decided to change this to something a little more informative.
    This meant adding this line to the global section of smb.conf
    server string = Ken's Linux PC
  • If you take a look at /var/log/log.smb after using your shares a few times you'll notice that samba logs just about everything to that file. This is great if you are very security conscious (aka rather paranoid). If you do not want this to happen it's quite a simple matter to add logfile=/dev/null to the global section - though of course it's always a good thing to have a log of what happened in case things go wrong.

Essential things to do in Windows:
Once you have samba set up you will need to do a few things in Windows so you can get around to making some use of it.

  • Firstly you will need to open the Network settings:
  • Rightclick on Network Neighbourhood and add the client 'Client for Microsoft Networks', then select it as the Primary Network Logon client.
  • Click on the Identification tab and ensure that the specified workgroup is the same as that mentioned in the smb.conf file.
  • Depending on the version of Windows that you have installed you should read the Win95.txt file in the /usr/doc/packages/samba directory on your Linux box - This is to do with Microsoft changing things around and now encrypting the password, and also applies if you are using Windows 98.

Getting the 9110 involved.
When you reboot your windows box you should be able to log on (with your Linux username and password) and see your Linux box in Network Neighborhood. There are still a few more things that you will need to do if you want to copy files straight from your 9110 to your 'user space' on the Linux box.

  • The Nokia PC Suite, as you will discover, does not display the computers available in the Network Neighborhood in it's File Transfer window. It will however display both the local and network/mapped drives of your Windows box. Mapping your Linux folder to a drive is quite simple; what you need to do is right click on whichever folder you want to use then click on 'Map Network Drive', check the reconnect at logon box and finally click on the OK button.
  • That done, when you start up the Nokia PC Suite next you will see that new drive in the left pane (it is called "Ken on 'Edge'" in my case) and can transfer files between your 9110 and Linux box more easily.

Sending a message.
There are a few other things that you can do with samba - one of them is to send a message to all samba clients. This can be very handy if you want to let them know that you have to restart Samba.
If they are using Windows to connect to your shares then they must be running 'winpopup.exe' to recieve these messages.
You can configure Samba to be the logon domain and use a log on script to start winpopup.exe automatically, however this is overkill for a simple home network. It's simpler to just have a shortcut to winpopup in the Startup group.
You can use smbclient to send messages (with the -M arugment to specify which machines you want the message to go to). Or you could use the samba wall script (wall.perl) which is available in /usr/doc/packages/samba/examples/misc. (The wall command writes a message to the screens of all people that are logged in to your linux box - wall.perl is the equivalent for Samba clients.)
I had to make a few changes to wall.perl so that it would work for me - you can download it from the downloads section. Once you have the script renamed to smb-wall and set it's executable permission (chmod 755 smb-wall) you can send a test message:

$smb-wall
What are you using Windows for?
.
You can also use smb-wall to send a message to a specified client with smb-wall caffeine (where caffeine is the name of the client tht you want the message sent to.)
Smb-wall can handle piped input, so something like the following should work just fine:
echo "Pinging!" | smb-wall caffeine; ping caffeine

You should be aware that the name of the machine that you specify to smb-wall must be the primary name of the machine (i.e. not an alias). So, for example, this would work on my network at home:

$smb-wall caffeine.zed
quick test
.
but this would not, even though gw has the same IP number as caffeine:
$smb-wall gw.zed
this will not get through
.

Other uses of smbclient

  • It is possible to connect to a shared Windows drive ala ftp and transfer files to or from it in the same manner that you would use a command line ftp client.
    smbclient \\\\CAFFEINE\\ZIP creates a samba connection to the ZIP drive that I have attached to my Windows 98 box. It's important to know that smbclient will prompt you for a password, even if the shared folder does not have a password shared against it in windows. I've found that random passwords will work just fine.
    Typing help at this point will cause a list of smbclient commands, quite similar to ftp's, to be displayed
    ilug@Edge:/home/ilug > smbclient \\\\CAFFEINE\\ZIP
    Added interface ip=192.168.1.1 bcast=192.168.1.255 nmask=255.255.255.0
    Server time is Mon Nov 22 23:03:04 1999
    Timezone is UTC-0.0
    Password:
    security=share
    smb: \> help
    ls             dir            lcd            cd             pwd
    get            mget           put            mput           rename
    more           mask           del            rm             mkdir
    md             rmdir          rd             pq             prompt
    recurse        translate      lowercase      print          printmode
    queue          qinfo          cancel         quit           q
    exit           newer          archive        tar            blocksize
    tarmode        setmode        help           ?              !
    smb: \> put nokiappp.txt
    putting file nokiappp.txt of size 945 bytes as \nokiappp.txt (38.452 kb/s)
    (average 38.4521 kb/s)
    
    There is a much better way of moving files to a different computer using the Samba (smb) protocol under Linux. That is to use kruiser, a KDE file manager, which used to be called KExplorer.
  • You can use smbclient to retrieve a list of the services (e.g. printers and diskspace) that are available on a machine (this is equivalent to net view \\CAFFEINE under DOS).
    Handy if you can't quite remember the name of whatever service it is that you want to use. E.g.
    ilug@Edge:/home/ilug > smbclient -L caffeine -I caffeine
    Added interface ip=192.168.1.1 bcast=192.168.1.255 nmask=255.255.255.0
    Server time is Mon Nov 22 23:28:06 1999
    Timezone is UTC-0.0
    security=share
    
    Server=[CAFFEINE] User=[] Workgroup=[CENTRAL] Domain=[CENTRAL]
    
            Sharename      Type      Comment
            ---------      ----      -------
            IPC$           IPC       Remote Inter Process Communication
            NOSMARTS       Printer   damned winprinter
            PRINTER$       Disk
            ZIP            Disk      ZIP
    ilug@Edge:/home/ilug >
    
And that, I think, is the perfect opportunity for me to wrap this up!

The Declan clause.
This tutorial was written by Ken Guest, http://ken.guest.cx.
Copyright © Ken Guest 1999.
Publication of this work in any printed or electronic form in part or in whole for non private use without (a) the inclusion of the above copyright notice (b) written permission of the author is an infringement of copyright and thus prohibited by law and international convention.




About the author, Ken Guest.

USERS COMMENTS


                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell