RHEL 6 for the Clueless: Samba File Sharing

By Ed Ed | Posted at 1:53

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 following commands:

mkdir /home/shared
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.

Edit smbusers:

gedit /etc/samba/smbusers

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 same place: /etc/samba/lmhosts. The first line should show: 127.0.0.1 localhost. Add another line below that: 192.168.1.102 hostname.

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.

Then open: /etc/samba/smb.conf. Find the section headed [global]. Change the workgroup name to whatever your Windows computer will be seeking. Default is workgroup in lower case letters. You値l need to remove the semicolon in front of the next line and provide a proper hostname for the netbios 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 two interfaces 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:

[shared]
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.


Re: RHEL 6 for the Clueless: Samba File Sharing

thanks, this worked flawlessly on CentOS 6.2

Posted by fabio - Feb 2, 2012 | 13:54

Re: RHEL 6 for the Clueless: Samba File Sharing

Everything worked - However, there is a problem with the shared directory (not the /home/user directory). I created a group (sambagrp) and added the authorized uses. However, the user cannot create a file or directory in the shared directory unless chown is ran on the directory to replace root with the user (drwxr-xr-x 2 root sambagrp 4096 Jun 10 20:22 sharedir). Is their anyway to make the share directory accessible to any authorized user without having to execute “chown [user] sharedir”?

Posted by Mike - Jun 11, 2012 | 1:54

Re: RHEL 6 for the Clueless: Samba File Sharing

Mike, I don't know of any way around that. Then again, I'm just a duffer who poked and prodded until I got it to work. I'm sure a real technician would have a better answer.

Posted by Ed Hurst - Jun 13, 2012 | 2:04

mp3

This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work.

Posted by mp3 - Jul 1, 2017 | 9:17

Re: RHEL 6 for the Clueless: Samba File Sharing

This was the first time i got to know about your samba here and this update is very good for the users. As i have been surfing for my superiorpapers.com essay writing service works and came through your blog. Keep up the good work.

Posted by Rahel - Jul 3, 2017 | 11:57

bespoke exhibition stands

Extraordinary article Lot's of data to Read…Great Man Keep Posting and redesign to People..Thanks

Posted by bespoke exhibition stands - Jul 3, 2017 | 12:28

research paper

I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job!

Posted by research paper - Jul 4, 2017 | 9:01

how to catch crabs

Much thanks for composing such an intriguing article on this theme. This has truly made me think and I want to peruse more.

Posted by how to catch crabs - Jul 4, 2017 | 9:45

Health Tips

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.

Posted by Health Tips - Jul 5, 2017 | 14:09

Health Tips

That was a wonderful post, I really enjoyed reading the article and have shared the same with my friends, I also follow this amazing health and fitness blog with a lot of informative articles on Health Tips, you can check it right here http://remainhealthy.net

Posted by Health Tips - Jul 8, 2017 | 7:11

Washington dc event photographers

A debt of gratitude is in order for sharing the post.. folks are universes best individual in every existences of individual..they need or must succeed to maintain needs of the gang.

Posted by Washington dc event photographers - Jul 8, 2017 | 9:57

payroll services

I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

Posted by payroll services - Jul 8, 2017 | 11:47

dirty karma

I don’t know what has happened to the custom of delivering consistent good articles. I hope that the custom comes alive after this.. thumbs up for your work.

Posted by dirty karma - Jul 9, 2017 | 11:34

cats astuce

You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site.

Posted by cats astuce - Jul 9, 2017 | 12:11

brawl stars triche

Really great post. I just unearthed your online journal and needed to say that I have truly delighted in perusing your blog entries.

Posted by brawl stars triche - Jul 10, 2017 | 7:06

5 Best Crib Mattress Reviews 2017 – Buyer’s Guide

Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog.


Coupon Codes

without harming your health. unwanted fat by using top and best diet pills

Posted by Coupon Codes - Jul 15, 2017 | 8:04

Re: RHEL 6 for the Clueless: Samba File Sharing

I have tried this method. Fortunately, this step easy to understand so I can use this application easily. Manchester airport taxi quote

Posted by Manchester airport taxi quote - Jul 17, 2017 | 7:24

anti-aging

Much thanks to you a cluster for offering this to every one of us you really acknowledge what you are discussing! Bookmarked.

Posted by anti-aging - Jul 19, 2017 | 9:30

Re: RHEL 6 for the Clueless: Samba File Sharing

Thank you very much for this valuable contribution and informative.

Posted by Latest Cisco 400-101 Dumps - Jul 19, 2017 | 11:40

Re: RHEL 6 for the Clueless: Samba File Sharing

Are the codes can be applied in any version of Windows?
|wrought iron lighting

Posted by Natalie Floyd - Jul 20, 2017 | 13:26

Please enter your comment entry below. Press 'Preview' to see how it will look.

Name:
Sign In to Your Account
User Name:
Password:
Location:
Homepage:
E-mail:
Subject:
:mrgreen: :neutral: :twisted: :arrow: :shock: :smile: :???: :cool: :evil: :grin: :idea: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: :!: :?:
Home About Connect: Twitter Facebook RSS
© 2001-2012 Universal Networks, All Rights Reserved. Some content rights may be held by Universal Networks' providers and used under license. Powered by ServerForest and SAFARI. Learn about our privacy policy here.