In my explorations with RHEL 6, we have come a long way towards a useful computing environment. One piece we have not taken time to explore much, however, is one of the most important for many users: file sharing. If you intend using your RHEL machine to serve files amongst Windows machines, one of the first things you should consider is using Samba.
This is the Open Source implementation of Windows' SMB. Samba allows your RHEL box to provide a compatibility layer so a Windows computer on the same network, such as your home LAN, can read portions of the Linux file system natively. It is also the only way I know you can have Linux operate as a print server for Windows sharing. That is, if you have a printer connected to your RHEL box and working, Samba allows you to provide a Windows computer access, provided that Windows box has its own driver for it.
There seems to be no documentation from Red Hat, and Samba itself offers a huge documentation library because there are too many options for any sane person to examine. There are some items you'll need to prepare before starting: username (so the Windows user can login from their machine), password, and the network IP address on your LAN for the other computer(s), and a shared directory with world write permissions. If a printer is involved, make sure it's setup to share.
RHEL provides a GUI tool for printer setup. If your printer is connected via USB, it should be recognized immediately if RHEL knows what it is. This is the place to check. There isn't space here to chase down all the various problems you might encounter, so if it doesn't pretty much work, and you can't get it recognized and configured through the Administration menu, you'll need to engage your favorite search engine using your printer model with the keyword "linux" or terms like "RHEL" and "Fedora," and make the most of it. In the menu system for the printer configuration tool is a place to checkmark some boxes to share the printer.
I've found a couple of tutorials on Samba, but neither one had all the right information. After fighting with it a bit, this is what I did to get it working.
Install Samba by logging into a Terminal as root:
yum install samba
Create shared directory; I used
/home/shared using the
chmod a+w /home/shared
chcon -t samba_share_t /home/shared
That last line insures the SELinux security system knows to allow outside systems to poke around in that folder. Now anyone using this computer can move files in and out of the folder, as well as the Samba users.
Add a Samba user. This is a different task than simply adding a user account. There is a GUI tool for adding Linux user accounts to the machine for them to use the computer itself. However, Samba users must be handled differently, so that the system forces them to use the Samba server.
useradd -c "Real Name" -d /home/samba-username -s /sbin/nologin samba-username
That's all one line. As usual, substitute the actual Real Name and username in the command above. Then create the Samba password. Remember what we said about coming up with good passwords:
smbpasswd -a samba-username
It will prompt for the password, which you type in blindly:
New SMB password:
Retype new SMB password:
Added user username.
This will open the default text editor. Scan down the file until you see something like this:
root = administrator admin nobody = guest pcguest smbguest
Immediately below this, add a line with this format:
username = samba-username
so RHEL recognizes the person logging in from the Winbox by their
samba-username. Close this file by saving it, then open a file in the
/etc/samba/lmhosts. The first line should show:
127.0.0.1 localhost. Add another line below that:
That is, the IP address on your network of the Windows box, and it's hostname in lower case. If you don't know how to find the IP address on Windows, use these instructions. To get the hostname, try this page from the same site. Save that file.
/etc/samba/smb.conf. Find the section headed
[global]. Change the workgroup name to whatever your
Windows computer will be seeking. Default is
lower case letters. You’ll need to remove the semicolon in front of the
next line and provide a proper hostname for the
name, which would be the name you gave your RHEL computer during
installation, again in lower case. Remove the semicolon from the next
line and the IP address numbers from the sample; all we need are the
lo eth0. Below that is a line with
hostsallow as a model. Below that, start a new line with
the same indentation:
hosts allow = 127. 192.168.1.
The "127." is the IP address for everything on your own machine. The other (192.168.1.) is the private LAN network I use for my home router; by leaving off the last section after the dot, it automatically includes every computer with that prefix, which is reserved for LANs.
Go all the way to the bottom of the file and add some lines. I named my shared directory "shared." Thus, the section heading should be named the same:
path = /home/shared
writeable = yes
browseable = yes
read only = No
guest ok = Yes
public = Yes
create mask = 0666
directory mask = 0777
Now change the firewall to allow Samba to get through. You can use the tool in System > Administration > Firewall. Simply scan down the list to Samba and checkmark the box. Optionally checkmark IPP printer sharing. Then hit "Apply." Now we start the service manually; it's actually two services:
/sbin/service smb start
/sbin/service nmb start
Test whether your Windows box can find the server. In Win7 and Vista, that's via your file manager window. On the left hand side look for the Network icon. Double click to open and the computer should search for other machines. Your RHEL box should eventually show up by it's hostname. Double click and see if you can login from there. If successful, your shared folder and any printer you've permitted will also show.
For XP and Win2K, it's a similar idea using the file manager. The simplest way is to right-click on "My Computer" and select "Explore" so that the left pane shows the various drives, and should display a network connection to the RHEL server.
If it works and you don't have to cry for help, you'll want to make it a normal service always running. System > Administration > Services -- find "nmb" and "smb" and click the "Enable" button. From now on, upon boot the system will start the two services automatically.
Ed Hurst is Associate Editor of Open for Business.