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

Re: RHEL 6 for the Clueless: Samba File Sharing

Has something been changed with the implementation of Windows 10? I want guys to make my thesis on the safest way of sharing files in computing environment. Regular cloud storage doesn't look safe from my perspective.

Posted by Noah - Nov 23, 2016 | 8:31

Re: RHEL 6 for the Clueless: Samba File Sharing

The samba (document sharing) subsystem on Ubuntu utilizes diverse login certifications than the standard login. explainer video pricing. What you have to do is utilize the program “smbpasswd” to include/change your samba (record sharing) secret word.

Posted by Celine Isai - Jan 19, 2017 | 6:29

Re: RHEL 6 for the Clueless: Samba File Sharing

New release of Samba has helped users to share their data in quick possible time, file is divided in different parts at same time. Suppose if you are a writer and working for custom writing service then you would be pleased to know when you find quality article from where you get information.

Posted by patris - Jan 23, 2017 | 20:27

Re: RHEL 6 for the Clueless: Samba File Sharing

This is the website that i had been always looking for when i need the gta money and rp and it is always a lot helpful.

Posted by gta 5 online money generator - Jan 30, 2017 | 5:59

Re: RHEL 6 for the Clueless: Samba File Sharing

Thanks for the steam wallet The key are equally important steam wallet codes.

Posted by free steam gift cards - Feb 13, 2017 | 1:40

Re: RHEL 6 for the Clueless: Samba File Sharing

RHEL provides a lot of useful features other than those provided within the similar applications. This is a nice tool to have which provides a very useful computing environment. I think this latest tool will provide a lot of assistance to the professionals.

Posted by manufactured homes prices - Feb 25, 2017 | 8:29

Re: RHEL 6 for the Clueless: Samba File Sharing

Thanks for this article. Great work. Good effort to complete this. Brilliant.

Posted by Buy Original Research Papers - Mar 10, 2017 | 18:55

Re: RHEL 6 for the Clueless: Samba File Sharing

Thanks for this great article. Very helpful. Providing a great help to get a bright future for the present generation. Great work.

Posted by Research Paper Writing - Mar 11, 2017 | 3:46

Re: RHEL 6 for the Clueless: Samba File Sharing

Microsoft outlook is one the emailing services and millions of people over the world use this to complete emailing requirements. But, technical issues are not avoidable of this service such as emails take too long to go or login issue. At this time you should talk to the technicians of Outlook Contact Number UK. They will give you the straight resolution of issue that you face within a couple of minutes that you need.

Posted by Rose Bronwen - Mar 20, 2017 | 10:19

Re: RHEL 6 for the Clueless: Samba File Sharing

I like this a lot. Thank you for sharing. I’m always looking for upcycles like this. In the end, you don’t know it was a shipping pallet to begin with!

Posted by happy wheels - Mar 23, 2017 | 8:34

Re: RHEL 6 for the Clueless: Samba File Sharing
Posted by ramukaka123 - Mar 25, 2017 | 11:07

Re: RHEL 6 for the Clueless: Samba File Sharing

I have gone through your post and came to know about Samba file sharing. I would like to know more on this topic. Hope you will update more information as soon as possible. I am eagerly waiting for your updated post to get more details. jewish wedding planner

Posted by Alitta - Mar 30, 2017 | 12:07

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.