Linux

How do I quickly share Linux directories with a Windows network?

Jack Wallen walks you through the process of setting up a share on your Linux desktop so that all the machines on your network can access it.

So you broke down and finally set up a Linux machine on your network. And this time it's not a server! You're running one of the more recent distributions (let's say either Ubuntu 10.04 or Fedora 13) with the GNOME desktop. Here's the thing: you need to allow other users, those using Microsoft Windows-based machines, to have access to specific directories on that Linux box. How do you do it?

Believe it or not -- it's very simple, and you won't have to edit a single line of a Samba configuration file in order to get it working. This simplified process may come as a surprise to anyone who has tried to share a Linux directory on a Windows network in the past. Instead of having to weed through the smb.conf file as before, everything is done from within the GUI.

In this How do I tutorial, I walk you through the process of setting up a shared directory on your Linux desktop so that all the machines on your network can access it.

This blog post is also available in PDF format in a TechRepublic download.

Prerequisites

You might be surprised to find out that once you have the desktop operating system installed, you have everything you need to begin this process. During the process, there may be (depending on your current installation) a dependency to be installed, but this will happen automatically when you start the set-up process. Outside of that, you will need the other machines connected to the same network. Those machines can be a part of either a domain or a workgroup -- it really doesn't matter.

Step 1

The first step (after you have decided what directory you are planning to share) is to open the Nautilus file manager, right-click on the directory to be shared, and select the Sharing Options entry. When you do this, a new window will open (Figure A) where you will enable the sharing of said folder.

Figure A

The first step is to check the Share This Folder checkbox.

If your system does not have all the requisite software, you will be walked through this process.

Step 2

If necessary, you will need to install the service (Samba) in charge of sharing your folders. Figure B shows the window that will warn you that not all dependencies are met.

Figure B

Once you click Install Service, you will have to enter an administrative password. If you are using an Ubuntu-like distribution (that uses sudo), just enter your user password.

Step 3

Once the service is installed, you will be taken back to the properties window where you can give the share a name and a description as well as select the options for the share. If you want to give read/write access for this folder, make sure the first option is checked. If you want guest access (access for those without an account on the machine sharing the folder), make sure the second option is checked.

After you are satisfied with the configuration, click the Create Share button.

Step 4

If you have enabled a feature requiring permission changes, you will need to let the Wizard automatically change the permissions for the share. Figure C shows the warning you will get for this step.

Figure C

If you do not allow the wizard to set these permissions, you will have to go back and manually set them. Make sure you do not skip this step.

Step 5

Once the service is installed, you have to restart Nautilus. Fortunately the Wizard will do this for you. As you can see in Figure D, the restarting of Nautilus is merely the click of a button. If by chance the window with the restart button does not appear, you can restart Nautilus by either issuing the command killall -9 nautilus or just logging out and logging back in.

Figure D

The restarting of Nautilus will be necessary only after the first share is set up. After that, Nautilus will not have to be restarted.

Step 6

You are now ready to test your shared directory. This is very simple. Go to one of your Windows machines and follow these steps:

1.               Open up Explorer.

2.               Enter \\IP_ADDRESS_TO_SHARE.

3.               Depending on how you have this set up, you might have to enter a username and password.

If there were no problems, you will now have access to your Linux shares from your Windows machine.

If you are attempting to reach that same Linux share from an OSX machine, do the following:

1.               Open Finder.

2.               Click <Apple>k.

3.               Enter smb://IP_ADDRESS_TO_SHARE.

4.               In the new window, enter the username/password (if necessary) for the share.

That's it! You now have access to your Linux share from your OSX machine.

Final thoughts

At one point it was a real challenge to get Windows machines to see shared files and directories on a Linux machine. Manually editing the smb.conf file required a much higher level of knowledge than what is required now. Thanks to the latest releases of major players in the Linux desktop and distribution landscape everything has become far more user friendly.

Stay on top of the latest Microsoft Windows tips and tricks with TechRepublic's Windows Desktop newsletter, delivered every Monday and Thursday. Automatically sign up today!

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

23 comments
rjkothari
rjkothari

Ubuntu 9.10 desktop is allowing me to access the files on Windows partition by just double clicking windows partition in Nautilus. Conversely, how do I access files in my user folders of Ubuntu partition e.g., 'Documents' etc from within Windows XP?

wfairley
wfairley

Jack, thank you for your steady stream of how-to blog posts. How does the recently discovered dll exploit factor into this one? If I understand correctly, the dll exploit uses smb ports 135-139 and 145, and the "patch" is to firewall those ports. Here is a blog request: are there alternatives to Active Directory? I am particularly interested in open-source alternatives. Woody Fairley CCNA, MCITP, CCP

mike.walsh
mike.walsh

I have two machines running Linux. One is a Fedora 13 installation, the other is Ubuntu 10.04. Both run Nautilus 2.30.1. Both are up-to-date with Automatic updates, as of Sept 7th. When I right-click on a folder on the Ubuntu machine I see an option for Sharing, just under the "Send to ..." option. But the Fedora machine does not show the Sharing option. Instead it has an option to "Revert to Previous Version ..." just above the "Compress" option, but no Sharing options. I am trying hard to like Linux, but ...

Justin James
Justin James

Jack - Next time, please use a different theme or something, because those screenshots are really hard to read. I don't know if that's just a transparent window (if so, use a solid color background) or a skinned window (if so, don't use the skin) or what. But it really hurts the eyes to see these screenshots. J.Ja

CassidyJames
CassidyJames

That theme is... terrible! It makes things very difficult to read and kinda gives Linux a bad look. You couldn't have used a default (or more standard) theme when taking screenshots?

Mark W. Kaelin
Mark W. Kaelin

Do you have a network that serves several different operating systems? Is managing a mixed environment getting better or worse as technology allows for more integration?

marcdw
marcdw

Neon's advice is the way to go regarding a dedicated partition for sharing (something I should've done with my XP/OpenSolaris combo where OpenSolaris reads FAT32 just fine but ntfs is another problem). Don't know what filesystem your Ubuntu is using but two old tools might help. Explore2fs reads ext2/ext3 and the newer Virtual Volumes has some read/write capabilities for other filesystems including reiserfs. VV is beta so use at your risk if thinking about writing to the Linux side. On my old ThinkPad with XP and Slackware Explore2fs has come in handy a time or two when I forgot to transfer a file I needed from the Linux side to a shared NAS. Direct access to the Linux file from Windows saved a lot of extra steps. Marc

Neon Samurai
Neon Samurai

It sounds like your trying to share between two OS on the same hard drive. WinXP doesn't like to read non-Windows partitions. If your rebuilding the system, consider cutting a large win32 partition. Both the Linux distro and Windows versions will be able to read/write it so you can share things between boots on the same machine. alternatively, get an external hard drive that's fat32 or such.

marcdw
marcdw

If I remember correctly the dll exploit article mentions firewalling the ports both internally (software) or externally (hardware firewall/router). I suppose blocking the ports on the hardware would (should?) not impact smb activity on the internal network. I've made the changes on the router but haven't tested anything yet. Marc

Neon Samurai
Neon Samurai

I kid.. mostly.. as a client *nix does not appear affected by the dll issue. Connect into the network share, fetch your file and at worst, you'll be an immune carrier. As a host, the *nix side can pass on files crafted to exploit the dll vulnerability. The module for Metasploit generates the file with exploit code then presents an adhoc SMB/CIFS/Samba share to the network. If the target Windows machine can see the share and read the file from it; hwammo, your in. The DLL issue does not affect *nix (being non-DLL based) but *nix can pass on malicious files which will affect the unpatched Windows systems. That's my current understanding anyhow.

mtrifiro
mtrifiro

Have same Fedora 13 experience; sharing is no doubt possible but not intuitive by any means.

Duggeek
Duggeek

I'm going to believe that it was semi-transparent windows over a wallpaper image. Hardly professional. Us readers don't need to see what the author chose for a desktop background, we need to see the dialogs in their default decorations! @Jack: Save your customized theme for when you use the desktop on your own time. The next Linux article you write, use screenshots from a dummy-user/LiveCD session instead, K?

Jaqui
Jaqui

the Crystal theme. That seems to be a favourite among distros for default theme currently. and you are right, a completely unusable theme. I would actually go with an older, unthemed look for ease of reading, but that would kill the "eye candy" that so many idiots think means usability.

mckinnej
mckinnej

Got anything similar for KDE or are we still stuck with tinkering in smb.conf?

ludedude1975
ludedude1975

I'd like to see an easy way to get linux to see windows shares. So far the only way I can get Ubuntu to view my windows machine is to manually type in smb my windows computer's IP address and shared folders name. I've never been able to get their Network Search to work correctly.

zefficace
zefficace

But it seems I'm not the only one that thinks "aero" or "compiz" are not that great and brings nothing. Eye pleasing colors is fine, I get that. But a pc has to be functionnal, not cute. If no "function" is afforded by a "feature", then the "feature" is a bad joke, just like the screen shots here.

Jaqui
Jaqui

in kde. t least it was in KDE3.x if you had installed and configured samba already then it was just a click in Konq to share a folder.

pgit
pgit

KDE has zeroconfig networking that works pretty well. The samba tools have never worked for me. Most distributions provide some GUI for simple file sharing. But the best, most comprehensive way to do this in any desktop environment is with webmin. Webmin won't install anything you may need, eg samba-server. But manually install it first, then webmin takes it from there. Mandriva (just an example) does provide a GUI to set up a simple share, that will install missing packages. Most distros are moving toward providing a quick setup tool with a UI. I still find webmin the way to go.

mike.walsh
mike.walsh

Use Nautilus, and make sure Side Pane is ticked in the View option. Then I clicked Places > Network (in side pane) > Windows Network > WALSH (my Workgroup name) > Magpie (another computer's name. And the files are all immediately accessible. That is very easy (and it has been very easy for many years with Red Hat's distributions.)

Jaqui
Jaqui

with Mandriva's DrakXtools running the access windows shared files and folders wizard makes it a one shot task. [ PCLinuxOS and Mandriva so far only distros using these wizard scripts ] it finds all windows hosted shares available and lets you set mount points for them to automatically have access at every system boot. not to sure what steps are involved with distros that don't have the tools to make life easy. :p

Jaqui
Jaqui

to find someone else more interested in performance than looks :D

Neon Samurai
Neon Samurai

If it's not a quick ad-hoc share, Webmin is great for setup. Debian + Webmin turn old hardware into a very slick NAS.