Windows Networking on the Raspberry Pi

The goal of this article is to configure the Raspberry Pi so that it can integrate into an existing Windows Networking environment without needing to make changes to any of the other, perhaps numerous, Windows PCs.  I know that there are numerous other ways to achieve networking like this though so please don’t feel the need to tell me about them in the comments below.  Please note that I will be doing a version of this article for the Apple Macintosh too.

A good way to do some programming on the Pi is to access the Pi file system over the network.  The advantage this gives you is that you can speedily browse the web for snippets of code under Windows and then copy / paste them directly into a file on the Pi.  This method works really well for me and it also allows me to easily back up my source code onto my main Windows machine.  Or you might just want to turn your Pi into a NAS device!

So this guide is intended for someone who is familiar with Windows Networking already.  If you have never used it before there are plenty of good guides out there which you can read.  Perhaps try and network two normal Windows PCs before you try this.

So we’re going to use Raspbian for this, first off make sure you download the most recent Raspbian image and burn it onto an SD card.

Before we get going I just want to mention a Windows program that you should familiarise yourself with.  Putty (above) is a terminal client program that will basically allow you to have the Raspberry Pi command prompt (the Shell) inside a desktop window (see below).  Raspbian comes with an SSH (Secure Shell) server that makes this possible.

Don’t confuse this with a full remote desktop program though, it just gives you the command prompt.   If you were to try and type startx inside Putty it wouldn’t work.  Putty only supports text based ouput.  However you can do things like install programs, move files around, reboot the Pi etc.  Basically everything you would normally be able to do if you were using the normal Linux command prompt on the Pi itself.

Where am I going with this?  You can copy and paste Linux commands directly into Putty from a web site such as this without having to manually type them out.  It will save you having to carefully check that you’ve typed the commands in correctly and therefore bags of time.

You can download Putty from here (putty.exe is the one you want).  It doesn’t have an installer package, it’s just a standalone exe file.  When you run it you’ll see the configuration screen below.

Enter the IP address of your Pi into the host name field and click the Open button.  If you don’t know the IP address just type ifconfig at the Pi command prompt and the address is on the second line just after inet addr.  You can ignore the security warning (below) and click yes (you’ll only see that warning once).  Note the Save and Load buttons, you need to provide a name under Saved Sessions to use those.

You’ll then have the usual login prompt, login with the same username and password as you would use on the Pi itself.  A paste in Putty is done by a right click of the mouse.  Copy and paste the following command into Putty and press enter.

sudo apt-get update

This just updates the package list so it’s ready for when we want to start installing new software, which is next!

We’re going to install a utility called Samba, yes like the Brazilian dancing but actually nothing like it.  It’s a suite of tools that allow Linux based machines to interact with Windows Networks and it’s also available for Raspbian.

Here is the next command to paste into Putty;

sudo apt-get install samba samba-common samba-common-bin winbind

A message saying that about 50 MB of disk space is required will show along with a prompt asking if you want to continue.  Just type y and press enter and the installation will begin, it may take a few minutes to finish.  If you’re wondering what winbind is; this is a small background process that announces your Pi by name to Windows PCs on the network, allowing them to use the actual host name instead of the IP address.

If you go to a Windows PC now, bring up a command prompt and enter ping raspberrypi (or whatever host name your Pi has) you’ll see that you get a reply.  You can also use the same host name in Putty from now on.  We’re not quite finished yet though.

We now need to edit the configuration file for Samba to specify how we want things to work, its a bit laborious but we only need to do it once.  I recommend you also do this in Putty so you can continue to copy and paste.  So we’re going to change to the Samba config folder, make a backup of the default config file and then edit the file using a program called nano.  Enter the following commands one by one.

cd /etc/samba

sudo cp smb.conf smb.backup

sudo nano smb.conf

You will now see the top of the config file, it should look something like this;

# Sample configuration file for the Samba suite for Debian GNU/Linux.
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example

A hash symbol indicates a comment in this file, so any line that starts with one is either a comment or a disabled setting.  Scroll down until you find [global].  You should see a line saying workgroup = WORKGROUP.  Change this to match the workgroup or domain of your Windows PCs, this will make the Pi visible when you browse the network in Windows.  Also add a setting called realm and one called netbios name just below and set them to the host name of the Pi.

   workgroup = WORKGROUP
   realm = raspberrypi
   netbios name = raspberrypi

Press Ctrl – O then enter to save.  Do this periodically so you don’t lose any changes.  Don’t concern yourself with what all the various settings mean, you can read up on this if you really want to know.  The comments often describe them quite well though.

A bit further down you should find this line, remove the semi colon.

;   name resolve order = lmhosts host wins bcast
   name resolve order = lmhosts host wins bcast

Next scroll down until you find;

####### Authentication #######

A bit below that you should see this line, remove the hash.

#   security = user
   security = user

So this is turning on user level security.  It will allow you to access the Pi from a Windows PC using your Raspbian login (for example ; pi / raspberry).  Save your changes.

So we now need to set up some Samba shares, these are equivalent to Windows shares and allow you to see the files from another computer.  Let’s make two shares.  One which is the home directory of the Raspbian user (cd ~ at the command prompt) and one NAS type share that all users can access.

Scroll right, right down until you find this.

#======================= Share Definitions =======================

Just under it you’ll see [homes].  Modify the settings so that they match what is below, copy and paste if desired.

   comment = Home Directories
   browseable = no
   valid users = @users
   writable = yes
   create mask = 0700
   directory mask = 0700

A bit further below you’ll see a line saying read only, change the yes to no.

   read only = yes
   read only = no

Press Ctrl – X, y then enter to save and exit nano.  We now need to create the physical folder for the NAS-all-users share.  For this example I’m going to make the location of the NAS folder /home/samba-share/nas (which is on the Pi SD card) however you may want to change this to share a USB drive that you’ve connected to the Pi.  In which case the path would be something like /media/usb0.  You’ll need to check out what the drive name is by using the command below.  If you need some help with mounting NTFS drives, have a look here.

ls /media

The name usb0 may not be the same for you.  You can then just substitute /home/samba-share/nas for the correct /media/usb0 path in all the text that follows.

If your nas folder is going to be on the SD card then you should copy and paste the following commands into Putty one by one.  Otherwise you can skip them.

sudo mkdir -p /home/samba-share/nas

sudo chown -R root:users /home/samba-share/nas/

sudo chmod -R ug+rwx,o+rx-w /home/samba-share/nas/

The first line creates the actual folder and the second two set the permissions on it so that all users can have read, write and delete permissions.  We now need to add the settings to smb.conf to make this folder visible as a Samba share, so run nano again.

sudo nano smb.conf

Scroll right to the end of the file and paste in the following settings.

   comment = All users
   path = /home/samba-share/nas
   valid users = @users
   force group = users
   create mask = 0660
   directory mask = 0771
   writable = yes
   read only = no

Press Ctrl – X, y then enter to save and exit nano.  The last thing to do is to create a Samba user to match your Raspbian user, then we can reboot and it should be ready to go.  Copy and paste the following command, you will be prompted to enter a password twice, enter the same password that you use to login to Raspbian with (e.g. raspberry).  Note that when you type a password no letters are shown, this is normal Linux/Raspbian behaviour.

sudo smbpasswd -a pi

You should then see Added user pi.  That is the configuration side of things done now, you can go ahead and reboot the pi.  You can send the reboot command from Putty, but you’ll then see a messaging saying that the server closed the connection.  This is obviously because it’s going down for a reboot!

sudo reboot

While the Pi reboots you can go onto your Windows PC and get ready to browse the network.  On Windows XP you should see something like this.

And on Windows Vista or 7 something like this.  If you’re using Windows 8, please have a look at the comments on this article at the end.

Double click the Pi server icon in Windows and you should be prompted for a username and password.  Use the same that you use for Raspbian (e.g. pi / raspberry).  You should then see two shares; nas and pi.  In some cases you may see the nas share only, before being prompted for the login details.  If this happens you’ll be prompted when you try to access the nas share whereupon the pi share should become visible.

Once you’re in, go into the pi share and to test it’s working just right click and go New > Folder.  If it lets you create and name the folder you’re in business.  Maybe try copying a large file over to the Pi and see what kind of transfer speed you get.

You can check that the changes you made from Windows are now visible on the Pi itself.  Either login on the Pi or via Putty and just type ls from the home directory.  Below we can see the “dave” folder I created from Windows.

So that is pretty much it.  If you’re interested in seeing a good way to do some code editing from Windows with the Pi just being used to test and run the program then read on, otherwise you’re done.

So if you already have a preferred code editing tool then you can just use that.  Otherwise I can recommend a nice lightweight program called Notepad++.  This program is tremendously convenient for code editing since it integrates with the Windows shell right click menu, allowing you to right click on any file to edit it.

So from Windows, browse into the pi share.  Right click and go New > Text Document and name the file test.c.  You now need to open this file in your Windows code editor.  If you’re using your own program you may need to re-browse to the pi share from the File > Open menu.  However with Notepad++ you can just right-click the file and select Edit with Notepad++.

Copy and Paste the following code into your code editor.

#include <stdio.h>

    printf("Hello World\n");

So you should now have something like this.

Save the file from your code editor and we’ll now go onto the Pi to compile and run it.  You can either log onto the Pi itself or use Putty.  After logging in type ls and you should see the test.c file, that you created from Windows, is shown.  Enter the following commands to compile and run the program (gcc is the c compiler program).

gcc test.c -o test.bin


If everything has worked you should see the Hello World message, as shown below.

Every time you make changes to test.c you will need to recompile it using the gcc command above.  Try doing that now with the code below.  This will make your Pi count to a million, press Ctrl – C while running if you want to stop it.

#include <stdio.h>

    int i;
    for (i = 1; i <= 1000000; i++)
        printf("%d\n", i);

The good thing about Notepad++ is that it provides some nice features that colourise the source code.  Most code editing tools will do this as it makes the code easier for a human to read.  We’ve just been using C, but Notepad++ will also do the same thing for other languages like Python too.

From Windows have a look inside the python_games folder and check out the code in the .py files that are in there.  Good luck.

50 thoughts on “Windows Networking on the Raspberry Pi

  1. Hi
    Thanks for the tutorial. Excellent, it worked first time. I’m an Analyst/Programmer. I mainly develop databases and for the several years I’ve consentrated on Oracle Apps. I’ve worked for a couple of large orgs and was ‘aware’ of networky things, but the network and databases were managed by DBA’s and Network Admins, sometimes not the most helpful of persons. Consequently, computing became much of a ‘means to end’ . Getting a Pi and reading helpful tutorials like yours appears to spaked off my interest in computers again. I don’t aim to become a network person, I’ve gone through too many pain barriers to start again. My aim is to ‘understand’ and not allow DBA’s and network people to baffle me with science or let them rub their own egos at my expence, so BIG Thank You for helping me start my quest in a painless way.

    • I have a quick question I am trying to run samba on windows 8. I follow exactly what you have but when I look at my networks nothing appears. do you know what I may be doing wrong or what the issue is? I am a beginner programmer so any help is appreciated

      • I haven’t actually tested it with 8 yet. Only XP, Vista and 7 so far. I’ll have to do some checking and get back to you. Just had a quick look on a work colleague’s laptop though; use the Windows 8 search function to find Windows Explorer. Run this and when it comes up you’ll see there is an address bar at the top. It’ll probably say Libraries in it. Delete this back, enter \\raspberrypi and press enter. If it’s working you should get prompted for the username and password. If not then something else is wrong.

      • If \\raspberrypi doesn’t work then try using the IP address of the Raspberry Pi. Like so \\192.168.0.XXX
        You can find out the Pi IP address by typing ifconfig at the command prompt, the address will be shown on the second line.
        It might be that the Samba winbind daemon doesn’t like Windows 8.

  2. Great tutorial. Your instructions are very well presented; especially for a Linux novice like myself. The only time I got confused was when my smb.conf file didn’t have some of the lines yours has.

    Moreover the file on Raspbmc has a section for ‘devices’. This seems to allow access to all connected devices, negating the need to add individual devices. I may be wrong, however!

    Thanks again, you’re the only person I’ve found that has clearly explained how to do this.

  3. A really great tutorial. Many thanks. Worked just fine from Windows 8, though file explorer didn’t show the pi by name, I navigated to \\192.168.nnn.nnn instead. Ping-ing the name works OK, however.

    • That is interesting. I would have thought that if Windows can resolve the name to the IP address via ping then it should also work via Windows Explorer. Can you just do the ping again and verify that the reply address the ping is coming from is indeed the IP address of the Pi?

  4. I have followed this guide (to the best of my abilities!!), but,
    In Windows Vista, I can see RASPBERRYPI , click and can see nas, click and enter ‘Pi’ & raspi password. I get the message ‘Windows cannot access \\RASPBERRYPI \nas (Access is denied). However I can now see, open and write to network folder ‘pi’.
    In PUTTY if I run the following commands I get;
    $ cd /mnt/nas/
    -bash: cd: nas: Permission denied
    $ ls -latr
    drwx—— 1 root root 4096 May 6 09:00 nas

    If however I run;
    $ sudo chown -R pi nas
    $ ls /mnt/nas
    I can see the contents of nas, and in Windows Vista I can also read the contents of nas, however I am unable to write to nas, I get the message ‘you need permission to perform this action’.

    Whist following your guide, when I ran $ sudo chmod -R ug+rwx,o+rx-w /home/samba-share/nas/
    I got;
    chmod: changing permissions of `/mnt/nas/Paul/Music excluding iTunes/Music/': Operation not supported
    For every file in the volume.
    The volume is formatted NTFS in a usb hdd.

    Hope you can help,

  5. Correction;
    ….when I ran $ sudo chmod -R ug+rwx,o+rx-w /home/samba-share/nas/

    Should read;
    Whist following your guide, when I ran $ sudo chmod -R ug+rwx,o+rx-w /mnt/nas/

    • Ah yes, I did mention about this. If you re read the paragraph after the “read only = no” line I just ask the reader to substitute the correct path in the following commands. Maybe I need to make that more clear.

  6. Sorted! the USB drive was mounted in fstab as ‘ntfs’, but by changing it to ‘ntfs -3g’ made the partition visible & writable.
    Great write up, thanks arc.


  7. Cheers, first time I’ve used Linux on anything at home and your walkthrough… walked me through getting on with a Windows network.
    Thank you.

    • Okay, so just before you enter the compile command type ls and see if you can see the file test.c. Look at the final picture in the blog post. If you can’t you may have saved this file either on your Windows PC or in another location on the Pi.

  8. Hey I have a new Pi I have configured with Cups and Samba to be a print server for our Windows PCs. I followed your guide here for the NAS for most of the settings for Samba and I’ve looked at other guides online. Maybe you can help me. I see the Pi listed in explorer and I try to browse to it I get prompted for a password. I enter the standard info but it just comes back like its invalid. I’m running Windows 7 Pro. Any tips, please?

    • That sounds like you may not have added a samba user yet… find the part of the article above that says sudo smbpasswd -a pi and start from there. Let me know if this helps or not.

      • Ok, I did that, but still the same result. It comes back with the password box right away. Is there a specific thing I need to do to make Windows pass the credentials as is. I work in networking, so normally I’m used to seeing these credentials pass using domain / username, then password.

        That’s sort of what my Windows password window shows with my host computer name listed as domain under the username / password fields. Even if I put in the hostname of the PI when I pass the credentials it doesn’t change the outcome. Neither of these systems are on a domain.

    • Still have not been able to get it working, its the same result on my brothers Mac, he gets password box, we enter the credentials and it doesn’t accept.

      • Ok I got it working now. I just decided to start fresh and reformatted my SD card with Raspbian again. After a fresh load of Samba first, configured, then loaded Cups, and then configured that too. All is well. Thank you for the great tutorial.

  9. Thanks a lot for this excellent tutorial. As a silverkid ager of 64 I can confirm the ease and comfort of using it with a first run success. I am using the W7-remote instead of Putty – however, it does not allow for c&p.
    Again – thx a lot.

  10. Worked flawlessly except for the ping on Windows 7. I am new to the Pi and learned several things from this blog. Using samba and your tip on Notepad++ will help coding immensely via ssh. Keep up the great work!

    Will peruse your other blogs to see what else I might learn!

  11. I worked!

    I don’t know much about this stuff, so I needed a good walk-through like this. Good, complete instructions.



  12. Excellent Tutorial…So easy to follow!

    I wish folks would hire YOU to write their manuals!

    Keep us going!

    Many Thanks!

  13. Brilliant Instructions, worked first time!

    Have had a PI for over a year but only set it up last week. Used to work with Unix on Sun and SG workstations many years ago so it’s been a real nostalgia trip.

  14. I followed the guide, as far as I can tell without mistake but when I get to rebooting the pi and seeing it in windows7 in my network folder I can see RASPBERRYPI but when I open it, it is just empty. No log in details no passwords just looks like an empty folder.

    Can anyone help?

    • Try changing
      browseable = yes

      Then try mapping homes as a network drive, selecting the checkbox “Connect using different credentials”

  15. Ahhhh…. Man, much appreciated. Seriously good tut. I ran through several youtube videos trying to refresh my memory on samba config. Been a long while and this was perfect.

    Now to undo it all and see if my 10 year old son can run through it…

  16. Outstanding!
    worked first time.
    I have a Drobo5n on the network.
    I want to run Calibre-server on the Pi to access the calibre libraries on the Drobo.
    (I can do this on windows)
    I have mounted the Drobo to a directory on the Pi and can see all the data.
    How ever Calibre-server does not run but comes up with an error ‘database locked’
    The only comments I can find on the web are that Calibre is not intended for a network.
    I have given up , for now, and will put the calibre libraries on an attached drive to the Pi.

  17. Great tutorial. Worked as written.
    I do have one question though. In the pi shared directory I made a sub directory of test (Yours was Dave). When I place the test.c file in that sub-directory and type ls while in putty, it does not find the file test.c. Need everything always be placed in the pi shared folder?

  18. Brilliant! Does just what I want – except for…….

    I am looking at building a security camera, how can I stream the output direct to my PC?

    If you are too busy to get back to me don’t worry as I am sure there is info out there somewhere.

    Again, thanks for this tutorial.


  19. I am very new to the Pi. I have been struggling with all kinds of tutorials, Youtube videos, books etc. to get my Pi on the Windows network. I was really getting frustrated.

    This tutorial simply works perfectly the first time around. All is good and I really appreciate you posting it. It was a major boost to my morale!!!

    I copied smb.conf over to one of my windows work stations for a backup of it. When I open smb.conf with Windows notepad on the work station it appears there are no CR/LF in the file i.e., it is one continuious line, changing word wrap does not help. Anyone know how to get the CR/LF to appear so that smb.conf is editable using Windows notepad?

    • Well I answered my own question! The suggested Notepad++ works fantastic and shows the CR/LF.

      I am so glad I ran across this tutorial, invaluable!!

  20. Really a great tutorial. Thank you very much.
    It covers the wohle windows networking with raspberry.
    But I just need to resolve the name of a windows machine on the raspi.
    My raspi writes to “ms-sql server” in a windows network, wich works fine if i use the ip-address of the machine. But using the Name the raspi can’t resolf it.
    Is there a way to resolve the name using “wins” ?

  21. Your tutorial works well. I have a problem though…
    From the pi using PCManFM I can see the Windows network, and I can access shared directories that the computers and NAS on the network are offering. I can drill down and see files, but when I click on them (such as txt or jpg) an application starts on the pi to display, but it shows nothing. Is this a permission problem?
    The shared files should be readable by anybody (and they are from Windows computers).

  22. Dave, excellent tutorial. Your step by step was one of the best, no left out instructions or things to read between the lines. Thank you very much. It works just as expected! Steve

  23. Really excellent tutorial on setting up networking w/ Windows. Wish I had you to write my user manuals!!

    I would like to setup printing from my RaspberryPi. I understand that this requires a package named Cups. Can you suggest a good source for a tutorial on setting this up?

  24. Well, never mind…
    I found that after setting up my network with the help of your excellent tutorial installing my network printer w/CUPS was a breeze. Thanks again!

  25. Hi there – great tutorial thankyou.

    Problem I have is that I only seem to have 2 sections in my smb.conf file namely [global] and [pi] and even the “line name resolve order” etc. is missing. Your input would be appreciated.

    Thanks for that

  26. Further to prev message I have tried to reconfigure the smb.conf file via samba but it is still missing most info. The /usr/share/samba/smb.conf looks ok (apart from missing the [homes] writeable=yes line) so do you reckon reckon I should copy that to etc/samba/smb.conf and start to edit it?


  27. BTW Putty can be used to support access to the GUI on the RPI, this is done by switching on X11 forwarding before establishing a connection. You will also need an X11 server installed and running on the client (e.g. Xming on Windows). Run startx on the RPI over the SSH connection from PuTTY and you should be able to access the GUI.
    That being said, there are more efficient protocols that offer compression and better features for remote access to a GUI running on GNU/Linux e.g. RFB (used by VNC).

  28. Thank you for very detailed tut. I have followed all exactly but still have a few issues, can you please assist.

    When I click on the PI icon in windows I do see my share folder (Pi_HDD) This is a mounted USB drive.

    Double click the Pi_HDD folder I get windows error: Windows cannot access \\SNYMANPI\Pi_HDD
    (SNYMANPI = this is my raspberry pi)
    (Pi_HDD = mounted USB drive)

    Can you please assist?

    Thank you.

  29. Windows troubleshoot reported the following:

    “SNYMANPI” exists but Windows can’t find “Pi_HDD”
    Setup correctly in Samba config file:
    Path = /mnt/hdd1/downloads

  30. Just installed samba following your tutorial. I can see my pi on the local network. The shared directory is visible. When I try to access it and enter my pi username and password I can’t connect and I am prompted to enter my password again.

    Any idea what I may have done wrong?

    I did go thru the configuration twice and did not find any errors.

  31. Sadly I still don’t know why but now it works. Changed nothing, no reboots. Just started working. Will it break again?? Only if I really need it to work.

Ask a Question or Leave Some Feedback

We will not display your email address. Fields marked with a * must be filled in.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>