The madness of Samba setup on Ubuntu

Yeah, Ubuntu has thrown a few medium-sized annoyances at me recently. Tonight I wanted to set up Samba for sharing files with our local Windows machines. I've set up Samba dozens of times, but this is one of the more confusing episodes I've come across recently.

First of all I looked and saw that I had a package named "samba-common", and yet this did not mean I actually had Samba. A little confusing, but I just had to fire up Synaptic and search for "samba". So I installed the package and figured I'd have a serviceable default config. No dice. Rather than hack at /etc/smb.conf I decided to use swat, the Web control panel for Samba, which I've used, and I like. I installed it and tried to surf http://localhost:901/, the usual way to access swat. No response. I read the swat man page which said it runs through inetd. The man page specifically mentions editing /etc/inetd.conf I looked there and found but two lines, one of which was:

#<off>#swat            stream  tcp     nowait.400      root    /usr/sbin/tcpd  /usr/sbin/swat

How quaint! Old school inetd. How odd! Only 2 managed services. Oh well. I uncommented the line and then tried to restart it. Umm. no trace of inetd beside that config file.

At this point I did some googling. I just wanted a simple Ubuntu-specific HOWTO. I wasn't really in much of a mood for pulling out all the hacking stops. Google had almost nothing to offer except others bitching about how hard Samba is to set up on Ubuntu. I went back to work. I checked Synaptic and it turned out I had no inetd package installed. I selected xinetd, which is what I'd been expecting in a modern distro, anyway.

Now I had to configure swat to run behind it, but I was on my own. This is why a package such as swat should depend on a package such as xinetd, so that it can provide a plug-and play config. I'm pretty sure it does on Fedora Core. And certainly there shouldn't be phantom inetd.conf files floating around to trip up users.

I created /etc/xinetd.d/swat, with these contents:

# description: SAMBA SWAT
service swat
{
    disable         = no
    socket_type     = stream
    protocol        = tcp
    user            = root  #should use a more limited user here
    wait            = no
    server          = /usr/sbin/swat
}

And then dpkg-reconfigure xinetd to restart xinetd (and do any other magic needed after updating config). Finally I got swat up. If you want to use swat to administer Samba, you'll need a proper root password. No sudo to bail you out. If you log in as your user, you get a crippled, pee-on swat console for mere mortal users. On one machine I got my Ubuntu root by booting to single user mode and then setting the password. On this machine I used Automatix. Either way, use that root login to get the full plate of admin options. From that point it's fairly smooth sailing. swat isn't perfect, but it's as close as you get to simple Samba administration.

I hope this helps someone else. Maybe it's my imagination, but this seems to be much harder than I remember it ever being on Fedora Core or Mandrake. Oddly enough, I'm getting the impression that Ubuntu rocks for user desktop stuff, but gets really clumsy when it comes to the server management goods that should be bread and butter for Linux.

[Uche Ogbuji]

via Copia
32 responses
Sometimes I think it just depends on the path you're used to. I've never had Samba issues in the way you talk about, but then I've never been near 'swat'. I guess swat isn't on the golden path in Ubuntu.
> I guess swat isn't on the golden path in Ubuntu.



Maybe.  But then I need a golden roadmap.  I've heard that webmin is near useless on Debian and derived.  I've found debconf primitive and very fiddly every time I have to use it.  I couldn't find any other config helpers in the menus and such.  Googling mostly exposed a lot of frustration by other users on the matter.  There was more scolding from Ubuntu boosters telling folks to down their cod liver oil and configure Samba the old fashioned way than there were friendly solutions.  I've proved my geek mettle often enough that I don't have to pull out the slide rule every time I just want to enable a well-known service on my computer.
Damit, if this works, then I can upgrade my server, to kubuntu, form Debian Stable!



I have been waiting for this, for 2 month now.



I will test your solution in vmware, if it works...you are the man.



I posted a question on the kubuntu forum two weeks ago, with no luck.



thansk for the advice.
Thank you for posting this. SWAT on Ubuntu had been driving me crazy. Long live the secondhand Power-PC G3 Ubuntu File Server!
Guys,



I'm trying to install SAMBA on Ubuntu but when i install the samba-commons and samba packages in synaptic i can't run swat.



Using shell, when i write swat it doesn't recognize this name, saying this command does not exist.



How can i solve this?
Bruno: This might be a stupid question, but did you install the swat package?  I just did a fresh install and followed the other instructions listed above and was succcessful. 



The only thing I did slightly differently was set a password for root using:

sudo passwd root

(needed to make swat work for real)



Agree with the author; surprisingly difficult for something so common.
I simply set up Samba using the Samba Configuration Panel in the KDE Control Panel.  The only part of it you absolutely HAVE to do in command line is run smbpasswd to generate your username/password combos for the network.



Oh, I use Debian, BTW.
Thanks very much, Uche. Your writeup got me 95% of the way there in getting SWAT to work. The one thing that didn't work was your SWAT config file,  /etc/xinetd.d/swat. The comment at the end of the "user = root" line caused xinetd to throw an error and not load the swat configuration. I had to look at syslog to figure that out. A comment on the line above works fine:



# description: SAMBA SWAT

service swat

{

  disable  = no

  socket_type  = stream

  protocol  = tcp

  #should use a more limited user here

  user  = root 

  wait  = no

  server  = /usr/sbin/swat

}
Simple when you know how! Thanks.
very helpful thread!



basic question - i logged into the root, and i tried to access http://localhost:901/ from the root CLI, however, Ubuntu won't allow this without a forced "-H". How do I log in to http://localhost:901/? Thanks!
harbinger,



I'm not clear on what you tried to do.  Were you using lynx (or elinks) to access that Web page from CLI?  What precise commands did you try, with what precise effect?



FYI in my case I simply use Firefox to access http://localhost:901/ from a regular user.  It prompted me for a username/password and I entered the root credentials.  Worked for me.
I am an intermediate Windows user who is not at hacker level, but knows enough to do quite a bit of things on a PC...I am not a noob. I have recently installed Ubuntu 5.10 on an old HP 8660...I was sick of paying for Windows OS. Ubuntu does have some user-friendly things, but it still seems like pulling teeth to get some basic things to work.  For example, I want to use my old Ubuntu PC as a music server and play the files on my XP laptop using Winamp.  I installed Samba and am having the darndest time getting the two computers connected! I  keep trying to express to the Linux community that their success (increased usership) is directly proportional to the user-friendliness of the programs!  It is no good if there are X number of features or programs if nobody can figure out how to use them or has to do Google searches for lines of code.



The point is that there should be auto installer packages for all of this crap, including Samba, SWAT, whatever.  Even Automatix is OK...I was able to get that going after typing in the few lines of code in the terminal.  The rest of it was done automatically.  After spending a couple months trying to get Samba to work, spending a couple hundred dollars on Windows doesn't seem like such a bad idea.
LOL ^^ What a noob.
Thanks, this saved me quite some time!

Appreciate it. :-)
Trying to make GUI tools that work is a waste of effort.

Real Linux users don't need them, and everyone else can quite reasonably use a Mac or a Windows machine. It takes so much effort to learn Linux that a user who isn't learning Linux for fun is better off investing the same effort in Windows. I enjoy Linux myself, but use Windows when I need to get work done. There are heaps of individual Linux tools that are useful, but developers who fundamentally dislike non-developer end users aren't going to care about fixing user issues.
Thank you!

Near perfection (The comment at the end.. :P )
Instead of installing xinetd, I installed package netkit-inetd (standard shipped with ubuntu) and this installs the standard inetd components. Didn't have to alter config files or whatever, had samba working immediately.



Basic steps I followed:

1. install samba, swat and netkit-inetd

2. change root passwd using "sudo passwd root"

3. Use favourite firefox browser to access http://localhost:901

4. done.
Ubuntu is a giant disappointment all around. Debian, without it Ubuntu would be nothing, is by far the easiest and best Linux offering avaliable. Just add SWAT and your up and running and for anything else as well.



Ubuntu needs to do a lot of work to get it's distro up to par if it thinks it is a system other than an internet appliance! Shame Michael, shame on you, to many cosmic rays get through that russian made tin can!!!!
no luck to get swat working with this manual neither, I tried the first and the last props, but always get the "problem loading page". samba was so easy to get going with webmin, now this is over, right now I agree very much with sam
lukas,



Are you using Breezy Badger or Dapper Drake?  I've been told that for the latter things have improved somewhat, and apparently the right recipe is here:



http://ubuntuguide.org/wiki/Dapper#Samba_Server



I'd be curious as to whether that helps anyone.



That having been said, there is at least one major regression in Dapper.  Watch out for the following bit of nastiness:



https://launchpad.net/distros/ubuntu/+source/hal/+bug/44874
bob_jones: your comment was not only NOT helpful, it was a waste of electrons. It was also a waste of time for everyone who viewed it. (It was even a waste of YOUR time - but that seems karmically fair.) In the future - if you can't say something productive....keep your fingers off the keyboard, bubba.



lurker: Any post that starts out with "real linux users...." is pretty much guaranteed to go arrogant, real fast. You didn't disappoint. (Your message is basically "hey, n00b - if you can't figure it out, get offa Linux and go play with baby toyz. Linux is for us l33ts - not for you unwashed masses.") Well - as long as your attitude prevails? Yep - it will be. Is that your intent? (Hint: try BSD, or better yet, Hurd. I hear it's TOTALLY inaccessible to non-nerds. You'll be SO cool, you'll NEVER need to worry about a girlfriend! Imagine - NO native drivers to worry about! Not a GUI tool to be found! Heaven!)



Jeezus. Some people. No wonder Linux isn't yet kicking Windows' ass -- with so many cheerleaders like y'all. ("You stupid n00b -- if you can't fix it, Linux isn't for you!") Good thing none of your kind are in marketing. (Well, maybe some ARE - but you'd all get fired after your first customer interaction.)



Randy
Thanks for the /etc/xinet.d/swat hint. 



That worked for me to bring up SWAT
Hi--



I have samba running on this Ubuntu 6.06. Synaptic shows swat is installed, and I even reinstalled it.



I followed your instructions above, but Firefox reports Problem loading--Unable to connect.



Any suggestions for troubleshooting this?



Thanks!



:- Doug.
Hi--



Got it! Somehow managed to miss the closing } in copying it to my computer.



After running sudo passwd root, I was able to get in as root. Never did figure out how to get in as ordinary user.



Thanks for this HOWTO.



:- Doug.
Awesome, thanks



I am very new to linux, but i know how to read instructions well enough, and this was perfect and fixed my problem nicely.



Its a long road converting to linux from 10 years of windows administration.
Thanks for this.

I encountered the same thing. Info was lacking on just how to START swat, although the install seemed straightforward.

I was disappointed to not see it come up in the Ubuntu services manager or somewhere.



Following your tone on the old-school status of inetd (and xinetd, and the neccesity of editing stuff by hand) I read through 'till I saw -- BertusBakfiets instructions.



nekit-inetd seems to be the one true way.



It just WORKED!

And I feel better about not messing under the hood with things that are being managed by other tools already.



:) Thanks to the both of you.
It's all good. Thanks a bunch. If you cp and paste the samba conf listed above, take out the comment on the user=root line otherwise it will cause xinitd to fail when loading. Thanks a bunch!!
BertusBakfiets, and all the others contributing thanks for the info. Up and running with Samba and Swat. Hoping that the worst is over.



BTW, how do I restrict the availability of the Swat config screens? I want it to be available only from the local network.



Thanks again.
Thanks both of you. I used Bertus solution and it worked flawlessly. Very useful. I think SWAT should have a netkit-inetd dependency.
thanks

Agree wholeheartedly, after two days of working through instruction books, google searches etc initial problems of seeing swat from xp machines solved by comment on one website (nowhere in any Samba instruction info) that you need to also install netkit-inetd. Second unclear obstacle was getting global configuration, rarely is it mentioned that you have to log in as root rather than as a member of admin group, then there was the root password issue. It is amazing with linux how many (very small) ommissions in the huge volume of info available can stuff you up for days.
10x for the help, it solved my problem.

Unfortunately I believe Ubuntu is not for me. I will need to move to a "real" non-desktop Linux
thanks! this was a great help to me!!!!

i had to 'sudo passwd root' and move the comment at the end of the line in the xinetd.d/swat conf file as other commenters noted and then it worked fine!



Cheers!