...making Linux just a little more fun!

| TAG Index | 1 | 2 | 3 | Knowledge Base | News Bytes -->

The Answer Gang

By Jim Dennis, Karl-Heinz Herrmann, Breen, Chris, and... (meet the Gang) ... the Editors of Linux Gazette... and You!



(?) samba share folders

From jpshark

Answered By: Brian Bilbrey, John Karns, Suramya Tomar

hello, perhaps you could answer a simple question for me. i have a home network with 2 linux boxes and 2 WinXP boxes. all 4 computers are set with the same workgroup - the linux boxes use samba. i can access the windows boxes from the linux boxes no problem. when I try to access the linux boxes from the windows boxes, i get prompted for a user name and password.

(!) [Brian] You need to setup users and passwords explicitly for Samba, these are stored and sometimes administered separately from the Unix accounts.
$ man smbpasswd
for more details.

(?) if i try the normal user name and passwords, windows resets the dialog box and prefixes the user name with the name of the computer. of course, this does not work. how do i access a linux box running samba from a windows box running XP? also, i haven't figured out how to mark a folder as "shared" in linux. thanks for any help. regards, jp

(!) [Brian] You need to configure directories that are shared in your systems smb.conf. You will want to read the smb.conf files on your system, both the running one (often found in /etc/samba/smb.conf) as well as any example smb.conf files that are found with the Samba documentation. And of course,
$ man smb.conf
(!) [John] As with most aspects of unix-like OS's, there is more than one way to configure samba. In fact samba comes with a utility called 'swat', but I've never used it, so I can't really say much about it. However, most Linux distros these days do a pretty decent job of providing a template configuration file that you can edit to add / change what you need without too much work. You will need to have a text editor installed, and know how to use it.
Depending on the distro that you have, the samba configuration file will likely be found as either /etc/smb.conf or /etc/samba/smb.conf. "locate smb.conf" might be of use to you, assuming that the "updatedb" utility has been run on your system. To run the following command(s) and edit the samba configuration, will need to login as root.
Usually, to get samba to allow connections from the outside world, you need to add the user and password manually, using the utility samba provides. To add a new user account, e.g., "john", type "smbpasswd -a john". The "-a" is for "add". "man smbpasswd" for details. You will be prompted for the password. If you duplicate the same username and password as you use on the windoze side, then you won't be prompted for a username and password when you want to access a samba share.
You designate a folder share by entering some parameters into the smb.conf. For example. lets say that I have a dual-boot machine, and I mount the 'blows partition under /dosC. I could add a stanza to smb.conf such as the following:
[dosc]
    comment = W2k - vfat
    browseable = yes
    read only = Yes
    path = /dosC
    valid users = john
    guest ok = no
    printable = no
Samba gives a fine degree of control by providing lots of parameters. Any parameters not specified for a share assume defaults which samba will provide. Usually the defaults for a share are such that you won't need to provide more than a handful of parameters. "man smb.conf" will give you lots of info about them. One thing perhaps worth noting is that many of the parameters have one or more synonomous "twin" parameters, so there aren't quite as many as there may seem at first, as there are "duplicates"
After making changes to smb.conf, it may be expedient to restart the smb daemon. There are actually two daemons, but they might both be handled in just one init script.
/etc/init.d/smb restart
and
/etc/init.d/nmb restart
should suffice in any case.
That will hopefully be enough to get you started. There's lots of info out there on the 'net about samba too. Google is your friend.
To share a folder using Samba in Linux you need to edit the smb.conf file. On my computer it is located in the /etc/samba folder.
You need to add the following lines to the file for each of the directories you want to share:
[ShareName]
         writeable = yes
         valid users = suramya
         user = suramya
         path = /home/suramya
         write list = suramya
The path is the directory you want to share. ShareName is the name you want to call it. Valid users tells the system which users are allowed to access this share. To create a readonly share remove the writable=yes tag.
Use the smbpasswd command to set the user password for samba share. There is a way to have it sync the password with the linux password file but I could never get that to work

This page edited and maintained by the Editors of Linux Gazette
HTML script maintained by Heather Stern of Starshine Technical Services, https://www.starshine.org/


Each TAG thread Copyright © its authors, 2005

Published in issue 112 of Linux Gazette March 2005

| TAG Index | 1 | 2 | 3 | Knowledge Base | News Bytes -->
Tux