How to Share A Folder via SMB/CIFS Protocol in Ubuntu 20.04

Last updated: July 5, 2020

gnome shell

This is a step by step beginner guide shows how to share a folder over local network via SMB/CIFS protocol in Ubuntu 20.04 Gnome desktop.

Share a folder in Ubuntu 20.04:

1.) First open terminal by pressing Ctrl+Alt+T on keyboard. When it opens, install samba, SMB/CIFS file, print, and login server by running command:

sudo apt install samba

Type user password (no asterisk feedback) and hit Enter to continue.

2.) Open Files (Nautilus file browser) and right-click on the folder you want to share, then click on “Local Network Share” menu option.

3.) In next pop-up window, do:

  • tick “Share this folder” to enable network sharing.
  • (optional) tick “Allow others to create and delete files in this folder”
  • (optional) tick “Guess access”
  • finally click on ‘Create Share’ button

4.) Confirm write permission (if enabled) and done!

5.) If you want remote PC to type username and password to access the shared folder, open terminal (Ctrl+Alt+T) and run command:

sudo smbpasswd -a USERNAME

Note:The “USERNAME” must be an existing user in your Ubuntu. It’s ji in my case. And set a password for remote smb access only.

Before getting access from remote PC, you may check out the IP address and / or hostname by running commands:

hostname

ip -4 address

Access the share folder from remote computer:

1. To access from Windows PC, go to Start -> Run to bring up Run command window. Type either \\ip-address\ or \\hostname\

2. To access from another Ubuntu desktop, go to Files -> Other Locations, then type either smb://ip-address/SHARE_FOLDER or smb://hostname/SHARE_FOLDER

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

7 responses to How to Share A Folder via SMB/CIFS Protocol in Ubuntu 20.04

  1. When I click “create share” in step 3 I do not get the message shown in step 4. I get the following:
    ‘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.

    What do I need to do?

    • Remember to create shared folder names different from user account names.

      • Thank you for the info. This pertains to 20.04 LTS

        Two things I found is that to be able to even list what’s in the shares you need to comment out a line (or change it to no) in the default smb.conf

        Originally
        obey pam restrictions = yes

        either
        obey pam restrictions = no
        or
        ; obey pam restrictions = yes

        and restart samba.

        Now you can list and read files in the shared folder.

        And in Nautilus, shared folder names should be different from mount points if sharing entire disk partitions. ex. if you mounted the disk /mnt/sda3, the share name should not be sda3.

        If the names are the same, then you won’t be able to write/delete on to it from a client.

        • Yay! Thx for your “..pam..” tip.
          =fixed fail open share on Lubuntu 20 desktop from lubuntu 20 laptop.

    • Start a privileged nautilus from a terminal

      $ sudo nautilus

  2. Wont work

  3. I’m having two HDDs in one PC – one for UBUNTU 20.04 and the other for WINDOWS 10. I would like to make entry to some folders of UBUNTU from WINDOWS 10 platform. I had followed the guidelines given by you here-in-above, but couldn’t succeed to locate the shared folder kept in UBUNTU Desktop from Windows 10 platform. Wouldn’t it be possible in a same PC?