December 2006


Samba Configuration with SWAT Then locate and select the service called xinetd, and click Restart. You’ll get a dialog to confirm that the restart was successful; then you can exit the tool by clicking on Quit. Using SWAT for the First Time Now we can test SWAT. Open a browser on the Linux server and type in the URL http://localhost:901. You’ll be prompted for a username and password - use the system’s root username and password. Then you should see the SWAT HOME page: Note that this page contains the index of Samba’s very comprehensive online documentation (as shown above), where you can find out much more about Samba and SWAT. There are also eight buttons listed across the top of this page, which provide access to SWAT’s various utilities: HOME - the home page of SWAT, and the first page that you see when you fire up the SWAT interface. GLOBALS - for setting the global variable values of the /etc/samba/smb.conf configuration file SHARES - for creating and deleting Samba shares, and setting Samba parameters 297
Hint: If you are looking for good and high quality web space to host and run your java application check Vision java web hosting services

Samba Configuration with SWAT Preparing… ########################################### [100%] 1: samba-swat ########################################### [100%] Note Alternatively, view the available package files on your disk by using the Nautilus file manager GUI to navigate to /mnt/cdrom/Redhat/RPMS. Locate the file matching the name samba-swat-*.rpm. Double-click on this file - this action will open RPM GUI tool, from which you can install the package. Starting the SWAT Service Starting the SWAT service is a two step process: 1. Launch gedit or your favorite text editor, and open the file /etc/xinetd.d/swat. This is the configuration file for the SWAT service, and it looks like this: # default: off # description: SWAT is the Samba Web Admin Tool. Use swat # to configure your Samba server. To use SWAT, # connect to port 901 with your favorite web browser. service swat { port = 901 socket_type = stream wait = no only_from = 127.0.0.1 user = root server = /usr/sbin/swat log_on_failure += USERID disable = yes } Change disable value, like this: disable = no Save the file, and close your text editor. Note As an aside, note that this default configuration ensures that the SWAT service will only be accessible through the IP address 127.0.0.1, and on port 901. The IP address 127.0.0.1 is a special address known as the loopback address, because requests to http://127.0.0.1 are sent to the web server on the same machine as the browser from which the request is made. Hence, by default, SWAT is only available from the file server machine itself - via http://127.0.0.1:901 or http://localhost:901 (as we mentioned earlier in the chapter). 2. Restart the xinetd service. (We must do this because SWAT runs as an xinetd service. The xinetd service is out of scope of this book, but it is enough to know that its purpose is to support Internet services such as SWAT). To do this, first launch the Service Configuration GUI tool by selecting Main Menu | System Settings | Server Settings | Services: 296
Hint: If you are looking for good and high quality web space to host and run your java application check Vision java web hosting services

Samba Configuration with SWAT Samba Configuration with SWAT If you open the Sarnba configuration files using gedit (or any text editor), you’ll see that the information and syntax used is rather complex. It is possible to configure Samba by editing these files in a text editor, but if you’re not familiar with it then it can be quite difficult and prone to error. Samba provides a number of command-line utilities for configuration too (some of which we mentioned above), but perhaps the easiest way to configure Samba is by using the Samba Web Administration Tool (SWAT). SWAT is a web-based interface, which means that you can use it to configure and manage your Samba server through a web browser - if you want, you can even do it remotely across a network or even across the Internet. Note If you are thinking of using SWAT for remote Samba management, you should note that SWAT will transmit your username and password in clear text when you log in. Across and insecure connection, this presents the risk that an unwelcome visitor could sniff out your login credentials and use them to ill effect. To avoid this, you should only use SWAT from within a secure network. In fact, as we’ll see shortly, SWAT’s default configuration makes it available only at http://localhost:901. Let’s see how to install SWAT and start the SWAT service. When we’ve done that, we’ll be ready to use SWAT to configure Samba and set up our file server for use. Installing SWAT Red Hat Linux 9’s Package Management GUI tool doesn’t provide an option for installing the SWAT package. Instead, we must install this package via the RPM’s command line utility, the SWAT utility is made available through the samba-swat package. Here’s how to install the samba-swat package at the command line: 1. Launch a terminal window, and switch to the root user account by using this command: $ su - 2. Insert Red Hat Linux 9 distribution Disk 2. Change to the directory on the CD that contains the RPM package files: # cd /mnt/cdrom/RedHat/RPMS Note If you get a No such file or directory message, it’s probably because the CD wasn’t mounted automatically when you inserted it. In this case, mount the CD manually: # mount /dev/cdrom Then try the above cd command again. 3. Use the ls command to find out the exact version of samba-swat contained on the disk. For example: # ls samba-swat*.rpm samba-swat-2.2.7a-6.i386.rpm If this command doesn’t find any matches, then remove the disk, replace it with Disk 1 or Disk 2, and return to Step 2. 4. Install the samba-swat package you’ve just found, by using the rpm command: # rpm -ivh samba-swat-2.2.7a-6.i386.rpm 295
Quick Hint: If you are looking for cheap and reliable provider to host and run your servlet application check Vision servlet hosting plans

An Overview of Samba # service smb stop Shutting down SMB services: [ OK ] Shutting down NMB services: [ OK ] You get the idea. Note, however, that this script only allows you to control the service manually. It doesn’t allow you to configure the service to start automatically on boot-up - for that, you need the Service Configuration GUI that we described above. Samba Configuration Files and Utilities We won’t take a look at every single item that is installed during the process described above, but it is worth pointing out some of the most important files, both to get an idea of Samba’s capabilities and because we’ll be using some of these files and programs later in this section. Specifically of interest to us here are Samba’s configuration files and programs. Samba’s configuration files are contained in the directory /etc/samba. Here’s a brief description of the the Samba configuration files that you’ll find there: Configuration File Description smb.conf This is the main configuration file for Samba. lmhosts This contains Samba’s NetBIOS-to-IP address mappings. secrets.tdb This is the Samba secrets database. It stores private information such as the local SID and machine trust password. It is generated by machine and cannot be read in a text editor. smbusers This is a text file that maps your Linux system’s users to various SMB-specific usernames. smbpasswd This is an encrypted password file. The format of this file is very similar to that of the passwd file we met in Chapter 8. This file doesn’t exist when you first install Samba, but is created when you add Samba users. In order to work with file servers through Samba, we can use its many programs. Here’s a list of some of the most important utilities provided by Samba. They’re all contained in the directory /usr/bin, and we’ll be using some of them later in this section: Program Purpose smbclient This is an FTP-like client, used to access SMB/CIFS resources on a file server. smbadduser This is a script, used for adding Samba users. It updates the smbusers and smbpasswd files. smbpasswd This changes a Samba user’s SMB password. It is similar to the Unix passwd command that we met in Chapter 8. smbmount This is used to mount an SMB filesystem. smbumount This is used to unmount an SMB file system. smbstatus This lists the current Samba connections. testparm This checks the smb.conf configuration file for correctness. nmblookup This is used to query NetBIOS names and map them to IP addresses in a network using NetBIOS over TCP/IP. In addition, we’ll also make use of the script /etc/rc.d/init.d/smb, which we use to start and stop the Samba file service. 294
Quick Hint: If you are looking for cheap and reliable provider to host and run your servlet application check Vision servlet hosting plans

An Overview of Samba As you can see, there are two standard packages: samba and samba-client. Click on Close, and then click on Update to start the installation. You’ll need the disk from your Red Hat Linux 9 distribution to complete the installation. Starting and Stopping the Samba Service As with other services we’ve seen, there are a number of ways to start and stop the Samba service. Once again, we can do so via the Service Configuration GUI tool. To launch the tool, select Main Menu | System Settings | Server Settings | Services or type the following command at the command line: $ redhat-config-services Then locate the smb service, as shown here: If the service is stopped (as shown here), then start it by clicking the Start button. It’s also a good idea to check the checkbox, to configure the samba service to start automatically whenever you boot up the system. For example, if you ever have to perform an emergency reboot on your file server, then the “automatic start” configuration means that the file server is immediately available to users after the reboot. When you’ve done this, select File | Save Changes to save your new setting. Alternatively, you can also stop and start smb service at the command line, using the service command to run the /etc/rc.d/init.d/smb script we mentioned earlier. Typing the script name at the command line like this reveals the possible usages: # service smb Usage: /etc/rc.d/smb {start|stop|restart|reload]status|condrestart} As you can see, it works in much the same way as the httpd and vsftpd scripts we’ve seen in earlier sections of this chapter. So, to start the service we’d type this: # service smb start Starting SMB services: [ OK ] Starting NMB services: [ OK ] This command starts both SMB and NMB (NetBIOS name server), which are both services related to Samba. To stop the service, we’d type this: 293

Hint: This post is supported by Gama web hosting php mysql provider

An Overview of Samba Note For more information on the others, see http://www.nfsv4.org, http://www.transarc.com/Product/EFS/AFS/index.html, and http://www.coda.cs.cmu.edu. An Overview of Samba Samba is an implementation of the Windows SMB and CIFS protocols on Unix. The Samba project was started by Andrew Tridgell, who wanted to mount his Unix server disk space onto a DOS PC. When he’d solved the problem, Tridgell discovered that what he’d built was an implementation of the SMB (server message block) protocol - a protocol for sharing files and other resources. Tridgell named his implementation Samba, and published version 1.0 in early 1992. Since that time, the Samba project has grown tremendously, and today there is still Samba development going on in the open source community. So, Samba is a collection of programs that make it possible to share files and printers between computers equipped to use the SMB protocol - Windows by default, Linux/Unix with Samba, and (more recently) Mac OS X. Samba is freely available under GNU General Public License, and is included as part of the Red Hat Linux 9 distribution. In this section we’ll take a look at how to install Samba, perform some basic configuration, and set up a shared file server on a Linux machine. We’ll also see how to use Samba to access a Linux-hosted file server from a Linux or Windows machine, and how to access a Windows-hosted file server from a Linux machine. There should be enough in this section to get you started working with file servers in Linux. If you want to explore further with SMB and Samba, try http://www.samba.org (and specifically http://www.samba.org/cifs/docs/what-is-smb.html). Installing SAMBA Again, perhaps the easiest way to install the Samba software suite is via the RPM GUI tool. Once you’ve started the RPM (for example, by selecting Main Menu | System Settings | Add/Remove Applications), use the Package Management dialog to locate the Windows File Server package group (which you will find under the Servers category). Ensure its checkbox is checked. If you like, click on its Details button to see the package details: 292

Hint: This post is supported by Gama web hosting php mysql provider

Setting up a File Server 1st kapils 2 (stdid) 5761024 bytes 2nd eziodm 3 (stdid) 193536 bytes 3rd eziodm 3 addresses.txt 1024 bytes If we want to cancel a print job, we can use the lprm command. For example, to remove the job with ID 838 from the print queue, we can issue the following command: # lprm 838 Of course, if you try to cancel another user’s print job, and you don’t have permission to do so, then CUPS will prevent you from canceling it. For example, suppose the user eziodm tried to cancel job 2 in the list above: # lprm 2 lprm: You don’t own job ID 2! Note You can learn more about the CUPS printing system at http://..cups.org/. Setting up a File Server A file server is essentially a shared storage space. File servers are generally accessed across a network, and provide its users with a central location for file storage. File systems are also helpful when you need to share files with other users: you can simply place your file in a public directory on the file server, where other users can access it. Like FTP servers, there are essentially two fundamental components to a file server - the storage space itself and the mechanism for accessing it. Whether you’re working on a single machine at home, or as part of a large network in a major organization, you’ll be using a file system to store your files; what a file server adds to this is the notion that the file system is a shared one, accessible by (possibly) many users. There are a number of benefits to be gained by implementing a file server: It reduces administration cost. Instead of having important data stored on many individual PCs (all of which would require backing up), you can store all your important data in one place (on the file server). Then, only the file server needs regular backing up. It provides the opportunity to enforce a more controlled and focused security policy, because the security policy needs only to be applied to the file server. It enables you to provide a more stable and reliable storage solution. It enables you to implement your storage solution on high-spec machines that provide high levels of uptime. Moreover, implementation of RAID or of mirrored SCSI disks (which help ensure data reliability) is more feasible on a central file server than on many PCs. There’s also something to be gained in terms of cost of file storage (although this is less pertinent in these days of cheap storage). First, it makes best use of the available storage capacity by making it accessible to all users. Second, it provides a central repository from which common resources can be made available to all (eliminating the need for each user to store their own copy). Once you’ve got a file system, what makes it a file server is the mechanism that enables the file system to be shared. There is plenty of software around for this purpose - Samba, the Network File System (NFS), the Andrew file system (AFS), and Coda are all examples. Some of these are shipped as part of the Red Hat Linux 9 distribution, and we’re going to focus on one in particular - Samba. 291

Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Sandzak.com java web hosting provider

Print Servers on Redhat Linux 9 As you can see, the application offers you a list of printers to choose from - the list shown above includes an entry for the prntr_queue-1 printer that we configured earlier. It also includes a Generic Printer entry - if you choose this, then the application will send the print job to your “default” printer (the one that your machine is configured to use automatically). You’ll need to configure the “default” printer before you use if for the first time; you can do this through the Openoffice Printer Setup tool. Select Main Menu | Office | Openoffice.org Printer Setup, select the Generic Printer entry in that dialog, and click the Properties button: In the resulting Properties of Generic Printer dialog, the default command in the Select Command section is lpr - this will send printer jobs via the lpr command to /dev/lp0 as the default print queue. Change the command to lpr -P printername, where printername is the name you gave to your printer. Then click OK to save these settings. Now you can return to your OpenWriter application, select File | Print, and select the Generic Printer option in the Print dialog to send the job to that printer. Creating Print Jobs at the Command Line The lpr utility that we’ve just seen can also be used to create print requests from command line. For example, if you want to print a text document called addreses.txt, contained in the present working directory, you can do so by typing the following at the command line: $ lpr addreses.txt We can also examine and control existing print jobs via the lpq and lprm command line utilities of the CUPS software suite. The lpq command allows us to view the contents of the print queue, and can be used as follows: $ lpq ptntr queue-1 is ready and printing Rank Owner Job File(s) Total Size active root 1 testprint.ps 15630 bytes 290

Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Sandzak.com java web hosting provider

Print Servers on Redhat Linux 9 Clicking Yes will save the configuration changes to the /etc/printcap configuration file, restart the lpd printer daemon, and print a test page: Configuring Printers The Printer Configuration provides a number of options for managing printers. For example, you can edit or remove the properties of a printer queue by selecting the queue and clicking Edit or Delete. You can also configure a particular printer to be the default by clicking on the Default button. Whenever you make any changes, you must save them by clicking on the Apply button (which also restarts the cupsd printer daemon to take account of your changes). You can also test a printer from the Printer Configuration tool, by choosing a printer and selecting any of the test configurations from the Test menu. Starting (and Stopping) the Printer Daemon To control the cupsd printer daemon, we can once again use the Service Configuration GUI. However, you may never need to do this manually - the service is configured to start automatically on system start-up by default, and restarts automatically if you change its configuration via the Printer Configuration tool. If you do need to control the service manually, you can do it using the Service Configuration GUI (as we’ve described in other sections of this chapter - the service in question is called cups), or by using the service command at the command line to control the cups script: # service cups Usage: cupsd {start|stop|restart|condrestart|reload|status} # service cups restart Stopping cups: Starting cups: [OK] [OK] Printing from Applications By default, all applications send printing requests to the default printer configured on the system; but of course, if there are more printers available then the application’s Print dialog allows you to choose which print queue to send the job to. For example, if you’re printing a word-processed document from OpenOffice’s OpenWriter application, then you’d do so by selecting its File | Print option from the menu bar. When you do that, you get a Print dialog like this: 289
Quick Hint: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

Print Servers on Redhat Linux 9 name for the printer (for example, something like prntr_queue-1). If you want, you can also type a description, which will help you to identify the printer. Click Forward. 4. The next screen allows you to choose the queue type from the following options: Label Type Description Locally-connected LOCAL For a printer attached directly to your computer through a parallel or USB port Networked CUPS IPP For a printer attached to a different CUPS system and accessible through TCP/IP Networked Unix LPD For a printer attached to a remote Unix system and accessible through TCP/IP Networked Windows SMB For a printer attached to a remote Windows system and accessible through a Samba share Networked Novell NCP For a printer attached to a remote Novell Netware system Networked JetDirect JETDIRECT For a printer connected directly to the network with its own IP address In this demonstration, we’ll demonstrate the LOCAL queue type. If you have a locally-connected printer, select Locally-connected, and select a device from the list (such as /dev/lp0). Then click Forward. Note If you have a networked computer, select one of the other options and follow the wizard to complete the configuration. 5. Next, you’ll be prompted to select the make and model of your printer. When you’ve done that, click Forward, and the wizard will confirm the details you’ve selected. 6. The new printer will now appear in the printer list in the main window. You’ll also see the following dialog: 288
Quick Hint: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

Next Page »