How to share files and folders in Ubuntu

This brief tutorial will outline how to enable file sharing in Ubuntu.

  1. Sharing files and folders across your network from your Ubuntu PC is every bit as easy as sharing files in Windows (arguably, it’s easier). Start by right-clicking the folder you want to share, and select Share Folder. If the services required to share files/folders aren’t installed, you’ll be prompted to install them.
  2. After clicking Install services they will automatically start to download and install.
  3. Once that has completed you’ll be presented with an options window. From here you can select the type of sharing (SMB or NFS), give the shared folder a name and decide if you want read-only access to the folder. Click OK when you’re done.
  4. If you right-click on your newly shared folder and select Properties and then the Emblems tab, you can give the folder a unique icon so you’ll know it’s shared.

  5. click to enlarge

  6. You can further modify the permissions of your shared folder by selecting the Permissions tab.

  7. click to enlarge

  8. Now open a terminal in Ubuntu and enter the command:

    sudo smbpasswd -a username

    This will add a SMB user.

  9. And now other computers can connect to your shared folder!
{ 59 comments… add one }
  • Ferdinand May 20, 2007, 7:32 am

    And when it asks you for the username and password? Do you give the username and password of the linux account?

  • Ross McKillop May 20, 2007, 2:19 pm


    Yes – sorry I should have included that – will update shortly.

  • Sven May 23, 2007, 4:05 am

    I have Ubuntu 7.04 running in Parallels Desktop. Will it possible to access a shared folder from Mac OS X running on the same machine. I tried it but it didn’t work.

  • Aamir June 4, 2007, 4:31 pm

    I tried this, and cannot log in (from my windows machine) via my ubuntu username. (which is “aamir”). I can see the PC in “My Network Places”.

    Please assist!

  • Brian June 6, 2007, 10:02 am

    I tried the same approach as the one listed here but, under OS X (10.3.9), after I enter the Ubuntu admin username and password I get an error which says Can not connect as the username or password is incorrect.

    I have attempted to connect from Ubuntu to the mac and that way works but not from the mac to Ubuntu. Any ideas?

  • soup June 12, 2007, 10:23 am

    To connect to your shared Linux folder on a Windows machine, enter sudo smbpasswd -a (username) in terminal and set your SMB password.

  • Tuomas June 20, 2007, 3:37 am


    It seems that you also need to add a samba user :

    sudo smbpasswd -a usernamen

    After that started to work with my installation

  • utunbu June 28, 2007, 1:58 pm

    Please include that we also need to add the user as a samba user using the command into the main article… I thought I had done something wrong until I scrolled down to see the comments

    Thanks for the article.

  • Lee Farris July 8, 2007, 10:29 am

    Excellent support article here. I have only been using Ubunta for couple of days and I love it. My feelings for Windows XP and Vista are moving more and more towards Ubunta.

    Thank you for your help.

    Lee Farris

  • John August 1, 2007, 7:54 pm

    yeah… another one that was stumped until the comments about adding the samba password…

    now it works great!

  • Peter September 21, 2007, 10:46 pm

    Great article, although you’re missing half the equation. You need to add a user as several people have mentioned before you’re tutorial can work. (and a possible samba restart? – I just did it just in case)

    sudo /etc/init.d/samba restart

  • Ross McKillop September 21, 2007, 10:56 pm

    Peter – yeah I really do have to update this. The samba user step I forgot as it had already been created. Thanks!

  • descent October 20, 2007, 4:13 am

    And what should i do if i want Windows users to connect to my shared files without entering any password?

  • Donald November 8, 2007, 5:20 am

    Thanks for the guide- I’ve been trying to work out if it is possible to share files in Ubuntu all morning and finally found this page.

    I right clicked on a file on this computer and installed both services, then chose SMB because NFS asked me about IP addresses, network name which I don’t know off hand.

    My other computer asked me for a password for MSHOME but did not recognise my Ubuntu password.

    Tried sudo smbpasswd -a usernamen as above with no success.

    Then went through the same process on my other computer and found I could access the shared folder with no problem from this computer.

    I checked permissions/folder access on the shared folders on both computers and found one set to ‘access files’ and the other to ‘none’. (These were the default settings- don’t know why they were different.)

    I was then able to see the shared folder on the other computer without being asked for a password.

    Under what circumstances is it necessary to set up a samba password?

    I think file sharing in both directions is working now, even though I haven’t gone through the password process on this computer.

    If possible could you include an idiots guide as to the relative merits of SMB and NFS (and indeed, what they are).

    Is there any reason to use NFS when SMB seems to be far easier to set up?

    Again, many thanks!

  • salvatore November 11, 2007, 6:35 pm

    While I should have known better, the ‘smbpasswd’ step had me stumped. Thanks for the kick in the right direction.

  • chris November 12, 2007, 10:14 am

    how do you connect to your shared folder ?

  • Kenster November 14, 2007, 5:06 pm

    How do you setup a shared folder that allows anonomous windows users. I would like to create an “In Box” folder and share it to my entire network so users can grab files from it or place files in it.

    In a network of hundreds of users putting a username and password for each user will not work.

  • ln November 18, 2007, 1:50 am

    same here:

    sudo smbpasswd -a usernamen

    fixed it for me, wasted a couple of hours today trying to get it working


  • reincarnut November 28, 2007, 9:11 am

    gosh, i went through the smbpasswd thingy too.

    and as a newbie, it took me 3 days befor i found this page… dang!

    thanks a ton, soup on Jun 12, 2007


  • benhur March 25, 2008, 8:14 pm

    thanks a lot! this worked for me!

  • peter June 11, 2008, 11:39 pm

    when i try to let ubuntu install the services for the first time, i get no choice regarding the protocols. hardy just installs samba, but not nfs…what’s wrong here?

  • James June 12, 2008, 3:29 pm

    I’m running two computers with Ubuntu and I tried all of this and I still don’t see anything when I go to Places–> Network. Do I need to change settings on my router?

  • stanley82 June 21, 2008, 7:31 am

    Well hardy heron ubuntu I did most of the above including the smbpasswd stuff. The process was similar but not exact. On my simple Xubuntu machine sharing right click sharing is not an option. On win98 net neighbourhood there is no singn of Ubuntu. Any suggestions? Ian

  • Matt June 21, 2008, 10:37 pm

    I get

    ‘net usershare’ returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied
    You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share.

    When I try to share the folder.


  • me too June 29, 2008, 4:58 pm

    I also get the error,
    “net usrshare returned error 255” when I try to create a shared folder in ubuntu Hardy heron.

  • corq July 8, 2008, 12:51 pm

    Thanks!!! I have one lonely *nix machine on a windows domain – I appreciated this.

  • Glenn July 8, 2008, 11:42 pm

    Something is missing from the instructions. Here is what I get:

    ‘net usershare’ returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied
    You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share.

  • Brad July 18, 2008, 6:00 pm

    I am also installing on hardy and running into this problem:

    ‘net usershare’ returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied
    You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share.

    any ideas there?

  • Brad July 18, 2008, 6:19 pm

    ok here is the hardy fix:

    I selected to install samba (file server) when i installed hardy server edition-this is ok.

    when i got the desktop installed i tried to right click in nautilus (file explorer) and share the file and I got the previous error (net usershare 255).

    to fix it i went to system ->administration -> users and groups. then unlock (enter password) then manage groups. choose sambashare then properties. select your name hit ok, close, close.

    Then logout and log back in and then right click and try to share the directory.

    For some reason in hardy samba doesn’t add you to the sambashare group.

  • Adriaan August 16, 2008, 3:16 am

    I didn’t do any of that sambashare stuff! I just followed what Brad said and it worked for me.

    “to fix it i went to system ->administration -> users and groups. then unlock (enter password) then manage groups. choose sambashare then properties. select your name hit ok, close, close.

    Then logout and log back in and then right click and try to share the directory. ”

    Thanks for the help. When I tried the first fix in the command line thing, it always said cannot modify password, so I gave up and tried Brad’s sollution, and voila, it worked!

  • ringi September 4, 2008, 6:49 pm

    Great howto THX

  • Carlton Smith October 24, 2008, 5:13 pm

    Well, I followed all of these instructions and I’m still getting the error. Is there a specific folder I should be using to create these shares?

  • Chris November 4, 2008, 1:39 am

    A nice easy workaround that works for many things is as follows:

    Open Terminal —> $sudo nautilus

    This opens a “explorer” (nautilus) with root privileges. Then apply your shares by right clicking on the folder that you wish to share and selecting “Sharing Options”.

    This works for me on so many levels, and only using Linux for three months, saves me looking up other terminal commands.

    I love Ubuntu Linux. Have changes all but my Vista Media Center PC now (and will not change that due to the XBox 360 and Linksys extenders).

    I hope this helps.

  • mark February 22, 2009, 1:31 pm

    None of this works for me. Tried it all and still no sharing of files. Running Hardy Heron and frustrated entirely with sharing in Ubuntu. I can neither access shares on a WinXP box nor can I share Ubuntu folders. What gives

  • Maxi March 24, 2009, 11:59 pm

    THANKS I didn’t know about the need of adding a SMB user to enable shares and that made me lose some time.

    How this whole process can be simple than a right click used in Windows still defeats me.

    Anyway, thanks

  • tester1 April 12, 2009, 10:42 pm

    I got the ‘net usershare’ returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied” before i logged out and logged back in. Then I used to get a “permission denied, user ‘xxx’ (the shared name I used for the folder) already exists in the system. So I changed the name in the “Share this folder – Share Name” field to something different. Note: this field is populated by your user name by default. Looks like this solved my issue

  • Z April 28, 2009, 1:23 pm

    Great article but… a normal user cannot do this in Ubuntu due to permissions. If they want to do this with using the terminal they have to Create a Launcher that runs the command ” gksudo “nautilus /” “. This will open a Nautilus session with root permissions and allow them to create the share.

  • Rubik May 26, 2009, 7:43 am

    Just what the doctor ordered. Thanks.

  • Martin May 26, 2009, 5:34 pm


    I can access the ubuntu files from any windows machine but I can’t see the windows computers in ubuntu just the workgroups, after a while of double clicking any workgroup says:
    “Unable to mount location, Failed to retrieve share list from server”
    I can access the windows ones from other windows machines

  • jitender sharma June 23, 2009, 11:03 pm


    i have ubuntu 8.10 and 8.04 but when we wants to sharing betwee n window XP . the file comes from window is locked and they are not open in ubuntu

    so tell me what is idea that are remove this problems


    jitender sharma

  • mathew July 16, 2009, 5:00 am

    I tried to follow the steps of allowing to share folders but when i tried to install this samba the window kept on reappearing i.e it failed to install

  • pias August 27, 2009, 7:43 am

    nice tutor, and i’t can access from XP SP2, now I have Ubuntu and Win XP SP2 computer, that I’ve installed a print on Win XP SP2 box… when I shared printer on LAN network from Win XP SP2 I confused/ I can’t used that shared print from Ubuntu 9.04??? any idea???

  • oceanmaster September 30, 2009, 4:30 am

    Wanting to share a folder and having problems? Try this:

    sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
    (backs up the smb.comf samba file)

    gksu gedit /etc/samba/smb.conf
    (opens the smb.conf file)

    Add this line below the “usershare allow guests = yes” line and save it
    usershare owner only = False

    4. (might not have to do this step)
    sudo /etc/init.d/samba restart
    (restart samba service)

  • ghost October 22, 2009, 3:51 pm

    Thanks Oceanmaster .
    I could see my shared ubuntu folders from Windows(Vista) but got an error when I tried to browse them. Now I can open them thanks again.

  • annoyed November 7, 2009, 4:37 am

    I had XP running on a PC set up as a server it crashed so I decided I’ll try Ubuntu instead of reinstalling XP big mistake as far as sharing files goes I tried all above suggestions to no avail. (1) fresh install me as only user (2) right clicked choose share installed sharing files (3) on windows pc saw shared folders asked for pw to access no pw worked (4) looked to web for solutions. (5) tried setting up password for samba share (6) restarted pc. Now shares are gone tried to right click and make shared again now even though I’m the only user and only account on this pc it say i don’t have permission to add a share needless to say I’m reinstalling XP. maybe I’ll try again a few years down the line when people make it a lot and i mean a hell of a lot easier to share files.

    XP = right click folder select share choose name click ok (DONE)

    Ubuntu = Just read above posts to see the number of steps involved. If even that will work.

  • Chris November 13, 2009, 12:36 pm

    The access from a Windows machine is unreliable at best. I set a smbpasswd, but first Windows was able to connect without requiring any password. Then a second try, and Windows can’t fnd the share at all. The third try, and it can find the share and see the share’s files, but it can’t read any of the files. I hate Samba. This is driving me nuts.

  • Chris November 13, 2009, 12:38 pm

    Note, when you’re trying to connect, open Firestarter, click on the Events tab, and right click on the Samba and Microsoft-ds events and mark them “Allow Inbound Service for Everyone”.

    This will prevent Ubuntu’s firewall from blocking Samba, which is what it does by default for some reason…

  • Marie-Micheline April 20, 2010, 12:21 pm

    Merci pour cette aide vais essayer maintenant.

  • fred June 11, 2010, 1:16 pm

    Thank you! It works great from OS X 10.5.8

  • zahid September 7, 2010, 7:06 am

    On Ubuntu 10.04 Lucid Lynx, I have noticed that you don’t need to do the samba steps.
    I can go into Network Neighbourhood on a Windows PC and can see my Linux PC and browse down to the shared folder.

  • Al September 14, 2010, 9:28 pm

    One thing you need to remember is you can only share items you own, i.e. in your home directory. In order to share other items, like backup folders on a usb drive, you need to create the share as an administrator. What I did was right click on the folder, scroll down to “Open as administrator”, click it, enter my password and then I followed the steps above. Remember that to enter “sudo smbpasswd -a (username)” in terminal and set your SMB password. Replace (username) with the name of the account and use your login password. I did this in Linux Mint 9 (based on Ubuntu 10.04) and it works great on both Linux machines and on my 2 macs. Lastly, on the sharing options tab, allowing guest access would not allow the folders to mount, so I left that checked off. I hope this helps.

  • Anirudh Tomer March 5, 2011, 9:01 am

    Thank you very much. I appreciate the work you have done. Its really well written.

  • Justin August 15, 2011, 6:58 pm

    Excellent tutorial – this allowed me to share files with my HTC Thunderbolt using es file explorer BUT –
    I spent two days trying to get my tbolt to connect but to no avail until I saw “AL’s” post about the
    “sudo smbpasswrd -a (username)” command from terminal – this was the missing puzzle piece.

    So a huge thank you to the author for a great, useful, (and most of all) working tutorial and a huge thank you to “AL” for the missing command!

  • Don December 3, 2011, 9:25 pm

    It would be nice if it worked, but after it says it has to install the service it says, “Could not apply changes! Fix broken packages first.” I searched for instructions on how to fix this but nothing works. In Windows, it works fine and so it’s much easier to do.
    (I’m running Ubuntu 10.4)

Leave a Comment