HOME      Other material for programmers   Pi? Arduino? Other?
(Parent page for this and other small getting started with Raspberry Pi tutorials)

I have notes for translators, if you would add a translation.

File sharing across LAN for Raspberry Pi

filename: pt0FirstFileShare.htm

You don't need to be able to do this... but it is a very useful feature that is easy to set up.

Suppose you have two or more computers on one LAN.

Wouldn't it be nice if "computer A" could read files which are on "computer B"?

Well... Sometimes. Some files. But if you "open that door", wouldn't it be a great gift to hackers, should they ever get into your system? Anyway, what would it be good for?

The answers to those questions: "Yes, but..." and "I'll tell you..."

Gift to hackers? Degrades system security?

Yes... if every computer on the LAN could read and write (and execute and delete) every file and folder on every other computer on the LAN, then yes, setting up file sharing would be reckless.

But you can set up limited file sharing, giving you a useful tool, without "opening too many doors".

Most of the guides I've found on the internet allow you to open more doors than I've ever found necessary. I've been using file sharing for decades... in a more limited way, and found it met all my wants admirably. And I'll show you how to set up the limited sharing that I like.

What's file sharing good for?

I set up a folder on each PC called something like "LANsneaker", a nod to the old term "sneakernet".

There was a time, Elizabeth, when we didn't have LANs. If you had some text on computer A that you wanted to incorporate in something on computer B, then

Now that we have filesharing across LANs, I do the same thing, except "the floppy" has been replaced by a folder on computer A called LANsneakerFromA. The user on computer A has full read/write/etc access to that folder. The user on computer B only has read things from that folder. (This locks down the security a bit, and also helps me avoid getting confused, and getting two editing sessions going (one on "A", one on "B"), and creating two versions of any file which "are" both on the same disk, under the same name. A bad situation to get into!

How to do LAN file sharing between Pi's and other computers

The standard tool for file sharing... and I believe it has a role in printer sharing, too, but I haven't got that far yet... is "Samba".

When I first started to explore this, August 2018, Raspberry Pi 3 B +, Raspbian 9 ("Stretch"), there were things that made me think that perhaps my Pi already had Samba installed, set up.

I already had the following folder, for instance:


Also, I could use the GUI's File Manager "Go/ Network", and drill down in that some way towards seeing things in the Windows workgroup present on my LAN. There was even a promising "smb" in the file manager's address bar, presumably something to do with Samba. There were also mentions on the internet of some Samba features being part of the basic standard.

Whatever I may or may not have been able to do with my basic Raspbian, I eventually decided that for what I wanted, an install was necessary. I got no result from sudo smbstatus before I'd done the install. Got lots of stuff (Version ID, etc) from it after I'd done the install.

Do an install

So... if you want even the simple but very useful "LANsneakernet" file sharing, proceed as follows.

This is shamelessly cloned from the excellent https://raspberrypihq.com/how-to-share-a-folder-with-a-windows-computer-from-a-raspberry-pi/.. but does have differences, to create the more "locked down" version that suits me. It also addresses some things not mentioned in the original. And mentions some "everyone knows" stuff that a new user might not know.

Go into the CLI. Do the usual sudo apt-get update / sudo apt-get upgrade, then start the Samba install with...

sudo apt-get install samba samba-common-bin

Assuming that completes without issues, you've made a good start. Now there is some configuring to do.

"One time" setting up"

Assuming you want my "locked down", "simple" filesharing...

Create a folder in your part of the file system which will be the one that others on the LAN can read, but not write to.

Assuming you are using the default user, "pi", you would create something like /home/pi/documents/LANsneakernet. (You might prefer to make it /home/pi/LANsneakernet... i.e. one "level" higher.) You can do this folder creating either with the CLI, or with the File Manager, under the GUI, as you like.

Before you start the next step, make a copy of /etc/samba/smb.conf. Something like /etc/samba/smb-as in original install.conf would be a good name to store it under.

Next, carefully edit the configuration file, /etc/samba/smb.conf


First find the...


... line. Assuming that the other computers on your LAN are Windows machines, and that you use the default workgroup name, you would make that line...


In Linux generally, case is important, remember.

(If you use Macs, I don't know what they call their workgroup. But in any case, I would suggest you use a non-standard workgroup name... one more nuisance for Bad Guys probing your system. Not a great barrier, but any little bit may help.)

Wins Support

Find the...

Windows Internet Name Serving Support Section

Create the following line within that...

wins support=yes

There are a bunch of other things that seem similar, but apparently we don't need to tweak those.

"Tweaks" done... now the heavy lifting...

We've done some small (but no less critical) tweaks to /etc/samba/smb.conf

Now we have to do some "heavy lifting". We're going to add a whole new section to it. What we add will create a "new share". You will need to add something like the following down at the bottom of your existing /etc/samba/smb.conf in a moment. But don't start yet.

Nota bene: Do not include the line numbers I've put on the following in what you add to your smb.conf. I've only put them there so that I can refer to certain lines in a moment.

Where you see a word inside double brackets, like "name" and "date" in line 2, you replace it, and the double brackets with what the word indicated.

   1. [PiShare]
   2. #Section added by ((name)) on ((date))
   3. comment=Share for Raspberry Pi by ((name)) from ((date))
   4. path=/home/pi/Documents/LANsneakernet
   5. browsable=yes
   6. writeable=no
   7. only guest=no
   8. create mask 0777
   9. direct mask 0777
  10. public=no

Remember... THAT is not what you append to your smb.conf file. But we're working towards what you do append.

Line 1: This gives the share a name. It should not repeat any name already present in the config file we are working on. (smb.conf) I suspect it needs to be quite short, and not have spaces in it.

Line 2: Any line starting "#" in this config file... and indeed in many config files... is "just" a comment. But comments are IMPORTANT. Replace "((name))" with your name or initials, if they are distinctive, and "(date))" with the date you added this section to the config file.

Line 3: I believe this comment will be listed in some contexts when you ask for information about the share you created. I don't think it otherwise affects the behavior of the share.

Line 4: Path: Here you give the path of the folder you created earlier, the (one) folder that will be visible across the LAN, for read only access. (Note what I said before: Many guides to Samba that you will read grant much more access across the LAN between machines. I consider that broad lowering of defenses as reckless... and not particularly useful, either.) (If you are doing all of this for a user other than the standard "pi", then the "pi" here would be replaced with the ID of the user in question.)

Line 5: I believe that this makes it easy to simply use a File Manager or Open dialog to drill down to files in the shared folder.

Line 6: Many guides to Samba say make this "writeable=yes".

Line 7: I don't really understand the "only guest" property yet. It might reward investigation.

Line 8: I strongly suspect that this is an important property to do with the permissions granted/ required in respect of creating files in the share. Well worth further study.

Line 9: I strongly suspect that this is an important property to do with the permissions granted/ required in respect of directories associated with the share. Well worth further study.

Line 10: I'm not sure what the "public" property is about. Would making it "yes" grant easier access to the folder? "no" doesn't restrict access beyond what I find satisfactory. I believe that setting it to "no" means that people wanting access have to give a user id and password. (We'll come back to that process.)

So... that's the discussion. What you would add to your smb.conf would look something like the following...

#Section added by tkb on 17Aug18
comment=Share for Raspberry Pi by tkb from 17Aug18
only guest=no
create mask 0777
direct mask 0777

Right! Getting fed up? Nearly there!!!

Save smb.conf with your edits.

One last set-up task...

Every user of the system has a password. The Samba services are password protected too! You probably "should" use a different password for your Samba rights... but, at a small "charge" to security, I was lazy and used my general user password for my Samba access, too. Use the CLI to issue the following command...

sudo smbpasswd -a pi

... to set the password which will allow user "pi" access to the Samba managed resources. If you've told your system to ask for your "general" password every time you use sudo, then first you are asked "[sudo] password for (user) pi:". Nothing will appear on the screen as you enter the password, remember. Press enter when you've entered the password. Then you will be asked, twice, for the SMB password you want put on the account to lock it.

Henceforth when you try to use Samba to do things, e.g. browse to a folder on another computer, shared across the LAN, there will be times when you are asked for your password... sometimes your general password, but, more often, for Samba tasks, your Samba password. (If you use the same password for both, your are Bad... but you won't have torn hair.)

Job done?

Right! As usual, the changes you made to the Samba configuration file have not been "seen" by Samba yet.

Save any work you have open, and reboot your Pi. Samba should start in the background, as the Pi starts up.

Now try to use it.

From a Windows machine, if your Pi isn't immediately visible, enter...


... in the Windows machine's File Explorer address bar. That is to say, if you gave your Raspberry Pi "MyFirstPi" for its hostname, then you'd tell Windows to look for...


The "\\" have to be BACK slashes, by the way. "//" will not do.

You should be able to drill down to the LANsneakernet folder.

You may find a bunch of folders there that you didn't create: "IA64", "W32ALPHA", etc, etc (7 in all). I don't know what they are. I won't be disturbing mine until I'm more knowledgeable. They're doing me no harm.

Assuming you have a folder set up for read only sharing from the Windows computer, to the LAN, see if you can get into it from the Pi.

On the Pi, in the GUI, start an instance of the File Manager.

Use the menu item "Go", and from it, "Network".

My LAN has an odd assortment of things on it. When I did Go/ Network, I saw, in the first window, the Pi, by its hostname. Fine. Not useful, but it is on the LAN, so it is right that it should appear here. Then one of the Windows computers appeared, here, by its name. And then there was an entry for "Windows Network". Double clicked that, and was taken "down" to a window with just the name of my Windows workgroup. Double-clicked on that. Was taken down to a list of the PCs on the LAN.

Drilled down again, and got a request for user name, domain, and password. Give your current Pi user name. (Probably "pi"), Fill in the Windows workgroup, for "domain"... probably all in capital letters. Enter the SMB password for the Pi user you are currently logged in. (Here, you WILL get an asterisk for each character you type of the password. It is in the CLI that Raspbian often puts nothing on the terminal during password entry.) Make a choice about the lifetime of the log-in. (I REALLY DON'T LIKE "Remember forever". If you have to put the password in from time to time, there's a better chance that you won't forget it, and be in a jam when you need it one distant day. AND: if someone steals your shirt-pocket sized Pi, do you want to save him/ her password hassles?)

You may have to enter the password a couple of times, as you drill deeper and deeper, but eventually you should be able to load files from the Windows machine to the Pi! (Simple text files are a good place to start.)

I very much hope that went well for you?

I'm sorry that was a bit protracted. And hope that you don't have to struggle through it too many times to eliminate the last glitch, last typo. Please let me know where the sticking points were, if I can improve this guide for the next reader.

This page was just "a sidebar" off of my main "Getting started with Raspberry Pi" page. Feel free to contact me (see below) with comments, suggestions, questions... save the next reader being confused by something? Please cite this page's URI, if you do: pt0FirstFileShare.htm.

Further reading

There are, of course, many pages about this on the internet. I found the following helpful...





Please remember that this material is copyright. (TK Boyd, 2018) There are further notes in this page's parent page.

   Search this site or the web      powered by FreeFind

Site search Web search
Site Map    What's New    Search

The search engine is not intelligent. It merely seeks the words you specify. It will not do anything sensible with "What does the 'could not compile' error mean?" It will just return references to pages with "what", "does", "could", "not".... etc.

This page is a "sidebar" to my main discussion of Getting Started with the extraordinary Raspberry Pi.

To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcome!

Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes. There were two "unknown attributes" in Google+ button code. Sigh.

Why does this page cause a script to run? Because of the Google panels, the code for the search button, etc. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....