Author: Federico Kereki
If you need to share files or printers with Windows machines, you’re likely using Samba and know how to administer and configure it by editing configuration files and starting and stopping the daemon. However, there’s an easier, graphical way to configure your box: the Samba Web Administration Tool.
SWAT allows you to set up all aspects of your Samba server through an intuitive Web interface in a style similar to Webmin. (In fact, if you use Webmin, you can access SWAT by going to Servers -> Samba Windows File Sharing and then clicking on the hammer icon for SWAT.)
Among its interesting features, SWAT includes a wizard that can you help you configure Samba quickly with a basic setup. It also provides context-sensitive help for all parameters (taken directly from the man pages), and it lets you monitor the current state of connections and users. Since it is an integral part of the Samba suite, all available parameters are always up to date.
While SWAT offers convenience, it won’t help you learn about Samba. You need to know about Samba before you use SWAT; if you don’t know what you’re doing, you’re likely to do more harm than good.
Installation and configuration
SWAT comes with Samba, so unless you’re running a really old version of Samba, you will already have it installed. You can check its availability, though, by using the swat --help
command. You can also use the following commands to find the program:
# whereis swat swat: /usr/sbin/swat /usr/share/man/man8/swat.8.gz # find / -name swat /etc/webmin/samba/swat /etc/xinetd.d/swat /usr/sbin/swat /usr/share/samba/swat
The /usr/sbin/swat file is the SWAT executable program itself. (I’m using openSUSE 10.3. In other distributions you might find SWAT somewhere else.) You will have the (root access only) /etc/webmin/samba/swat file only if you have Webmin installed; this is where Webmin keeps your Samba user and password. Finally, you must edit /etc/xinetd.d/swat so that SWAT will be available through xinetd. Working as root, edit it so it looks like this:
# SWAT is the Samba Web Administration Tool. service swat { port = 901 groups = yes socket_type = stream protocol = tcp wait = no user = root server = /usr/sbin/swat only_from = 127.0.0.1 log_on_failure += USERID disable = no }
Note that in the server
line, I put the path I found earlier with whereis
or find
. It’s likely that the last line will read disable=yes
because many distributions don’t enable SWAT by default. My version of this file was missing the port
and groups
lines, so I had to add them. When you’re done editing the file, run /etc/init.d/xinetd restart
, and SWAT will be ready to work.
Note: On older systems, you might have inetd instead of xinetd; in that case, look for /etc/inetd.conf, which should include an entry like this:
# swat is the Samba Web Administration Tool swat stream tcp nowait.400 root /usr/sbin/swat swat
Use /etc/init.d/inetd restart
to activate your edits.
Using SWAT
SWAT works by rewriting the configuration files at /etc/samba/smb.conf and restarting Samba as needed. Note, however, that when it rewrites the file, it wipes away all comments, so if you’re the kind of sysadmin who likes to include documentation within configuration files, you’ll have a reason to hate SWAT. Unsupported parameters are deleted, parameters that have the default value are ignored, and SWAT changes the order of the parameters, so your carefully handcrafted configuration file may look rather bleak after SWAT is done with it.
Access SWAT by opening a browser and going to http://127.0.0.1:901. The home page provides access to the man documentation pages and some extra Samba documentation, including some complete books. You’ll have to install the samba-doc additional package to get the latter.
Here’s a list of SWAT’s other pages and the functions you can use:
- Globals: Provides access to the global parameters (what else?) in smb.conf. You can work at one of two levels: Basic, which shows only the more important options listed, or Advanced, which shows every available parameter. Click on the corresponding buttons to pick your desired level. You can click on the Help links to get specific help about each parameter. After making any edits, click on Commit Changes to save your choices, or Reset Values to go back to the original smb.conf values.
- Shares: Lets you create, edit, or drop shares. To edit an existing share, pick it from the combo box, then click on Choose Share; clicking on Delete Share will delete it. When you add or edit a share, you can specify several parameters on either Basic or Advanced levels, such as name, path, valid and invalid users, and read-only or writable. Remember to click on Commit Changes (or Reset Values) before changing pages or your work will have been in vain.
- Printers: Similar to Shares, but works with printers instead.
- Wizard: Lets you do a quick server configuration. You can pick either a standalone server, a domain controller, or a domain member. You must also specify how the server will work with Windows Internet Name Service (WINS) and whether you want to expose your home directories. Click on “Rewrite smb.conf” or on Commit to save your values, and you will have a basic Samba server running, which you can then further tweak using the other options.
- Status: Shows you which services are running: usually smbd (the Samba daemon itself) and nmbd (the NetBIOS nameserver support daemon), and possibly Winbind (to allow a Linux box to become a Windows domain member). You also get the listing of all active connections (which you may kill, if you need to), active shares, and open files. You can click on Auto Refresh so the page will refresh on its own every so many seconds (30 by default).
- View: Lets you view the current configuration file. You can click on the View button to see it either in the normal view (minimalist, with only the nondefault attributes) or the full view (with all possible parameters).
- Password: Allows you to create, delete, enable, or disable local Samba users and change passwords for a local or remote server.
Conclusion
Whether you’re just starting out with Samba or are an experimented sysadmin, SWAT can you help you configure your box more easily through its graphical interface.
Categories:
- System Administration
- Internet & WWW